Skip to content

Commit

Permalink
Merge pull request #97 from FlintMC/bugfix/missing-version-properties
Browse files Browse the repository at this point in the history
Correct version on all annotations
  • Loading branch information
juliarn committed Jan 11, 2021
2 parents 940d762 + 913d49f commit f70dd68
Show file tree
Hide file tree
Showing 47 changed files with 103 additions and 66 deletions.
Expand Up @@ -70,7 +70,7 @@
*
* @return The subscribed method phase.
*/
Phase phase() default Phase.PRE;
Phase phase();

/**
* An enumeration representing all available phases.
Expand Down
Expand Up @@ -61,7 +61,7 @@ private ChatEventInjector(
this.receiveFactory = receiveFactory;
}

@ClassTransform("net.minecraft.client.gui.NewChatGui")
@ClassTransform(value = "net.minecraft.client.gui.NewChatGui", version = "1.15.2")
public void transformChatGui(ClassTransformContext context)
throws NotFoundException, CannotCompileException {
CtClass transforming = context.getCtClass();
Expand Down Expand Up @@ -92,7 +92,7 @@ public ITextComponent handleChatReceive(ITextComponent component, Subscribe.Phas
return (ITextComponent) this.componentMapper.toMinecraft(event.getMessage());
}

@ClassTransform("net.minecraft.client.entity.player.ClientPlayerEntity")
@ClassTransform(value = "net.minecraft.client.entity.player.ClientPlayerEntity", version = "1.15.2")
public void transformClientPlayerEntity(ClassTransformContext context)
throws CannotCompileException, NotFoundException {
CtClass transforming = context.getCtClass();
Expand Down
Expand Up @@ -59,7 +59,8 @@ private VersionedEntityAttackEventInjector(
parameters = {
@Type(typeName = "net.minecraft.entity.player.PlayerEntity"),
@Type(typeName = "net.minecraft.entity.Entity")
})
},
version = "1.15.2")
public void attackEntity(@Named("args") Object[] args) {
Entity entity = this.entityMapper.fromAnyMinecraftEntity(args[1]);
if (entity == null) {
Expand All @@ -77,7 +78,8 @@ public void attackEntity(@Named("args") Object[] args) {
@Type(typeName = "net.minecraft.entity.player.PlayerEntity"),
@Type(typeName = "net.minecraft.entity.Entity"),
@Type(reference = Hand.class)
})
},
version = "1.15.2")
public void interactWithEntity(@Named("args") Object[] args) {
Entity entity = this.entityMapper.fromAnyMinecraftEntity(args[1]);
if (entity == null) {
Expand Down
Expand Up @@ -52,7 +52,8 @@ private IngameMenuEventInjector(
className = "net.minecraft.client.Minecraft",
methodName = "displayInGameMenu",
parameters = @Type(reference = boolean.class),
executionTime = Hook.ExecutionTime.BEFORE)
executionTime = Hook.ExecutionTime.BEFORE,
version = "1.15.2")
public HookResult displayInGameMenu(Hook.ExecutionTime executionTime) {
if (Minecraft.getInstance().currentScreen != null) {
return HookResult.CONTINUE;
Expand All @@ -68,7 +69,8 @@ public HookResult displayInGameMenu(Hook.ExecutionTime executionTime) {
className = "net.minecraft.client.Minecraft",
methodName = "displayGuiScreen",
parameters = @Type(typeName = "net.minecraft.client.gui.screen.Screen"),
executionTime = Hook.ExecutionTime.BEFORE)
executionTime = Hook.ExecutionTime.BEFORE,
version = "1.15.2")
public void displayGuiScreen(@Named("args") Object[] args, Hook.ExecutionTime executionTime) {
Object screen = args[0];
if (screen != null) {
Expand Down
Expand Up @@ -45,7 +45,8 @@ public VersionedMinecraftInitializeEventInjector(EventBus eventBus) {
className = "net.minecraft.client.Minecraft",
methodName = "<init>",
parameters = {@Type(reference = GameConfiguration.class)},
executionTime = {Hook.ExecutionTime.BEFORE, Hook.ExecutionTime.AFTER})
executionTime = {Hook.ExecutionTime.BEFORE, Hook.ExecutionTime.AFTER},
version = "1.15.2")
public void minecraftInitialize(Hook.ExecutionTime executionTime) {
this.eventBus.fireEvent(this.event, executionTime);
}
Expand Down
Expand Up @@ -45,7 +45,8 @@ private VersionedTickEventInjector(EventBus eventBus, TickEvent.Factory factory)
@Hook(
executionTime = {ExecutionTime.BEFORE, ExecutionTime.AFTER},
className = "net.minecraft.client.Minecraft",
methodName = "runTick")
methodName = "runTick",
version = "1.15.2")
public void handleGeneralTick(ExecutionTime executionTime) {
this.eventBus.fireEvent(this.generalTickEvent, executionTime);
}
Expand Down
Expand Up @@ -66,7 +66,8 @@ private InventoryClickEventInjector(
@Type(reference = ClickType.class),
@Type(reference = PlayerEntity.class)
},
defaultValue = "net.minecraft.item.ItemStack.EMPTY")
defaultValue = "net.minecraft.item.ItemStack.EMPTY",
version = "1.15.2")
public HookResult slotClick(
@Named("instance") Object instance,
@Named("args") Object[] args,
Expand Down
Expand Up @@ -65,7 +65,8 @@ public void fireServerClose(PacketEvent event, Subscribe.Phase phase) {
@Hook(
executionTime = Hook.ExecutionTime.BEFORE,
className = "net.minecraft.client.entity.player.ClientPlayerEntity",
methodName = "closeScreen")
methodName = "closeScreen",
version = "1.15.2")
public HookResult closeScreen() {
Inventory inventory = this.controller.getOpenInventory();
if (inventory == null) {
Expand Down
Expand Up @@ -53,7 +53,8 @@ public InventoryOpenEventInjector(EventBus eventBus, InventoryController control
@Type(typeName = "net.minecraft.inventory.container.ContainerType"),
@Type(typeName = "net.minecraft.client.Minecraft"),
@Type(reference = int.class)
})
},
version = "1.15.2")
public void createScreen() {
InventoryOpenEvent event = this.eventFactory.create(this.controller.getOpenInventory());
this.eventBus.fireEvent(event, Subscribe.Phase.POST);
Expand Down
Expand Up @@ -23,6 +23,7 @@
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import net.flintmc.framework.eventbus.EventBus;
import net.flintmc.framework.eventbus.event.subscribe.PreSubscribe;
import net.flintmc.framework.eventbus.event.subscribe.Subscribe;
import net.flintmc.framework.eventbus.event.subscribe.Subscribe.Phase;
import net.flintmc.framework.stereotype.type.Type;
Expand Down Expand Up @@ -69,7 +70,7 @@ public InventoryUpdateSlotEventInjector(
this.airStack = registry.getAirType().createStack();
}

@Subscribe(version = "1.15.2")
@PreSubscribe(version = "1.15.2")
public void injectUpdatingItemLists(TickEvent event) {
ClientPlayerEntity player = Minecraft.getInstance().player;
if (player != null) {
Expand Down
Expand Up @@ -24,6 +24,7 @@
import com.mojang.authlib.GameProfile;
import java.util.UUID;
import net.flintmc.framework.eventbus.EventBus;
import net.flintmc.framework.eventbus.event.subscribe.PreSubscribe;
import net.flintmc.framework.eventbus.event.subscribe.Subscribe;
import net.flintmc.mcapi.player.event.PlayerInfoEvent;
import net.flintmc.mcapi.player.network.NetworkPlayerInfo;
Expand Down Expand Up @@ -55,7 +56,7 @@ private VersionedPlayerInfoInterceptor(
this.gameProfileSerializer = gameProfileSerializer;
}

@Subscribe
@PreSubscribe
public void handlePlayerList(PacketEvent packetEvent) {
if (!(packetEvent.getPacket() instanceof SPlayerListItemPacket)) {
return;
Expand Down
Expand Up @@ -36,7 +36,7 @@ public class VersionedAbstractClientPlayerTransformer {
private static final String FOV_MODIFIER_CLASS = FieldOfViewModifier.class.getName();
private static final int LOCAL_FOV = 1;

@ClassTransform("net.minecraft.client.entity.player.AbstractClientPlayerEntity")
@ClassTransform(value = "net.minecraft.client.entity.player.AbstractClientPlayerEntity", version = "1.15.2")
public void transform(ClassTransformContext context) throws NotFoundException, BadBytecode {
CtMethod fovModifierMethod = context.getDeclaredMethod("getFovModifier");

Expand Down
Expand Up @@ -42,7 +42,7 @@ private VersionedResourcePackReloadEventBroadCaster(
this.resourcePackReloadEvent = resourcePackReloadEvent;
}

@Subscribe(phase = Subscribe.Phase.POST)
@Subscribe(phase = Subscribe.Phase.POST, version = "1.15.2")
public void init(OpenGLInitializeEvent event) {
// Install a hook on the minecraft resource manager
((SimpleReloadableResourceManager) Minecraft.getInstance().getResourceManager())
Expand Down
Expand Up @@ -61,7 +61,8 @@ public ServerKickEventInjector(
executionTime = Hook.ExecutionTime.BEFORE,
className = "net.minecraft.client.network.play.ClientPlayNetHandler",
methodName = "onDisconnect",
parameters = @Type(reference = ITextComponent.class))
parameters = @Type(reference = ITextComponent.class),
version = "1.15.2")
public void handleKick(@Named("args") Object[] args) {
ConnectedServer server = this.controller.getConnectedServer();

Expand Down
Expand Up @@ -22,8 +22,6 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import net.flintmc.framework.eventbus.EventBus;
import net.flintmc.framework.stereotype.type.Type;
import net.flintmc.mcapi.server.ServerAddress;
Expand All @@ -32,6 +30,9 @@
import net.minecraft.client.network.login.ClientLoginNetHandler;
import net.minecraft.network.login.server.SLoginSuccessPacket;

import java.net.InetSocketAddress;
import java.net.SocketAddress;

@Singleton
public class ServerLoginSuccessEventInjector {

Expand All @@ -53,7 +54,8 @@ public ServerLoginSuccessEventInjector(
executionTime = {Hook.ExecutionTime.BEFORE, Hook.ExecutionTime.AFTER},
className = "net.minecraft.client.network.login.ClientLoginNetHandler",
methodName = "handleLoginSuccess",
parameters = @Type(reference = SLoginSuccessPacket.class))
parameters = @Type(reference = SLoginSuccessPacket.class),
version = "1.15.2")
public void handleLoginSuccess(
@Named("instance") Object instance, Hook.ExecutionTime executionTime) {
ClientLoginNetHandler handler = (ClientLoginNetHandler) instance;
Expand Down
Expand Up @@ -63,7 +63,7 @@ private CustomPayloadInterceptor(
this.fieldBuilderFactory = fieldBuilderFactory;
}

@ClassTransform("net.minecraft.client.network.play.ClientPlayNetHandler")
@ClassTransform(value = "net.minecraft.client.network.play.ClientPlayNetHandler", version = "1.15.2")
public void transform(ClassTransformContext context)
throws NotFoundException, BadBytecode, CannotCompileException {

Expand Down
Expand Up @@ -47,7 +47,8 @@ private VersionedWorldInterceptor(World world, TileEntityMapper tileEntityMapper
@Hook(
className = "net.minecraft.world.World",
methodName = "addTileEntity",
parameters = {@Type(reference = net.minecraft.tileentity.TileEntity.class)})
parameters = {@Type(reference = net.minecraft.tileentity.TileEntity.class)},
version = "1.15.2")
public void hookAfterAddTileEntity(@Named("args") Object[] args) {
net.minecraft.tileentity.TileEntity minecraftTileEntity =
(net.minecraft.tileentity.TileEntity) args[0];
Expand All @@ -66,7 +67,8 @@ public void hookAfterAddTileEntity(@Named("args") Object[] args) {
@Hook(
className = "net.minecraft.world.World",
methodName = "removeTileEntity",
parameters = {@Type(reference = BlockPos.class)})
parameters = {@Type(reference = BlockPos.class)},
version = "1.15.2")
public void hookAfterRemoveTileEntity(@Named("args") Object[] args) {
BlockPos blockPos = (BlockPos) args[0];
TileEntity tileEntity = this.world.getTileEntity(this.world.fromMinecraftBlockPos(blockPos));
Expand Down
Expand Up @@ -22,7 +22,7 @@
import net.flintmc.transform.shadow.FieldGetter;
import net.flintmc.transform.shadow.Shadow;

@Shadow("net.minecraft.world.storage.WorldSummary")
@Shadow(value = "net.minecraft.world.storage.WorldSummary", version = "1.15.2")
public interface WorldSummaryShadow {

@FieldGetter("versionName")
Expand Down
Expand Up @@ -61,7 +61,7 @@ private ChatEventInjector(
this.receiveFactory = receiveFactory;
}

@ClassTransform("net.minecraft.client.gui.NewChatGui")
@ClassTransform(value = "net.minecraft.client.gui.NewChatGui", version = "1.16.4")
public void transformChatGui(ClassTransformContext context)
throws NotFoundException, CannotCompileException {
CtClass transforming = context.getCtClass();
Expand Down Expand Up @@ -92,7 +92,7 @@ public ITextComponent handleChatReceive(ITextComponent component, Subscribe.Phas
return (ITextComponent) this.componentMapper.toMinecraft(event.getMessage());
}

@ClassTransform("net.minecraft.client.entity.player.ClientPlayerEntity")
@ClassTransform(value = "net.minecraft.client.entity.player.ClientPlayerEntity", version = "1.16.4")
public void transformClientPlayerEntity(ClassTransformContext context)
throws CannotCompileException, NotFoundException {
CtClass transforming = context.getCtClass();
Expand Down
Expand Up @@ -59,7 +59,8 @@ private VersionedEntityAttackEventInjector(
parameters = {
@Type(typeName = "net.minecraft.entity.player.PlayerEntity"),
@Type(typeName = "net.minecraft.entity.Entity")
})
},
version = "1.16.4")
public void attackEntity(@Named("args") Object[] args) {
Entity entity = this.entityMapper.fromAnyMinecraftEntity(args[1]);
if (entity == null) {
Expand All @@ -77,7 +78,8 @@ public void attackEntity(@Named("args") Object[] args) {
@Type(typeName = "net.minecraft.entity.player.PlayerEntity"),
@Type(typeName = "net.minecraft.entity.Entity"),
@Type(reference = Hand.class)
})
},
version = "1.16.4")
public void interactWithEntity(@Named("args") Object[] args) {
Entity entity = this.entityMapper.fromAnyMinecraftEntity(args[1]);
if (entity == null) {
Expand Down
Expand Up @@ -76,7 +76,7 @@ private VersionedEntityRenderNameEventInjectorTransformer(
this.mappingProvider = mappingProvider;
}

@ClassTransform("net.minecraft.client.renderer.entity.EntityRenderer")
@ClassTransform(value = "net.minecraft.client.renderer.entity.EntityRenderer", version = "1.16.4")
public void transformRenderName(ClassTransformContext context)
throws NotFoundException, CannotCompileException, BadBytecode {
CtClass[] params =
Expand Down
Expand Up @@ -31,7 +31,7 @@
import net.flintmc.mcapi.world.World;
import net.minecraft.nbt.CompoundNBT;

@Implement(value = ArrowEntity.class, version = "1.15.2")
@Implement(value = ArrowEntity.class, version = "1.16.4")
public class VersionedArrowEntity extends VersionedArrowBaseEntity implements ArrowEntity {

private final net.minecraft.entity.projectile.ArrowEntity arrowEntity;
Expand Down
Expand Up @@ -29,7 +29,7 @@
* 1.15.2 implementation of the {@link AgeableEntity.Provider}.
*/
@Singleton
@Implement(value = AgeableEntity.Provider.class, version = "1.15.2")
@Implement(value = AgeableEntity.Provider.class, version = "1.16.4")
public class VersionedAgeableEntityProvider implements AgeableEntity.Provider {

private final AgeableEntity.Factory ageableEntityFactory;
Expand Down
Expand Up @@ -29,7 +29,7 @@
* 1.15.2 implementation of the {@link CreatureEntity.Provider}.
*/
@Singleton
@Implement(value = CreatureEntity.Provider.class, version = "1.15.2")
@Implement(value = CreatureEntity.Provider.class, version = "1.16.4")
public class VersionedCreatureEntityProvider implements CreatureEntity.Provider {

private final CreatureEntity.Factory creatureEntityFactory;
Expand Down
Expand Up @@ -30,7 +30,7 @@
/**
* 1.15.2 implementation of the {@link EntityTypeBuilder}.
*/
@Implement(value = EntityTypeBuilder.class, version = "1.15.2")
@Implement(value = EntityTypeBuilder.class, version = "1.16.4")
public class VersionedEntityTypeBuilder implements EntityTypeBuilder {

private final Entity.Classification classification;
Expand Down
Expand Up @@ -45,7 +45,8 @@ public VersionedMinecraftInitializeEventInjector(EventBus eventBus) {
className = "net.minecraft.client.Minecraft",
methodName = "<init>",
parameters = {@Type(reference = GameConfiguration.class)},
executionTime = {Hook.ExecutionTime.BEFORE, Hook.ExecutionTime.AFTER})
executionTime = {Hook.ExecutionTime.BEFORE, Hook.ExecutionTime.AFTER},
version = "1.16.4")
public void minecraftInitialize(Hook.ExecutionTime executionTime) {
this.eventBus.fireEvent(this.event, executionTime);
}
Expand Down
Expand Up @@ -66,7 +66,8 @@ private InventoryClickEventInjector(
@Type(reference = ClickType.class),
@Type(reference = PlayerEntity.class)
},
defaultValue = "net.minecraft.item.ItemStack.EMPTY")
defaultValue = "net.minecraft.item.ItemStack.EMPTY",
version = "1.16.4")
public HookResult slotClick(
@Named("instance") Object instance,
@Named("args") Object[] args,
Expand Down
Expand Up @@ -46,7 +46,7 @@ public InventoryCloseEventInjector(
this.controller = controller;
}

@Subscribe(phase = Subscribe.Phase.ANY)
@Subscribe(phase = Subscribe.Phase.ANY, version = "1.16.4")
public void fireServerClose(PacketEvent event, Subscribe.Phase phase) {
if (event.getDirection() != Direction.RECEIVE
|| !(event.getPacket() instanceof AccessibleSCloseWindowPacket)) {
Expand Down
Expand Up @@ -49,7 +49,8 @@ private InventoryHeldItemChangeEventInjector(
@Hook(
className = "net.minecraft.client.multiplayer.PlayerController",
methodName = "syncCurrentPlayItem",
executionTime = ExecutionTime.BEFORE)
executionTime = ExecutionTime.BEFORE,
version = "1.16.4")
public HookResult fireHeldItemChangeEvent(
@Named("instance") Object instance, ExecutionTime executionTime) {
int knownSlot = ((AccessiblePlayerController) instance).getCurrentPlayerItem();
Expand Down
Expand Up @@ -53,7 +53,8 @@ public InventoryOpenEventInjector(EventBus eventBus, InventoryController control
@Type(typeName = "net.minecraft.inventory.container.ContainerType"),
@Type(typeName = "net.minecraft.client.Minecraft"),
@Type(reference = int.class)
})
},
version = "1.16.4")
public void createScreen() {
InventoryOpenEvent event = this.eventFactory.create(this.controller.getOpenInventory());
this.eventBus.fireEvent(event, Subscribe.Phase.POST);
Expand All @@ -64,7 +65,7 @@ public void createScreen() {
methodName = "displayGuiScreen",
parameters = @Type(typeName = "net.minecraft.client.gui.screen.Screen"),
executionTime = Hook.ExecutionTime.AFTER,
version = "1.15.2")
version = "1.16.4")
public void displayGuiScreen(@Named("args") Object[] args) {
if (!(args[0] instanceof InventoryScreen)) {
return;
Expand Down

0 comments on commit f70dd68

Please sign in to comment.