From de3bc706bd7fdef62a46d3fa567a9d822eb8e87b Mon Sep 17 00:00:00 2001 From: Aleksey Date: Wed, 14 Apr 2021 09:31:07 +0300 Subject: [PATCH] Continue migration --- .../java/ru/betterend/effects/EndPotions.java | 6 ++--- .../java/ru/betterend/item/EndArmorItem.java | 6 ++--- .../mixin/common/AbstractBlockMixin.java | 2 +- .../mixin/common/AnvilBlockMixin.java | 4 +-- .../mixin/common/AnvilScreenHandlerMixin.java | 10 +++---- .../mixin/common/ArmorItemAccessor.java | 12 ++++----- .../mixin/common/BiomeArrayMixin.java | 18 ++++++------- .../mixin/common/BoneMealItemMixin.java | 26 +++++++++---------- .../mixin/common/BrewingAccessor.java | 2 +- .../mixin/common/ChorusFlowerBlockMixin.java | 20 +++++++------- .../mixin/common/TagGroupLoaderMixin.java | 6 ++--- 11 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/main/java/ru/betterend/effects/EndPotions.java b/src/main/java/ru/betterend/effects/EndPotions.java index e0a91270..86ab156b 100644 --- a/src/main/java/ru/betterend/effects/EndPotions.java +++ b/src/main/java/ru/betterend/effects/EndPotions.java @@ -24,8 +24,8 @@ public class EndPotions { } public static void register() { - BrewingAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EndItems.ENDER_DUST, END_VEIL); - BrewingAccessor.callRegisterPotionRecipe(END_VEIL, Items.REDSTONE, LONG_END_VEIL); - BrewingAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EndBlocks.MURKWEED.asItem(), Potions.NIGHT_VISION); + BrewingAccessor.callAddMix(Potions.AWKWARD, EndItems.ENDER_DUST, END_VEIL); + BrewingAccessor.callAddMix(END_VEIL, Items.REDSTONE, LONG_END_VEIL); + BrewingAccessor.callAddMix(Potions.AWKWARD, EndBlocks.MURKWEED.asItem(), Potions.NIGHT_VISION); } } diff --git a/src/main/java/ru/betterend/item/EndArmorItem.java b/src/main/java/ru/betterend/item/EndArmorItem.java index 4c98eb68..0f04de3e 100644 --- a/src/main/java/ru/betterend/item/EndArmorItem.java +++ b/src/main/java/ru/betterend/item/EndArmorItem.java @@ -27,20 +27,20 @@ public class EndArmorItem extends ArmorItem implements Patterned { return; } - Multimap attributeModifiers = accessor.be_getAttributeModifiers(); + Multimap attributeModifiers = accessor.getDefaultModifiers(); // In case Mojang or anyone else decided to fix this if (attributeModifiers.keys().contains(Attributes.KNOCKBACK_RESISTANCE)) { return; } - UUID uuid = accessor.be_getModifiers()[slot.getIndex()]; + UUID uuid = accessor.getModifiers()[slot.getIndex()]; // Rebuild attributeModifiers to include knockback resistance ImmutableMultimap.Builder builder = ImmutableMultimap.builder(); builder.putAll(attributeModifiers); builder.put(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(uuid, "Armor knockback resistance", knockbackResistance, AttributeModifier.Operation.ADDITION)); - accessor.be_setAttributeModifiers(builder.build()); + accessor.setDefaultModifiers(builder.build()); } @Override diff --git a/src/main/java/ru/betterend/mixin/common/AbstractBlockMixin.java b/src/main/java/ru/betterend/mixin/common/AbstractBlockMixin.java index c7f32c8d..369f0a72 100644 --- a/src/main/java/ru/betterend/mixin/common/AbstractBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/AbstractBlockMixin.java @@ -23,7 +23,7 @@ import ru.betterend.util.MHelper; @Mixin(BlockBehaviour.class) public abstract class AbstractBlockMixin { - @Inject(method = "getDroppedStacks", at = @At("HEAD"), cancellable = true) + @Inject(method = "getDrops", at = @At("HEAD"), cancellable = true) public void be_getDroppedStacks(BlockState state, LootContext.Builder builder, CallbackInfoReturnable> info) { if (state.is(Blocks.GLOWSTONE)) { ItemStack tool = builder.getParameter(LootContextParams.TOOL); diff --git a/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java b/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java index 19b4f081..46d69ce5 100644 --- a/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java @@ -11,8 +11,8 @@ import ru.betterend.blocks.basis.EndAnvilBlock; @Mixin(AnvilBlock.class) public class AnvilBlockMixin { - @Inject(method = "getLandingState", at = @At("HEAD"), cancellable = true) - private static void be_getLandingState(BlockState fallingState, CallbackInfoReturnable info) { + @Inject(method = "damage", at = @At("HEAD"), cancellable = true) + private static void be_damage(BlockState fallingState, CallbackInfoReturnable info) { if (fallingState.getBlock() instanceof EndAnvilBlock) { IntegerProperty destructionProperty = ((EndAnvilBlock) fallingState.getBlock()).getDestructionProperty(); int destruction = fallingState.getValue(destructionProperty); diff --git a/src/main/java/ru/betterend/mixin/common/AnvilScreenHandlerMixin.java b/src/main/java/ru/betterend/mixin/common/AnvilScreenHandlerMixin.java index 28ad1cf7..5df5f766 100644 --- a/src/main/java/ru/betterend/mixin/common/AnvilScreenHandlerMixin.java +++ b/src/main/java/ru/betterend/mixin/common/AnvilScreenHandlerMixin.java @@ -37,7 +37,7 @@ public abstract class AnvilScreenHandlerMixin extends ItemCombinerMenu implement super(MenuType.ANVIL, syncId, playerInventory, ContainerLevelAccess.NULL); } - @Inject(method = "(ILnet/minecraft/entity/player/PlayerInventory;Lnet/minecraft/screen/ScreenHandlerContext;)V", + @Inject(method = "(ILnet/minecraft/world/entity/player/Inventory;Lnet/minecraft/world/inventory/ContainerLevelAccess;)V", at = @At("TAIL")) public void be_initAnvilLevel(int syncId, Inventory inventory, ContainerLevelAccess context, CallbackInfo info) { if (context != ContainerLevelAccess.NULL) { @@ -57,14 +57,14 @@ public abstract class AnvilScreenHandlerMixin extends ItemCombinerMenu implement @Shadow public abstract void createResult(); - @Inject(method = "canTakeOutput", at = @At("HEAD"), cancellable = true) + @Inject(method = "mayPickup", at = @At("HEAD"), cancellable = true) protected void be_canTakeOutput(Player player, boolean present, CallbackInfoReturnable info) { if (be_currentRecipe != null) { info.setReturnValue(be_currentRecipe.checkHammerDurability(inputSlots, player)); } } - @Inject(method = "onTakeOutput", at = @At("HEAD"), cancellable = true) + @Inject(method = "onTake", at = @At("HEAD"), cancellable = true) protected void be_onTakeOutput(Player player, ItemStack stack, CallbackInfoReturnable info) { if (be_currentRecipe != null) { this.inputSlots.getItem(0).shrink(be_currentRecipe.getInputCount()); @@ -89,7 +89,7 @@ public abstract class AnvilScreenHandlerMixin extends ItemCombinerMenu implement } } - @Inject(method = "updateResult", at = @At("HEAD"), cancellable = true) + @Inject(method = "createResult", at = @At("HEAD"), cancellable = true) public void be_updateOutput(CallbackInfo info) { RecipeManager recipeManager = this.player.level.getRecipeManager(); be_recipes = recipeManager.getRecipesFor(AnvilRecipe.TYPE, inputSlots, player.level); @@ -109,7 +109,7 @@ public abstract class AnvilScreenHandlerMixin extends ItemCombinerMenu implement } } - @Inject(method = "setNewItemName", at = @At("HEAD"), cancellable = true) + @Inject(method = "setItemName", at = @At("HEAD"), cancellable = true) public void be_setNewItemName(String string, CallbackInfo info) { if (be_currentRecipe != null) { info.cancel(); diff --git a/src/main/java/ru/betterend/mixin/common/ArmorItemAccessor.java b/src/main/java/ru/betterend/mixin/common/ArmorItemAccessor.java index ce903a6e..f91eed33 100644 --- a/src/main/java/ru/betterend/mixin/common/ArmorItemAccessor.java +++ b/src/main/java/ru/betterend/mixin/common/ArmorItemAccessor.java @@ -11,12 +11,12 @@ import com.google.common.collect.Multimap; @Mixin(ArmorItem.class) public interface ArmorItemAccessor { - @Accessor("MODIFIERS") - UUID[] be_getModifiers(); + @Accessor("ARMOR_MODIFIER_UUID_PER_SLOT") + UUID[] getModifiers(); - @Accessor("attributeModifiers") - Multimap be_getAttributeModifiers(); + @Accessor("defaultModifiers") + Multimap getDefaultModifiers(); - @Accessor("attributeModifiers") - void be_setAttributeModifiers(Multimap attributeModifiers); + @Accessor("defaultModifiers") + void setDefaultModifiers(Multimap attributeModifiers); } diff --git a/src/main/java/ru/betterend/mixin/common/BiomeArrayMixin.java b/src/main/java/ru/betterend/mixin/common/BiomeArrayMixin.java index 13da34e7..7ee5b484 100644 --- a/src/main/java/ru/betterend/mixin/common/BiomeArrayMixin.java +++ b/src/main/java/ru/betterend/mixin/common/BiomeArrayMixin.java @@ -13,19 +13,19 @@ import ru.betterend.interfaces.IBiomeArray; public class BiomeArrayMixin implements IBiomeArray { @Final @Shadow - private Biome[] data; + private Biome[] biomes; @Final @Shadow - private static int HORIZONTAL_SECTION_COUNT; + private static int WIDTH_BITS; @Final @Shadow - public static int HORIZONTAL_BIT_MASK; + public static int HORIZONTAL_MASK; @Final @Shadow - public static int VERTICAL_BIT_MASK; + public static int VERTICAL_MASK; @Override public void setBiome(Biome biome, BlockPos pos) { @@ -33,13 +33,13 @@ public class BiomeArrayMixin implements IBiomeArray { int biomeY = pos.getY() >> 2; int biomeZ = pos.getZ() >> 2; int index = be_getArrayIndex(biomeX, biomeY, biomeZ); - data[index] = biome; + biomes[index] = biome; } private int be_getArrayIndex(int biomeX, int biomeY, int biomeZ) { - int i = biomeX & HORIZONTAL_BIT_MASK; - int j = Mth.clamp(biomeY, 0, VERTICAL_BIT_MASK); - int k = biomeZ & HORIZONTAL_BIT_MASK; - return j << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT | k << HORIZONTAL_SECTION_COUNT | i; + int i = biomeX & HORIZONTAL_MASK; + int j = Mth.clamp(biomeY, 0, VERTICAL_MASK); + int k = biomeZ & HORIZONTAL_MASK; + return j << WIDTH_BITS + WIDTH_BITS | k << WIDTH_BITS | i; } } diff --git a/src/main/java/ru/betterend/mixin/common/BoneMealItemMixin.java b/src/main/java/ru/betterend/mixin/common/BoneMealItemMixin.java index aaf77045..29bd14f5 100644 --- a/src/main/java/ru/betterend/mixin/common/BoneMealItemMixin.java +++ b/src/main/java/ru/betterend/mixin/common/BoneMealItemMixin.java @@ -28,7 +28,7 @@ public class BoneMealItemMixin { private static final Direction[] DIR = BlocksHelper.makeHorizontal(); private static final MutableBlockPos POS = new MutableBlockPos(); - @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true) + @Inject(method = "useOn", at = @At("HEAD"), cancellable = true) private void be_onUse(UseOnContext context, CallbackInfoReturnable info) { Level world = context.getLevel(); BlockPos blockPos = context.getClickedPos(); @@ -39,7 +39,7 @@ public class BoneMealItemMixin { if (world.getBlockState(blockPos).is(EndTags.END_GROUND)) { boolean consume = false; if (world.getBlockState(blockPos).is(Blocks.END_STONE)) { - BlockState nylium = beGetNylium(world, blockPos); + BlockState nylium = be_getNylium(world, blockPos); if (nylium != null) { BlocksHelper.setWithoutUpdate(world, blockPos, nylium); consume = true; @@ -48,11 +48,11 @@ public class BoneMealItemMixin { else { if (!world.getFluidState(offseted).isEmpty() && endBiome) { if (world.getBlockState(offseted).getBlock().equals(Blocks.WATER)) { - consume = beGrowWaterGrass(world, blockPos); + consume = be_growWaterGrass(world, blockPos); } } else { - consume = beGrowGrass(world, blockPos); + consume = be_growGrass(world, blockPos); } } if (consume) { @@ -73,7 +73,7 @@ public class BoneMealItemMixin { } } - private boolean beGrowGrass(Level world, BlockPos pos) { + private boolean be_growGrass(Level world, BlockPos pos) { int y1 = pos.getY() + 3; int y2 = pos.getY() - 3; boolean result = false; @@ -86,7 +86,7 @@ public class BoneMealItemMixin { POS.setY(y); BlockPos down = POS.below(); if (world.isEmptyBlock(POS) && !world.isEmptyBlock(down)) { - BlockState grass = beGetGrassState(world, down); + BlockState grass = be_getGrassState(world, down); if (grass != null) { BlocksHelper.setWithoutUpdate(world, POS, grass); result = true; @@ -98,7 +98,7 @@ public class BoneMealItemMixin { return result; } - private boolean beGrowWaterGrass(Level world, BlockPos pos) { + private boolean be_growWaterGrass(Level world, BlockPos pos) { int y1 = pos.getY() + 3; int y2 = pos.getY() - 3; boolean result = false; @@ -111,7 +111,7 @@ public class BoneMealItemMixin { POS.setY(y); BlockPos down = POS.below(); if (world.getBlockState(POS).is(Blocks.WATER) && world.getBlockState(down).is(EndTags.END_GROUND)) { - BlockState grass = beGetWaterGrassState(world, down); + BlockState grass = be_getWaterGrassState(world, down); if (grass != null) { BlocksHelper.setWithoutUpdate(world, POS, grass); result = true; @@ -123,14 +123,14 @@ public class BoneMealItemMixin { return result; } - private BlockState beGetGrassState(Level world, BlockPos pos) { + private BlockState be_getGrassState(Level world, BlockPos pos) { BlockState state = world.getBlockState(pos); Block block = state.getBlock(); block = BonemealUtil.getGrass(EndBiomes.getBiomeID(world.getBiome(pos)), block, world.getRandom()); return block == null ? null : block.defaultBlockState(); } - private BlockState beGetWaterGrassState(Level world, BlockPos pos) { + private BlockState be_getWaterGrassState(Level world, BlockPos pos) { EndBiome biome = EndBiomes.getFromBiome(world.getBiome(pos)); if (world.random.nextInt(16) == 0) { return EndBlocks.CHARNIA_RED.defaultBlockState(); @@ -147,7 +147,7 @@ public class BoneMealItemMixin { return null; } - private void beShuffle(Random random) { + private void be_shuffle(Random random) { for (int i = 0; i < 4; i++) { int j = random.nextInt(4); Direction d = DIR[i]; @@ -156,8 +156,8 @@ public class BoneMealItemMixin { } } - private BlockState beGetNylium(Level world, BlockPos pos) { - beShuffle(world.random); + private BlockState be_getNylium(Level world, BlockPos pos) { + be_shuffle(world.random); for (Direction dir : DIR) { BlockState state = world.getBlockState(pos.relative(dir)); if (BlocksHelper.isEndNylium(state)) diff --git a/src/main/java/ru/betterend/mixin/common/BrewingAccessor.java b/src/main/java/ru/betterend/mixin/common/BrewingAccessor.java index 0093c018..f1987282 100644 --- a/src/main/java/ru/betterend/mixin/common/BrewingAccessor.java +++ b/src/main/java/ru/betterend/mixin/common/BrewingAccessor.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(PotionBrewing.class) public interface BrewingAccessor { @Invoker - static void callRegisterPotionRecipe(Potion input, Item item, Potion output) { + static void callAddMix(Potion input, Item item, Potion output) { throw new AssertionError("@Invoker dummy body called"); } } diff --git a/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java index 570963f9..87a40f52 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java @@ -42,8 +42,8 @@ public abstract class ChorusFlowerBlockMixin extends Block { @Final private ChorusPlantBlock plantBlock; - @Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true) - private void beCanPlace(BlockState state, LevelReader world, BlockPos pos, CallbackInfoReturnable info) { + @Inject(method = "canSurvive", at = @At("HEAD"), cancellable = true) + private void be_canPlace(BlockState state, LevelReader world, BlockPos pos, CallbackInfoReturnable info) { if (world.getBlockState(pos.below()).is(EndBlocks.CHORUS_NYLIUM)) { info.setReturnValue(true); info.cancel(); @@ -51,13 +51,13 @@ public abstract class ChorusFlowerBlockMixin extends Block { } @Inject(method = "randomTick", at = @At("HEAD"), cancellable = true) - private void beOnTick(BlockState state, ServerLevel world, BlockPos pos, Random random, CallbackInfo info) { + private void be_onTick(BlockState state, ServerLevel world, BlockPos pos, Random random, CallbackInfo info) { if (world.getBlockState(pos.below()).is(EndTags.END_GROUND)) { BlockPos up = pos.above(); if (world.isEmptyBlock(up) && up.getY() < 256) { int i = state.getValue(ChorusFlowerBlock.AGE); if (i < 5) { - this.grow(world, up, i + 1); + this.placeGrownFlower(world, up, i + 1); if (GeneratorOptions.changeChorusPlant()) { BlocksHelper.setWithoutUpdate(world, pos, plantBlock.defaultBlockState().setValue(ChorusPlantBlock.UP, true).setValue(ChorusPlantBlock.DOWN, true).setValue(BlocksHelper.ROOTS, true)); } @@ -70,8 +70,8 @@ public abstract class ChorusFlowerBlockMixin extends Block { } } - @Inject(method = "generate", at = @At("RETURN"), cancellable = true) - private static void beOnGenerate(LevelAccessor world, BlockPos pos, Random random, int size, CallbackInfo info) { + @Inject(method = "generatePlant", at = @At("RETURN"), cancellable = true) + private static void be_onGeneratePlant(LevelAccessor world, BlockPos pos, Random random, int size, CallbackInfo info) { BlockState state = world.getBlockState(pos); if (GeneratorOptions.changeChorusPlant() && state.is(Blocks.CHORUS_PLANT)) { BlocksHelper.setWithoutUpdate(world, pos, state.setValue(BlocksHelper.ROOTS, true)); @@ -79,13 +79,13 @@ public abstract class ChorusFlowerBlockMixin extends Block { } @Shadow - private static boolean isSurroundedByAir(LevelReader world, BlockPos pos, @Nullable Direction exceptDirection) { return false; } + private static boolean allNeighborsEmpty(LevelReader world, BlockPos pos, @Nullable Direction exceptDirection) { return false; } @Shadow - private void grow(Level world, BlockPos pos, int age) {} + private void placeGrownFlower(Level world, BlockPos pos, int age) {} @Shadow - private void die(Level world, BlockPos pos) {} + private void placeDeadFlower(Level world, BlockPos pos) {} @Override public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { @@ -98,7 +98,7 @@ public abstract class ChorusFlowerBlockMixin extends Block { } @Inject(method = "die", at = @At("HEAD"), cancellable = true) - private void beOnDie(Level world, BlockPos pos, CallbackInfo info) { + private void be_onDie(Level world, BlockPos pos, CallbackInfo info) { BlockState down = world.getBlockState(pos.below()); if (down.is(Blocks.CHORUS_PLANT) || down.is(EndTags.GEN_TERRAIN)) { world.setBlock(pos, this.defaultBlockState().setValue(BlockStateProperties.AGE_5, 5), 2); diff --git a/src/main/java/ru/betterend/mixin/common/TagGroupLoaderMixin.java b/src/main/java/ru/betterend/mixin/common/TagGroupLoaderMixin.java index 825d68be..bb201c67 100644 --- a/src/main/java/ru/betterend/mixin/common/TagGroupLoaderMixin.java +++ b/src/main/java/ru/betterend/mixin/common/TagGroupLoaderMixin.java @@ -20,13 +20,13 @@ public class TagGroupLoaderMixin { @Shadow private String entryType; - @Inject(method = "prepareReload", at = @At("RETURN"), cancellable = true) - public void be_prepareReload(ResourceManager manager, Executor prepareExecutor, CallbackInfoReturnable>> info) { + @Inject(method = "prepare", at = @At("RETURN"), cancellable = true) + public void be_prepareReload(ResourceManager manager, Executor executor, CallbackInfoReturnable>> info) { CompletableFuture> future = info.getReturnValue(); info.setReturnValue(CompletableFuture.supplyAsync(() -> { Map map = future.join(); TagHelper.apply(entryType, map); return map; - })); + }, executor)); } }