Server mixins update

This commit is contained in:
paulevsGitch 2021-04-15 01:16:53 +03:00
parent de3bc706bd
commit 2a8853d615
42 changed files with 302 additions and 316 deletions

View file

@ -95,7 +95,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
teleportPlayer(player, destination, exitPos);
} else {
TeleportingEntity teleEntity = (TeleportingEntity) entity;
teleEntity.beSetExitPos(exitPos);
teleEntity.be_setExitPos(exitPos);
Entity teleported = entity.changeDimension(destination);
if (teleported != null) {
teleported.setPortalCooldown();
@ -113,7 +113,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
player.teleportTo(destination, exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5, player.yRot, player.xRot);
} else {
TeleportingEntity teleEntity = (TeleportingEntity) player;
teleEntity.beSetExitPos(exitPos);
teleEntity.be_setExitPos(exitPos);
player.changeDimension(destination);
}
}

View file

@ -7,7 +7,7 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.Potions;
import ru.betterend.BetterEnd;
import ru.betterend.mixin.common.BrewingAccessor;
import ru.betterend.mixin.common.PotionBrewingAccessor;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
@ -24,8 +24,8 @@ public class EndPotions {
}
public static void register() {
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);
PotionBrewingAccessor.callAddMix(Potions.AWKWARD, EndItems.ENDER_DUST, END_VEIL);
PotionBrewingAccessor.callAddMix(END_VEIL, Items.REDSTONE, LONG_END_VEIL);
PotionBrewingAccessor.callAddMix(Potions.AWKWARD, EndBlocks.MURKWEED.asItem(), Potions.NIGHT_VISION);
}
}

View file

@ -141,7 +141,7 @@ public class EndSlimeEntity extends Slime {
slimeEntity.setCustomName(text);
slimeEntity.setNoAi(bl);
slimeEntity.setInvulnerable(this.isInvulnerable());
((ISlime) slimeEntity).beSetSlimeSize(j, true);
((ISlime) slimeEntity).be_setSlimeSize(j, true);
slimeEntity.refreshDimensions();
slimeEntity.moveTo(this.getX() + (double) g, this.getY() + 0.5D, this.getZ() + (double) h, this.random.nextFloat() * 360.0F, 0.0F);
this.level.addFreshEntity(slimeEntity);

View file

@ -4,5 +4,5 @@ import net.minecraft.core.BlockPos;
import net.minecraft.world.level.biome.Biome;
public interface IBiomeArray {
public void setBiome(Biome biome, BlockPos pos);
public void be_setBiome(Biome biome, BlockPos pos);
}

View file

@ -1,5 +1,5 @@
package ru.betterend.interfaces;
public interface ISlime {
public void beSetSlimeSize(int size, boolean heal);
public void be_setSlimeSize(int size, boolean heal);
}

View file

@ -3,7 +3,7 @@ package ru.betterend.interfaces;
import net.minecraft.core.BlockPos;
public interface TeleportingEntity {
void beSetExitPos(BlockPos pos);
void beResetExitPos();
boolean beCanTeleport();
void be_setExitPos(BlockPos pos);
void be_resetExitPos();
boolean be_canTeleport();
}

View file

@ -27,20 +27,20 @@ public class EndArmorItem extends ArmorItem implements Patterned {
return;
}
Multimap<Attribute, AttributeModifier> attributeModifiers = accessor.getDefaultModifiers();
Multimap<Attribute, AttributeModifier> attributeModifiers = accessor.be_getDefaultModifiers();
// In case Mojang or anyone else decided to fix this
if (attributeModifiers.keys().contains(Attributes.KNOCKBACK_RESISTANCE)) {
return;
}
UUID uuid = accessor.getModifiers()[slot.getIndex()];
UUID uuid = accessor.be_getModifiers()[slot.getIndex()];
// Rebuild attributeModifiers to include knockback resistance
ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
builder.putAll(attributeModifiers);
builder.put(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(uuid, "Armor knockback resistance", knockbackResistance, AttributeModifier.Operation.ADDITION));
accessor.setDefaultModifiers(builder.build());
accessor.be_setDefaultModifiers(builder.build());
}
@Override

View file

@ -27,18 +27,16 @@ import ru.betterend.interfaces.AnvilScreenHandlerExtended;
import ru.betterend.recipe.builders.AnvilRecipe;
@Mixin(AnvilMenu.class)
public abstract class AnvilScreenHandlerMixin extends ItemCombinerMenu implements AnvilScreenHandlerExtended {
public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilScreenHandlerExtended {
private List<AnvilRecipe> be_recipes = Collections.emptyList();
private AnvilRecipe be_currentRecipe;
private DataSlot anvilLevel;
public AnvilScreenHandlerMixin(int syncId, Inventory playerInventory) {
public AnvilMenuMixin(int syncId, Inventory playerInventory) {
super(MenuType.ANVIL, syncId, playerInventory, ContainerLevelAccess.NULL);
}
@Inject(method = "<init>(ILnet/minecraft/world/entity/player/Inventory;Lnet/minecraft/world/inventory/ContainerLevelAccess;)V",
at = @At("TAIL"))
@Inject(method = "<init>(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) {
int anvLevel = context.evaluate((world, blockPos) -> {

View file

@ -12,11 +12,11 @@ import com.google.common.collect.Multimap;
@Mixin(ArmorItem.class)
public interface ArmorItemAccessor {
@Accessor("ARMOR_MODIFIER_UUID_PER_SLOT")
UUID[] getModifiers();
UUID[] be_getModifiers();
@Accessor("defaultModifiers")
Multimap<Attribute, AttributeModifier> getDefaultModifiers();
Multimap<Attribute, AttributeModifier> be_getDefaultModifiers();
@Accessor("defaultModifiers")
void setDefaultModifiers(Multimap<Attribute, AttributeModifier> attributeModifiers);
void be_setDefaultModifiers(Multimap<Attribute, AttributeModifier> attributeModifiers);
}

View file

@ -9,16 +9,16 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(BiomeGenerationSettings.class)
public interface GenerationSettingsAccessor {
public interface BiomeGenerationSettingsAccessor {
@Accessor("features")
List<List<Supplier<ConfiguredFeature<?, ?>>>> beGetFeatures();
List<List<Supplier<ConfiguredFeature<?, ?>>>> be_getFeatures();
@Accessor("features")
void beSetFeatures(List<List<Supplier<ConfiguredFeature<?, ?>>>> features);
void be_setFeatures(List<List<Supplier<ConfiguredFeature<?, ?>>>> features);
@Accessor("structureFeatures")
List<Supplier<ConfiguredStructureFeature<?, ?>>> beGetStructures();
@Accessor("structureStarts")
List<Supplier<ConfiguredStructureFeature<?, ?>>> be_getStructures();
@Accessor("structureFeatures")
void beSetStructures(List<Supplier<ConfiguredStructureFeature<?, ?>>> structures);
@Accessor("structureStarts")
void be_setStructures(List<Supplier<ConfiguredStructureFeature<?, ?>>> structures);
}

View file

@ -21,8 +21,7 @@ import ru.betterend.item.tool.EndHammerItem;
import ru.betterend.util.MHelper;
@Mixin(BlockBehaviour.class)
public abstract class AbstractBlockMixin {
public abstract class BlockBehaviourMixin {
@Inject(method = "getDrops", at = @At("HEAD"), cancellable = true)
public void be_getDroppedStacks(BlockState state, LootContext.Builder builder, CallbackInfoReturnable<List<ItemStack>> info) {
if (state.is(Blocks.GLOWSTONE)) {

View file

@ -43,7 +43,7 @@ public abstract class ChorusFlowerBlockMixin extends Block {
private ChorusPlantBlock plantBlock;
@Inject(method = "canSurvive", at = @At("HEAD"), cancellable = true)
private void be_canPlace(BlockState state, LevelReader world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
private void be_canSurvive(BlockState state, LevelReader world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
if (world.getBlockState(pos.below()).is(EndBlocks.CHORUS_NYLIUM)) {
info.setReturnValue(true);
info.cancel();
@ -51,7 +51,7 @@ public abstract class ChorusFlowerBlockMixin extends Block {
}
@Inject(method = "randomTick", at = @At("HEAD"), cancellable = true)
private void be_onTick(BlockState state, ServerLevel world, BlockPos pos, Random random, CallbackInfo info) {
private void be_randomTick(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) {
@ -71,7 +71,7 @@ public abstract class ChorusFlowerBlockMixin extends Block {
}
@Inject(method = "generatePlant", at = @At("RETURN"), cancellable = true)
private static void be_onGeneratePlant(LevelAccessor world, BlockPos pos, Random random, int size, CallbackInfo info) {
private static void be_generatePlant(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));
@ -97,8 +97,8 @@ public abstract class ChorusFlowerBlockMixin extends Block {
}
}
@Inject(method = "die", at = @At("HEAD"), cancellable = true)
private void be_onDie(Level world, BlockPos pos, CallbackInfo info) {
@Inject(method = "placeDeadFlower", at = @At("HEAD"), cancellable = true)
private void be_placeDeadFlower(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);

View file

@ -37,16 +37,16 @@ public abstract class ChorusPlantBlockMixin extends Block {
}
}
@Inject(method = "appendProperties", at = @At("TAIL"))
private void beAddProperties(StateDefinition.Builder<Block, BlockState> builder, CallbackInfo info) {
@Inject(method = "createBlockStateDefinition", at = @At("TAIL"))
private void be_createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder, CallbackInfo info) {
GeneratorOptions.init();
if (GeneratorOptions.changeChorusPlant()) {
builder.add(BlocksHelper.ROOTS);
}
}
@Inject(method = "withConnectionProperties", at = @At("RETURN"), cancellable = true)
private void beConnectionProperties(BlockGetter world, BlockPos pos, CallbackInfoReturnable<BlockState> info) {
@Inject(method = "getStateForPlacement", at = @At("RETURN"), cancellable = true)
private void be_getStateForPlacement(BlockGetter world, BlockPos pos, CallbackInfoReturnable<BlockState> info) {
BlockState plant = info.getReturnValue();
if (plant.is(Blocks.CHORUS_PLANT)) {
if (world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
@ -67,8 +67,8 @@ public abstract class ChorusPlantBlockMixin extends Block {
}
}
@Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true)
private void beCanPlace(BlockState state, LevelReader world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
@Inject(method = "canSurvive", at = @At("HEAD"), cancellable = true)
private void be_canSurvive(BlockState state, LevelReader world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
BlockState down = world.getBlockState(pos.below());
if (down.is(EndBlocks.CHORUS_NYLIUM) || down.is(Blocks.END_STONE)) {
info.setReturnValue(true);
@ -76,8 +76,8 @@ public abstract class ChorusPlantBlockMixin extends Block {
}
}
@Inject(method = "getStateForNeighborUpdate", at = @At("RETURN"), cancellable = true)
private void beStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom, CallbackInfoReturnable<BlockState> info) {
@Inject(method = "updateShape", at = @At("RETURN"), cancellable = true)
private void be_updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom, CallbackInfoReturnable<BlockState> info) {
BlockState plant = info.getReturnValue();
if (plant.is(Blocks.CHORUS_PLANT)) {
if (world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
@ -100,8 +100,8 @@ public abstract class ChorusPlantBlockMixin extends Block {
}
}
@Inject(method = "getPlacementState", at = @At("RETURN"), cancellable = true)
private void beGetPlacementState(BlockPlaceContext ctx, CallbackInfoReturnable<BlockState> info) {
@Inject(method = "getStateForPlacement", at = @At("RETURN"), cancellable = true)
private void be_getStateForPlacement(BlockPlaceContext ctx, CallbackInfoReturnable<BlockState> info) {
BlockPos pos = ctx.getClickedPos();
Level world = ctx.getLevel();
BlockState plant = info.getReturnValue();

View file

@ -21,8 +21,8 @@ import ru.betterend.world.generator.GeneratorOptions;
@Mixin(ChorusPlantFeature.class)
public class ChorusPlantFeatureMixin {
@Inject(method = "generate", at = @At("HEAD"), cancellable = true)
private void be_onGenerate(WorldGenLevel structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, NoneFeatureConfiguration defaultFeatureConfig, CallbackInfoReturnable<Boolean> info) {
@Inject(method = "place", at = @At("HEAD"), cancellable = true)
private void be_place(WorldGenLevel structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, NoneFeatureConfiguration defaultFeatureConfig, CallbackInfoReturnable<Boolean> info) {
if (structureWorldAccess.isEmptyBlock(blockPos) && structureWorldAccess.getBlockState(blockPos.below()).is(EndBlocks.CHORUS_NYLIUM)) {
ChorusFlowerBlock.generatePlant(structureWorldAccess, blockPos, random, MHelper.randRange(8, 16, random));
BlockState bottom = structureWorldAccess.getBlockState(blockPos);

View file

@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.Shadow;
import ru.betterend.interfaces.IBiomeArray;
@Mixin(ChunkBiomeContainer.class)
public class BiomeArrayMixin implements IBiomeArray {
public class ChunkBiomeContainerMixin implements IBiomeArray {
@Final
@Shadow
private Biome[] biomes;
@ -28,7 +28,7 @@ public class BiomeArrayMixin implements IBiomeArray {
public static int VERTICAL_MASK;
@Override
public void setBiome(Biome biome, BlockPos pos) {
public void be_setBiome(Biome biome, BlockPos pos) {
int biomeX = pos.getX() >> 2;
int biomeY = pos.getY() >> 2;
int biomeZ = pos.getZ() >> 2;

View file

@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(ComposterBlock.class)
public interface ComposterBlockAccessor {
@Invoker
static void callRegisterCompostableItem(float levelIncreaseChance, ItemLike item) {
static void callAdd(float levelIncreaseChance, ItemLike item) {
throw new AssertionError("@Invoker dummy body called");
}
}

View file

@ -12,14 +12,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(CraftingMenu.class)
public abstract class CraftingScreenHandlerMixin
{
public abstract class CraftingMenuMixin {
@Shadow
@Final
private ContainerLevelAccess context;
@Inject(method = "canUse", at = @At("HEAD"), cancellable = true)
private void be_canUse(Player player, CallbackInfoReturnable<Boolean> info) {
@Inject(method = "stillValid", at = @At("HEAD"), cancellable = true)
private void be_stillValid(Player player, CallbackInfoReturnable<Boolean> info) {
if (context.evaluate((world, pos) -> {
return world.getBlockState(pos).getBlock() instanceof CraftingTableBlock;
}, true)) {

View file

@ -15,7 +15,7 @@ import ru.betterend.world.generator.GeneratorOptions;
@Mixin(value = DimensionType.class, priority = 100)
public class DimensionTypeMixin {
@Inject(method = "createEndGenerator", at = @At("HEAD"), cancellable = true)
@Inject(method = "defaultEndGenerator", at = @At("HEAD"), cancellable = true)
private static void be_replaceGenerator(Registry<Biome> biomeRegistry, Registry<NoiseGeneratorSettings> chunkGeneratorSettingsRegistry, long seed, CallbackInfoReturnable<ChunkGenerator> info) {
info.setReturnValue(new NoiseBasedChunkGenerator(new BetterEndBiomeSource(biomeRegistry, seed), seed, () -> {
return (NoiseGeneratorSettings) chunkGeneratorSettingsRegistry.getOrThrow(NoiseGeneratorSettings.END);
@ -23,7 +23,7 @@ public class DimensionTypeMixin {
info.cancel();
}
@Inject(method = "hasEnderDragonFight", at = @At("HEAD"), cancellable = true)
@Inject(method = "createDragonFight", at = @At("HEAD"), cancellable = true)
private void be_hasEnderDragonFight(CallbackInfoReturnable<Boolean> info) {
if (!GeneratorOptions.hasDragonFights()) {
info.setReturnValue(false);

View file

@ -21,14 +21,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.betterend.registry.EndTags;
@Mixin(EnchantmentMenu.class)
public abstract class EnchantmentScreenHandlerMixin extends AbstractContainerMenu {
public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
@Shadow
@Final
private Container inventory;
private Container enchantSlots;
@Shadow
@Final
private ContainerLevelAccess context;
private ContainerLevelAccess access;
@Shadow
@Final
@ -36,30 +36,30 @@ public abstract class EnchantmentScreenHandlerMixin extends AbstractContainerMen
@Shadow
@Final
private DataSlot seed;
private DataSlot enchantmentSeed;
@Shadow
@Final
public int[] enchantmentPower;
public int[] costs;
@Shadow
@Final
public int[] enchantmentId;
public int[] enchantClue;
@Shadow
@Final
public int[] enchantmentLevel;
public int[] levelClue;
protected EnchantmentScreenHandlerMixin(MenuType<?> type, int syncId) {
protected EnchantmentMenuMixin(MenuType<?> type, int syncId) {
super(type, syncId);
}
@Inject(method = "onContentChanged", at = @At("HEAD"), cancellable = true)
private void beOnContentChanged(Container inventory, CallbackInfo info) {
if (inventory == this.inventory) {
@Inject(method = "slotsChanged", at = @At("HEAD"), cancellable = true)
private void be_slotsChanged(Container inventory, CallbackInfo info) {
if (inventory == this.enchantSlots) {
ItemStack itemStack = inventory.getItem(0);
if (!itemStack.isEmpty() && itemStack.isEnchantable()) {
this.context.execute((world, blockPos) -> {
this.access.execute((world, blockPos) -> {
int i = 0;
int j;
@ -95,24 +95,24 @@ public abstract class EnchantmentScreenHandlerMixin extends AbstractContainerMen
}
}
this.random.setSeed((long) this.seed.get());
this.random.setSeed((long) this.enchantmentSeed.get());
for (j = 0; j < 3; ++j) {
this.enchantmentPower[j] = EnchantmentHelper.getEnchantmentCost(this.random, j, i, itemStack);
this.enchantmentId[j] = -1;
this.enchantmentLevel[j] = -1;
if (this.enchantmentPower[j] < j + 1) {
this.enchantmentPower[j] = 0;
this.costs[j] = EnchantmentHelper.getEnchantmentCost(this.random, j, i, itemStack);
this.enchantClue[j] = -1;
this.levelClue[j] = -1;
if (this.costs[j] < j + 1) {
this.costs[j] = 0;
}
}
for (j = 0; j < 3; ++j) {
if (this.enchantmentPower[j] > 0) {
List<EnchantmentInstance> list = this.generateEnchantments(itemStack, j, this.enchantmentPower[j]);
if (this.costs[j] > 0) {
List<EnchantmentInstance> list = this.generateEnchantments(itemStack, j, this.costs[j]);
if (list != null && !list.isEmpty()) {
EnchantmentInstance enchantmentLevelEntry = (EnchantmentInstance) list.get(this.random.nextInt(list.size()));
this.enchantmentId[j] = Registry.ENCHANTMENT.getId(enchantmentLevelEntry.enchantment);
this.enchantmentLevel[j] = enchantmentLevelEntry.level;
this.enchantClue[j] = Registry.ENCHANTMENT.getId(enchantmentLevelEntry.enchantment);
this.levelClue[j] = enchantmentLevelEntry.level;
}
}
}
@ -122,9 +122,9 @@ public abstract class EnchantmentScreenHandlerMixin extends AbstractContainerMen
}
else {
for (int i = 0; i < 3; ++i) {
this.enchantmentPower[i] = 0;
this.enchantmentId[i] = -1;
this.enchantmentLevel[i] = -1;
this.costs[i] = 0;
this.enchantClue[i] = -1;
this.levelClue[i] = -1;
}
}
info.cancel();

View file

@ -16,16 +16,16 @@ import ru.betterend.world.generator.GeneratorOptions;
@Mixin(EndCityFeature.class)
public class EndCityFeatureMixin {
@Inject(method = "shouldStartAt", at = @At("HEAD"), cancellable = true)
private void be_shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, WorldgenRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration defaultFeatureConfig, CallbackInfoReturnable<Boolean> info) {
@Inject(method = "isFeatureChunk", at = @At("HEAD"), cancellable = true)
private void be_isFeatureChunk(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, WorldgenRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration defaultFeatureConfig, CallbackInfoReturnable<Boolean> info) {
if (GeneratorOptions.useNewGenerator()) {
int chance = GeneratorOptions.getEndCityFailChance();
if (chance == 0) {
info.setReturnValue(getGenerationHeight(i, j, chunkGenerator) >= 60);
info.setReturnValue(getYPositionForFeature(i, j, chunkGenerator) >= 60);
info.cancel();
}
else if (chunkRandom.nextInt(chance) == 0){
info.setReturnValue(getGenerationHeight(i, j, chunkGenerator) >= 60);
info.setReturnValue(getYPositionForFeature(i, j, chunkGenerator) >= 60);
info.cancel();
}
else {
@ -36,7 +36,7 @@ public class EndCityFeatureMixin {
}
@Shadow
private static int getGenerationHeight(int chunkX, int chunkZ, ChunkGenerator chunkGenerator) {
private static int getYPositionForFeature(int chunkX, int chunkZ, ChunkGenerator chunkGenerator) {
return 0;
}
}

View file

@ -23,20 +23,20 @@ import ru.betterend.util.WorldDataUtil;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(EndPodiumFeature.class)
public class EndPortalFeatureMixin {
public class EndPodiumFeatureMixin {
@Final
@Shadow
private boolean open;
private boolean active;
@Inject(method = "generate", at = @At("HEAD"), cancellable = true)
private void bePortalGenerate(WorldGenLevel world, ChunkGenerator generator, Random random, BlockPos blockPos, NoneFeatureConfiguration config, CallbackInfoReturnable<Boolean> info) {
@Inject(method = "place", at = @At("HEAD"), cancellable = true)
private void be_place(WorldGenLevel world, ChunkGenerator generator, Random random, BlockPos blockPos, NoneFeatureConfiguration config, CallbackInfoReturnable<Boolean> info) {
if (!GeneratorOptions.hasPortal()) {
info.setReturnValue(false);
info.cancel();
}
else if (GeneratorOptions.replacePortal()) {
blockPos = be_updatePos(blockPos, world);
StructureTemplate structure = StructureHelper.readStructure(BetterEnd.makeID(open ? "portal/end_portal_active" : "portal/end_portal_inactive"));
StructureTemplate structure = StructureHelper.readStructure(BetterEnd.makeID(active ? "portal/end_portal_active" : "portal/end_portal_inactive"));
BlockPos size = structure.getSize();
blockPos = blockPos.offset(-(size.getX() >> 1), -3, -(size.getZ() >> 1));
structure.placeInWorldChunk(world, blockPos, new StructurePlaceSettings(), random);
@ -45,7 +45,7 @@ public class EndPortalFeatureMixin {
}
}
@ModifyVariable(method = "generate", ordinal = 0, at = @At("HEAD"))
@ModifyVariable(method = "place", ordinal = 0, at = @At("HEAD"))
private BlockPos be_setPosOnGround(BlockPos blockPos, WorldGenLevel world) {
return be_updatePos(blockPos, world);
}

View file

@ -12,10 +12,9 @@ import ru.betterend.effects.EndEnchantments;
import ru.betterend.effects.EndStatusEffects;
@Mixin(EnderMan.class)
public abstract class EndermanEntityMixin {
@Inject(method = "isPlayerStaring", at = @At("HEAD"), cancellable = true)
private void be_isPlayerStaring(Player player, CallbackInfoReturnable<Boolean> info) {
public abstract class EnderManMixin {
@Inject(method = "isLookingAtMe", at = @At("HEAD"), cancellable = true)
private void be_isLookingAtMe(Player player, CallbackInfoReturnable<Boolean> info) {
if (player.isCreative() || player.hasEffect(EndStatusEffects.END_VEIL) ||
EnchantmentHelper.getItemEnchantmentLevel(EndEnchantments.END_VEIL, player.getItemBySlot(EquipmentSlot.HEAD)) > 0) {
info.setReturnValue(false);

View file

@ -17,11 +17,10 @@ import ru.betterend.interfaces.TeleportingEntity;
@Mixin(Entity.class)
public abstract class EntityMixin implements TeleportingEntity {
@Shadow
public float yaw;
public float yRot;
@Shadow
public float pitch;
public float xRot;
@Shadow
public boolean removed;
@Shadow
@ -42,9 +41,9 @@ public abstract class EntityMixin implements TeleportingEntity {
private BlockPos exitPos;
@Inject(method = "moveToWorld", at = @At("HEAD"), cancellable = true)
public void be_moveToWorld(ServerLevel destination, CallbackInfoReturnable<Entity> info) {
if (!removed && beCanTeleport() && world instanceof ServerLevel) {
@Inject(method = "changeDimension", at = @At("HEAD"), cancellable = true)
public void be_changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> info) {
if (!removed && be_canTeleport() && world instanceof ServerLevel) {
this.detach();
this.world.getProfiler().push("changeDimension");
this.world.getProfiler().push("reposition");
@ -63,31 +62,31 @@ public abstract class EntityMixin implements TeleportingEntity {
((ServerLevel) world).resetEmptyTime();
destination.resetEmptyTime();
this.world.getProfiler().pop();
this.beResetExitPos();
this.be_resetExitPos();
info.setReturnValue(entity);
}
}
}
@Inject(method = "getTeleportTarget", at = @At("HEAD"), cancellable = true)
protected void be_getTeleportTarget(ServerLevel destination, CallbackInfoReturnable<PortalInfo> info) {
if (beCanTeleport()) {
info.setReturnValue(new PortalInfo(new Vec3(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getVelocity(), yaw, pitch));
@Inject(method = "findDimensionEntryPoint", at = @At("HEAD"), cancellable = true)
protected void be_findDimensionEntryPoint(ServerLevel destination, CallbackInfoReturnable<PortalInfo> info) {
if (be_canTeleport()) {
info.setReturnValue(new PortalInfo(new Vec3(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getVelocity(), yRot, xRot));
}
}
@Override
public void beSetExitPos(BlockPos pos) {
public void be_setExitPos(BlockPos pos) {
this.exitPos = pos.immutable();
}
@Override
public void beResetExitPos() {
public void be_resetExitPos() {
this.exitPos = null;
}
@Override
public boolean beCanTeleport() {
public boolean be_canTeleport() {
return this.exitPos != null;
}
}

View file

@ -16,15 +16,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin {
private Entity lastAttacker;
@Inject(method = "damage", at = @At("HEAD"))
public void be_damage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> info) {
@Inject(method = "hurt", at = @At("HEAD"))
public void be_hurt(DamageSource source, float amount, CallbackInfoReturnable<Boolean> info) {
this.lastAttacker = source.getEntity();
}
@ModifyArg(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;takeKnockback(FDD)V"))
@ModifyArg(method = "hurt", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;knockback(FDD)V"))
private float be_increaseKnockback(float value, double x, double z) {
if (lastAttacker != null && lastAttacker instanceof LivingEntity) {
LivingEntity attacker = (LivingEntity) lastAttacker;
@ -35,8 +34,7 @@ public abstract class LivingEntityMixin {
private double be_getKnockback(Item tool) {
if (tool == null) return 0.0D;
Collection<AttributeModifier> modifiers = tool.getDefaultAttributeModifiers(EquipmentSlot.MAINHAND)
.get(Attributes.ATTACK_KNOCKBACK);
Collection<AttributeModifier> modifiers = tool.getDefaultAttributeModifiers(EquipmentSlot.MAINHAND).get(Attributes.ATTACK_KNOCKBACK);
if (modifiers.size() > 0) {
return modifiers.iterator().next().getAmount();
}

View file

@ -29,73 +29,73 @@ import ru.betterend.world.generator.GeneratorOptions;
@Mixin(MinecraftServer.class)
public class MinecraftServerMixin {
@Shadow
private ServerResources serverResourceManager;
private ServerResources resources;
@Final
@Shadow
private Map<ResourceKey<Level>, ServerLevel> worlds;
private Map<ResourceKey<Level>, ServerLevel> levels;
@Final
@Shadow
protected WorldData saveProperties;
protected WorldData worldData;
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
private void beOnReload(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> info) {
beInjectRecipes();
private void be_reloadResources(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> info) {
be_injectRecipes();
}
@Inject(method = "loadWorld", at = @At(value = "RETURN"), cancellable = true)
private void beOnLoadWorld(CallbackInfo info) {
beInjectRecipes();
@Inject(method = "loadLevel", at = @At(value = "RETURN"), cancellable = true)
private void be_loadLevel(CallbackInfo info) {
be_injectRecipes();
EndBiomes.initRegistry((MinecraftServer) (Object) this);
}
@Inject(method = "getOverworld", at = @At(value = "HEAD"), cancellable = true)
private final void beGetOverworld(CallbackInfoReturnable<ServerLevel> info) {
@Inject(method = "overworld", at = @At(value = "HEAD"), cancellable = true)
private final void be_overworld(CallbackInfoReturnable<ServerLevel> info) {
if (GeneratorOptions.swapOverworldToEnd()) {
ServerLevel world = worlds.get(Level.END);
ServerLevel world = levels.get(Level.END);
if (world == null) {
world = worlds.get(Level.OVERWORLD);
world = levels.get(Level.OVERWORLD);
}
info.setReturnValue(world);
info.cancel();
}
}
@Inject(method = "createWorlds", at = @At(value = "TAIL"))
private final void be_CreateWorlds(ChunkProgressListener worldGenerationProgressListener, CallbackInfo info) {
@Inject(method = "createLevels", at = @At(value = "TAIL"))
private final void be_createLevels(ChunkProgressListener worldGenerationProgressListener, CallbackInfo info) {
if (GeneratorOptions.swapOverworldToEnd()) {
ServerLevel world = worlds.get(Level.END);
ServerLevel world = levels.get(Level.END);
if (world == null) {
world = worlds.get(Level.OVERWORLD);
world = levels.get(Level.OVERWORLD);
}
this.getPlayerManager().setLevel(world);
ServerLevelData serverWorldProperties = saveProperties.overworldData();
net.minecraft.world.level.levelgen.WorldGenSettings generatorOptions = saveProperties.worldGenSettings();
this.getPlayerList().setLevel(world);
ServerLevelData serverWorldProperties = worldData.overworldData();
net.minecraft.world.level.levelgen.WorldGenSettings generatorOptions = worldData.worldGenSettings();
boolean bl = generatorOptions.isDebug();
setupSpawn(world, serverWorldProperties, generatorOptions.generateBonusChest(), bl, true);
setInitialSpawn(world, serverWorldProperties, generatorOptions.generateBonusChest(), bl, true);
}
}
@Inject(method = "setupSpawn", at = @At(value = "HEAD"), cancellable = true)
private static void be_SetupSpawn(ServerLevel world, ServerLevelData serverWorldProperties, boolean bonusChest, boolean debugWorld, boolean bl, CallbackInfo info) {
@Inject(method = "setInitialSpawn", at = @At(value = "HEAD"), cancellable = true)
private static void be_setInitialSpawn(ServerLevel world, ServerLevelData serverWorldProperties, boolean bonusChest, boolean debugWorld, boolean bl, CallbackInfo info) {
if (GeneratorOptions.swapOverworldToEnd() && world.dimension() == Level.OVERWORLD) {
info.cancel();
}
}
@Shadow
private static void setupSpawn(ServerLevel world, ServerLevelData serverWorldProperties, boolean bonusChest, boolean debugWorld, boolean bl) {}
private static void setInitialSpawn(ServerLevel world, ServerLevelData serverWorldProperties, boolean bonusChest, boolean debugWorld, boolean bl) {}
@Shadow
public PlayerList getPlayerManager() {
public PlayerList getPlayerList() {
return null;
}
private void beInjectRecipes() {
private void be_injectRecipes() {
if (FabricLoader.getInstance().isModLoaded("kubejs")) {
RecipeManagerAccessor accessor = (RecipeManagerAccessor) serverResourceManager.getRecipeManager();
accessor.setRecipes(EndRecipeManager.getMap(accessor.getRecipes()));
RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.getRecipeManager();
accessor.be_setRecipes(EndRecipeManager.getMap(accessor.be_getRecipes()));
}
}
}

View file

@ -15,9 +15,9 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Monster.class)
public class HostileEntityMixin {
@Inject(method = "canSpawnInDark", at = @At(value = "RETURN"), cancellable = true)
private static void be_endermenCheck(EntityType<? extends Monster> type, ServerLevelAccessor serverWorldAccess, MobSpawnType spawnReason, BlockPos pos, Random random, CallbackInfoReturnable<Boolean> info) {
public class MonsterMixin {
@Inject(method = "checkMonsterSpawnRules", at = @At(value = "RETURN"), cancellable = true)
private static void be_checkMonsterSpawnRules(EntityType<? extends Monster> type, ServerLevelAccessor serverWorldAccess, MobSpawnType spawnReason, BlockPos pos, Random random, CallbackInfoReturnable<Boolean> info) {
boolean canSpawn = info.getReturnValue();
if (canSpawn && spawnReason == MobSpawnType.NATURAL && type == EntityType.ENDERMAN) {
AABB box = new AABB(pos).inflate(16);

View file

@ -16,28 +16,25 @@ import ru.betterend.world.generator.GeneratorOptions;
import ru.betterend.world.generator.TerrainGenerator;
@Mixin(NoiseBasedChunkGenerator.class)
public abstract class NoiseChunkGeneratorMixin extends ChunkGenerator {
public abstract class NoiseBasedChunkGeneratorMixin extends ChunkGenerator {
@Final
@Shadow
protected Supplier<NoiseGeneratorSettings> settings;
public NoiseChunkGeneratorMixin(BiomeSource populationSource, BiomeSource biomeSource, StructureSettings structuresConfig, long worldSeed) {
public NoiseBasedChunkGeneratorMixin(BiomeSource populationSource, BiomeSource biomeSource, StructureSettings structuresConfig, long worldSeed) {
super(populationSource, biomeSource, structuresConfig, worldSeed);
}
@Inject(method = "<init>(Lnet/minecraft/world/biome/source/BiomeSource;Lnet/minecraft/world/biome/source/BiomeSource;JLjava/util/function/Supplier;)V", at = @At("TAIL"))
@Inject(method = "<init>(Lnet/minecraft/world/level/biome/BiomeSource;Lnet/minecraft/world/level/biome/BiomeSource;JLjava/util/function/Supplier;)V", at = @At("TAIL"))
private void beOnInit(BiomeSource populationSource, BiomeSource biomeSource, long seed, Supplier<NoiseGeneratorSettings> settings, CallbackInfo info) {
TerrainGenerator.initNoise(seed);
}
@Inject(method = "sampleNoiseColumn([DII)V", at = @At("HEAD"), cancellable = true, allow = 2)
private void beSampleNoiseColumn(double[] buffer, int x, int z, CallbackInfo info) {
@Inject(method = "fillNoiseColumn([DII)V", at = @At("HEAD"), cancellable = true, allow = 2)
private void be_fillNoiseColumn(double[] buffer, int x, int z, CallbackInfo info) {
if (GeneratorOptions.useNewGenerator() && settings.get().stable(NoiseGeneratorSettings.END)) {
//System.out.println(TerrainGenerator.canGenerate(x, z));
//if (TerrainGenerator.canGenerate(x, z)) {
TerrainGenerator.fillTerrainDensity(buffer, x, z, getBiomeSource());
info.cancel();
//}
}
}
}

View file

@ -12,16 +12,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.betterend.events.PlayerAdvancementsEvents;
@Mixin(PlayerAdvancements.class)
public abstract class PlayerAdvancementTrackerMixin {
public abstract class PlayerAdvancementsMixin {
@Shadow
private ServerPlayer owner;
private ServerPlayer player;
@Inject(method = "grantCriterion", at = @At(
@Inject(method = "award", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/advancement/AdvancementRewards;apply(Lnet/minecraft/server/network/ServerPlayerEntity;)V",
target = "Lnet/minecraft/server/PlayerAdvancements;grant(Lnet/minecraft/server/level/ServerPlayer;)V",
shift = Shift.AFTER))
public void be_onAdvancementComplete(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> info) {
PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.invoker().onAdvancementComplete(owner, advancement, criterionName);
public void be_award(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> info) {
PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.invoker().onAdvancementComplete(player, advancement, criterionName);
}
}

View file

@ -59,7 +59,7 @@ import net.minecraft.world.level.storage.LevelData;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(PlayerList.class)
public class PlayerManagerMixin {
public class PlayerListMixin {
@Final
@Shadow
private static Logger LOGGER;
@ -70,7 +70,7 @@ public class PlayerManagerMixin {
@Final
@Shadow
private RegistryAccess.RegistryHolder registryManager;
private RegistryAccess.RegistryHolder registryHolder;
@Shadow
private int viewDistance;
@ -81,17 +81,17 @@ public class PlayerManagerMixin {
@Final
@Shadow
private Map<UUID, ServerPlayer> playerMap;
private Map<UUID, ServerPlayer> playersByUUID;
@Inject(method = "onPlayerConnect", at = @At(value = "HEAD"), cancellable = true)
public void be_onPlayerConnect(Connection connection, ServerPlayer player, CallbackInfo info) {
@Inject(method = "placeNewPlayer", at = @At(value = "HEAD"), cancellable = true)
public void be_placeNewPlayer(Connection connection, ServerPlayer player, CallbackInfo info) {
if (GeneratorOptions.swapOverworldToEnd()) {
GameProfile gameProfile = player.getGameProfile();
GameProfileCache userCache = this.server.getProfileCache();
GameProfile gameProfile2 = userCache.get(gameProfile.getId());
String string = gameProfile2 == null ? gameProfile.getName() : gameProfile2.getName();
userCache.add(gameProfile);
CompoundTag compoundTag = this.loadPlayerData(player);
CompoundTag compoundTag = this.load(player);
ResourceKey<Level> var23;
if (compoundTag != null) {
DataResult<ResourceKey<Level>> var10000 = DimensionType.parseLegacy(new Dynamic<Tag>(NbtOps.INSTANCE, compoundTag.get("Dimension")));
@ -123,13 +123,13 @@ public class PlayerManagerMixin {
LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", player.getName().getString(), string2, player.getId(), player.getX(), player.getY(), player.getZ());
LevelData worldProperties = serverWorld3.getLevelData();
this.setGameMode(player, (ServerPlayer) null, serverWorld3);
this.updatePlayerGameMode(player, (ServerPlayer) null, serverWorld3);
ServerGamePacketListenerImpl serverPlayNetworkHandler = new ServerGamePacketListenerImpl(this.server, connection, player);
GameRules gameRules = serverWorld3.getGameRules();
boolean bl = gameRules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN);
boolean bl2 = gameRules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
serverPlayNetworkHandler.send(new ClientboundLoginPacket(player.getId(), player.gameMode.getGameModeForPlayer(), player.gameMode.getPreviousGameModeForPlayer(), BiomeManager.obfuscateSeed(serverWorld3.getSeed()),
worldProperties.isHardcore(), this.server.levelKeys(), this.registryManager, serverWorld3.dimensionType(), serverWorld3.dimension(), this.getMaxPlayerCount(), this.viewDistance, bl2, !bl,
worldProperties.isHardcore(), this.server.levelKeys(), this.registryHolder, serverWorld3.dimensionType(), serverWorld3.dimension(), this.getPlayerCount(), this.viewDistance, bl2, !bl,
serverWorld3.isDebug(), serverWorld3.isFlat()));
serverPlayNetworkHandler.send(new ClientboundCustomPayloadPacket(ClientboundCustomPayloadPacket.BRAND, (new FriendlyByteBuf(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())));
serverPlayNetworkHandler.send(new ClientboundChangeDifficultyPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked()));
@ -137,10 +137,10 @@ public class PlayerManagerMixin {
serverPlayNetworkHandler.send(new ClientboundSetCarriedItemPacket(player.inventory.selected));
serverPlayNetworkHandler.send(new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getRecipes()));
serverPlayNetworkHandler.send(new ClientboundUpdateTagsPacket(this.server.getTags()));
this.sendCommandTree(player);
this.sendPlayerPermissionLevel(player);
player.getStats().markAllDirty();
player.getRecipeBook().sendInitialRecipeBook(player);
this.sendScoreboard(serverWorld3.getScoreboard(), player);
this.updateEntireScoreboard(serverWorld3.getScoreboard(), player);
this.server.invalidateStatus();
TranslatableComponent mutableText2;
if (player.getGameProfile().getName().equalsIgnoreCase(string)) {
@ -150,11 +150,11 @@ public class PlayerManagerMixin {
mutableText2 = new TranslatableComponent("multiplayer.player.joined.renamed", new Object[] { player.getDisplayName(), string });
}
this.broadcastChatMessage(mutableText2.withStyle(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.NIL_UUID);
this.broadcastMessage(mutableText2.withStyle(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.NIL_UUID);
serverPlayNetworkHandler.teleport(player.getX(), player.getY(), player.getZ(), player.yRot, player.xRot);
this.players.add(player);
this.playerMap.put(player.getUUID(), player);
this.sendToAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, new ServerPlayer[] { player }));
this.playersByUUID.put(player.getUUID(), player);
this.broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, new ServerPlayer[] { player }));
for (int i = 0; i < this.players.size(); ++i) {
player.connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, new ServerPlayer[] { (ServerPlayer) this.players.get(i) }));
@ -162,7 +162,7 @@ public class PlayerManagerMixin {
serverWorld3.addNewPlayer(player);
this.server.getCustomBossEvents().onPlayerConnect(player);
this.sendWorldInfo(player, serverWorld3);
this.sendLevelInfo(player, serverWorld3);
if (!this.server.getResourcePack().isEmpty()) {
player.sendTexturePack(this.server.getResourcePack(), this.server.getResourcePackHash());
}
@ -224,18 +224,18 @@ public class PlayerManagerMixin {
}
@Shadow
public CompoundTag loadPlayerData(ServerPlayer player) {
public CompoundTag load(ServerPlayer player) {
return null;
}
@Shadow
private void setGameMode(ServerPlayer player, @Nullable ServerPlayer oldPlayer, ServerLevel world) {}
private void updatePlayerGameMode(ServerPlayer player, @Nullable ServerPlayer oldPlayer, ServerLevel world) {}
@Shadow
public void sendCommandTree(ServerPlayer player) {}
public void sendPlayerPermissionLevel(ServerPlayer player) {}
@Shadow
public int getMaxPlayerCount() {
public int getPlayerCount() {
return 0;
}
@ -245,14 +245,14 @@ public class PlayerManagerMixin {
}
@Shadow
protected void sendScoreboard(ServerScoreboard scoreboard, ServerPlayer player) {}
protected void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) {}
@Shadow
public void broadcastChatMessage(Component message, ChatType type, UUID senderUuid) {}
public void broadcastMessage(Component message, ChatType type, UUID senderUuid) {}
@Shadow
public void sendToAll(Packet<?> packet) {}
public void broadcastAll(Packet<?> packet) {}
@Shadow
public void sendWorldInfo(ServerPlayer player, ServerLevel world) {}
public void sendLevelInfo(ServerPlayer player, ServerLevel world) {}
}

View file

@ -18,30 +18,30 @@ import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@Mixin(Player.class)
public abstract class PlayerEntityMixin {
private static Direction[] HORIZONTAL;
public abstract class PlayerMixin {
private static Direction[] horizontal;
@Inject(method = "findRespawnPosition", at = @At(value = "HEAD"), cancellable = true)
private static void be_statueRespawn(ServerLevel world, BlockPos pos, float f, boolean bl, boolean bl2, CallbackInfoReturnable<Optional<Vec3>> info) {
@Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At(value = "HEAD"), cancellable = true)
private static void be_findRespawnPositionAndUseSpawnBlock(ServerLevel world, BlockPos pos, float f, boolean bl, boolean bl2, CallbackInfoReturnable<Optional<Vec3>> info) {
BlockState blockState = world.getBlockState(pos);
if (blockState.is(EndBlocks.RESPAWN_OBELISK)) {
info.setReturnValue(beObeliskRespawnPosition(world, pos, blockState));
info.setReturnValue(be_obeliskRespawnPosition(world, pos, blockState));
info.cancel();
}
}
private static Optional<Vec3> beObeliskRespawnPosition(ServerLevel world, BlockPos pos, BlockState state) {
private static Optional<Vec3> be_obeliskRespawnPosition(ServerLevel world, BlockPos pos, BlockState state) {
if (state.getValue(BlockProperties.TRIPLE_SHAPE) == TripleShape.TOP) {
pos = pos.below(2);
}
else if (state.getValue(BlockProperties.TRIPLE_SHAPE) == TripleShape.MIDDLE) {
pos = pos.below();
}
if (HORIZONTAL == null) {
HORIZONTAL = BlocksHelper.makeHorizontal();
if (horizontal == null) {
horizontal = BlocksHelper.makeHorizontal();
}
MHelper.shuffle(HORIZONTAL, world.getRandom());
for (Direction dir: HORIZONTAL) {
MHelper.shuffle(horizontal, world.getRandom());
for (Direction dir: horizontal) {
BlockPos p = pos.relative(dir);
BlockState state2 = world.getBlockState(p);
if (!state2.getMaterial().blocksMotion() && state2.getCollisionShape(world, pos).isEmpty()) {

View file

@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(PotionBrewing.class)
public interface BrewingAccessor {
public interface PotionBrewingAccessor {
@Invoker
static void callAddMix(Potion input, Item item, Potion output) {
throw new AssertionError("@Invoker dummy body called");

View file

@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(RecipeManager.class)
public interface RecipeManagerAccessor {
@Accessor("recipes")
Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> getRecipes();
Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> be_getRecipes();
@Accessor("recipes")
void setRecipes(Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> recipes);
void be_setRecipes(Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> recipes);
}

View file

@ -30,7 +30,7 @@ public class RecipeManagerMixin {
private Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> recipes;
@Inject(method = "apply", at = @At(value = "RETURN"))
private void beSetRecipes(Map<ResourceLocation, JsonElement> map, ResourceManager resourceManager, ProfilerFiller profiler, CallbackInfo info) {
private void be_apply(Map<ResourceLocation, JsonElement> map, ResourceManager resourceManager, ProfilerFiller profiler, CallbackInfo info) {
recipes = EndRecipeManager.getMap(recipes);
}
@ -46,7 +46,7 @@ public class RecipeManagerMixin {
* (example - mod stone with vanilla tags and furnace from that stone)
*/
@Overwrite
public <C extends Container, T extends Recipe<C>> Optional<T> getFirstMatch(RecipeType<T> type, C inventory, Level world) {
public <C extends Container, T extends Recipe<C>> Optional<T> getRecipeFor(RecipeType<T> type, C inventory, Level world) {
Collection<Recipe<C>> values = getAllOfType(type).values();
List<Recipe<C>> list = new ArrayList<Recipe<C>>(values);
list.sort((v1, v2) -> {

View file

@ -32,7 +32,7 @@ import ru.betterend.util.WorldDataUtil;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(ServerLevel.class)
public class ServerWorldMixin {
public class ServerLevelMixin {
private static final int DEV_VERSION = be_getVersionInt("63.63.63");
private static final int FIX_VERSION = DEV_VERSION;
private static String lastWorld = null;
@ -70,8 +70,8 @@ public class ServerWorldMixin {
}
}
@Inject(method = "getSpawnPos", at = @At("HEAD"), cancellable = true)
private void be_getSpawnPos(CallbackInfoReturnable<BlockPos> info) {
@Inject(method = "getSharedSpawnPos", at = @At("HEAD"), cancellable = true)
private void be_getSharedSpawnPos(CallbackInfoReturnable<BlockPos> info) {
if (GeneratorOptions.changeSpawn()) {
if (((ServerLevel) (Object) this).dimension() == Level.END) {
info.setReturnValue(GeneratorOptions.getSpawn());

View file

@ -33,28 +33,27 @@ import ru.betterend.interfaces.TeleportingEntity;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(ServerPlayer.class)
public abstract class ServerPlayerEntityMixin extends Player implements TeleportingEntity {
public abstract class ServerPlayerMixin extends Player implements TeleportingEntity {
@Shadow
public ServerGamePacketListenerImpl networkHandler;
public ServerGamePacketListenerImpl connection;
@Final
@Shadow
public ServerPlayerGameMode interactionManager;
public ServerPlayerGameMode gameMode;
@Final
@Shadow
public MinecraftServer server;
@Shadow
private boolean inTeleportationState;
private boolean isChangingDimension;
@Shadow
private float syncedHealth;
private float lastSentHealth;
@Shadow
private int syncedFoodLevel;
private int lastSentFood;
@Shadow
private int syncedExperience;
private int lastSentExp;
private BlockPos exitPos;
public ServerPlayerEntityMixin(Level world, BlockPos pos, float yaw, GameProfile profile) {
public ServerPlayerMixin(Level world, BlockPos pos, float yaw, GameProfile profile) {
super(world, pos, yaw, profile);
}
@ -67,21 +66,21 @@ public abstract class ServerPlayerEntityMixin extends Player implements Teleport
@Inject(method = "getTeleportTarget", at = @At("HEAD"), cancellable = true)
protected void be_getTeleportTarget(ServerLevel destination, CallbackInfoReturnable<PortalInfo> info) {
if (beCanTeleport()) {
if (be_canTeleport()) {
info.setReturnValue(new PortalInfo(new Vec3(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getDeltaMovement(), yRot, xRot));
}
}
@Inject(method = "moveToWorld", at = @At("HEAD"), cancellable = true)
public void be_moveToWorld(ServerLevel destination, CallbackInfoReturnable<Entity> info) {
if (beCanTeleport() && level instanceof ServerLevel) {
this.inTeleportationState = true;
ServerLevel serverWorld = this.getServerWorld();
@Inject(method = "changeDimension", at = @At("HEAD"), cancellable = true)
public void be_changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> info) {
if (be_canTeleport() && level instanceof ServerLevel) {
this.isChangingDimension = true;
ServerLevel serverWorld = this.getLevel();
LevelData worldProperties = destination.getLevelData();
ServerPlayer player = ServerPlayer.class.cast(this);
this.networkHandler.send(new ClientboundRespawnPacket(destination.dimensionType(), destination.dimension(), BiomeManager.obfuscateSeed(destination.getSeed()),
interactionManager.getGameModeForPlayer(),interactionManager.getPreviousGameModeForPlayer(), destination.isDebug(), destination.isFlat(), true));
this.networkHandler.send(new ClientboundChangeDifficultyPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked()));
this.connection.send(new ClientboundRespawnPacket(destination.dimensionType(), destination.dimension(), BiomeManager.obfuscateSeed(destination.getSeed()),
gameMode.getGameModeForPlayer(),gameMode.getPreviousGameModeForPlayer(), destination.isDebug(), destination.isFlat(), true));
this.connection.send(new ClientboundChangeDifficultyPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked()));
PlayerList playerManager = this.server.getPlayerList();
playerManager.sendPlayerPermissionLevel(player);
serverWorld.removePlayerImmediately(player);
@ -96,48 +95,48 @@ public abstract class ServerPlayerEntityMixin extends Player implements Teleport
this.setRot(teleportTarget.yRot, teleportTarget.xRot);
this.moveTo(teleportTarget.pos.x, teleportTarget.pos.y, teleportTarget.pos.z);
serverWorld.getProfiler().pop();
this.worldChanged(serverWorld);
this.interactionManager.setLevel(destination);
this.networkHandler.send(new ClientboundPlayerAbilitiesPacket(this.abilities));
this.triggerDimensionChangeTriggers(serverWorld);
this.gameMode.setLevel(destination);
this.connection.send(new ClientboundPlayerAbilitiesPacket(this.abilities));
playerManager.sendLevelInfo(player, destination);
playerManager.sendAllPlayerInfo(player);
for (MobEffectInstance statusEffectInstance : this.getActiveEffects()) {
this.networkHandler.send(new ClientboundUpdateMobEffectPacket(getId(), statusEffectInstance));
this.connection.send(new ClientboundUpdateMobEffectPacket(getId(), statusEffectInstance));
}
this.networkHandler.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
this.syncedExperience = -1;
this.syncedHealth = -1.0F;
this.syncedFoodLevel = -1;
this.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
}
this.beResetExitPos();
this.be_resetExitPos();
info.setReturnValue(player);
}
}
@Shadow
abstract ServerLevel getServerWorld();
abstract ServerLevel getLevel();
@Shadow
abstract void worldChanged(ServerLevel origin);
abstract void triggerDimensionChangeTriggers(ServerLevel origin);
@Shadow
@Override
protected abstract PortalInfo findDimensionEntryPoint(ServerLevel destination);
@Override
public void beSetExitPos(BlockPos pos) {
public void be_setExitPos(BlockPos pos) {
this.exitPos = pos.immutable();
}
@Override
public void beResetExitPos() {
public void be_resetExitPos() {
this.exitPos = null;
}
@Override
public boolean beCanTeleport() {
public boolean be_canTeleport() {
return this.exitPos != null;
}
}

View file

@ -6,12 +6,12 @@ import org.spongepowered.asm.mixin.Shadow;
import ru.betterend.interfaces.ISlime;
@Mixin(Slime.class)
public class SlimeEntityMixin implements ISlime {
public class SlimeMixin implements ISlime {
@Shadow
protected void setSize(int size, boolean heal) {}
@Override
public void beSetSlimeSize(int size, boolean heal) {
public void be_setSlimeSize(int size, boolean heal) {
setSize(size, heal);
}
}

View file

@ -31,16 +31,16 @@ import ru.betterend.util.WorldDataUtil;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(SpikeFeature.class)
public class EndSpikeFeatureMixin {
@Inject(method = "generate", at = @At("HEAD"), cancellable = true)
private void beSpikeGenerate(WorldGenLevel structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, SpikeConfiguration endSpikeFeatureConfig, CallbackInfoReturnable<Boolean> info) {
public class SpikeFeatureMixin {
@Inject(method = "place", at = @At("HEAD"), cancellable = true)
private void be_place(WorldGenLevel structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, SpikeConfiguration endSpikeFeatureConfig, CallbackInfoReturnable<Boolean> info) {
if (!GeneratorOptions.hasPillars()) {
info.setReturnValue(false);
}
}
@Inject(method = "generateSpike", at = @At("HEAD"), cancellable = true)
private void be_generateSpike(ServerLevelAccessor world, Random random, SpikeConfiguration config, SpikeFeature.EndSpike spike, CallbackInfo info) {
@Inject(method = "placeSpike", at = @At("HEAD"), cancellable = true)
private void be_placeSpike(ServerLevelAccessor world, Random random, SpikeConfiguration config, SpikeFeature.EndSpike spike, CallbackInfo info) {
int x = spike.getCenterX();
int z = spike.getCenterZ();
int radius = spike.getRadius();

View file

@ -15,8 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.betterend.util.TagHelper;
@Mixin(TagLoader.class)
public class TagGroupLoaderMixin {
public class TagLoaderMixin {
@Shadow
private String entryType;

View file

@ -92,7 +92,7 @@ public class EndTags {
}
else if (block instanceof LeavesBlock || block instanceof SimpleLeavesBlock) {
TagHelper.addTag(BlockTags.LEAVES, block);
ComposterBlockAccessor.callRegisterCompostableItem(0.3F, block);
ComposterBlockAccessor.callAdd(0.3F, block);
}
else if (block instanceof VineBlock) {
TagHelper.addTag(BlockTags.CLIMBABLE, block);
@ -103,7 +103,7 @@ public class EndTags {
Material mat = block.defaultBlockState().getMaterial();
if (mat.equals(Material.PLANT) || mat.equals(Material.REPLACEABLE_PLANT)) {
ComposterBlockAccessor.callRegisterCompostableItem(0.1F, block);
ComposterBlockAccessor.callAdd(0.1F, block);
}
});
@ -111,7 +111,7 @@ public class EndTags {
if (item.isEdible()) {
FoodProperties food = item.getFoodProperties();
float compost = food.getNutrition() * food.getSaturationModifier() * 0.18F;
ComposterBlockAccessor.callRegisterCompostableItem(compost, item);
ComposterBlockAccessor.callAdd(compost, item);
}
});

View file

@ -10,7 +10,7 @@ import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import ru.betterend.mixin.common.GenerationSettingsAccessor;
import ru.betterend.mixin.common.BiomeGenerationSettingsAccessor;
import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndStructures;
@ -20,9 +20,9 @@ public class FeaturesHelper {
public static void addFeatures(Registry<Biome> biomeRegistry) {
biomeRegistry.forEach((biome) -> {
if (biome.getBiomeCategory() == Biome.BiomeCategory.THEEND && !INJECTED.contains(biome)) {
GenerationSettingsAccessor accessor = (GenerationSettingsAccessor) biome.getGenerationSettings();
List<Supplier<ConfiguredStructureFeature<?, ?>>> structures = Lists.newArrayList(accessor.beGetStructures());
List<List<Supplier<ConfiguredFeature<?, ?>>>> preFeatures = accessor.beGetFeatures();
BiomeGenerationSettingsAccessor accessor = (BiomeGenerationSettingsAccessor) biome.getGenerationSettings();
List<Supplier<ConfiguredStructureFeature<?, ?>>> structures = Lists.newArrayList(accessor.be_getStructures());
List<List<Supplier<ConfiguredFeature<?, ?>>>> preFeatures = accessor.be_getFeatures();
List<List<Supplier<ConfiguredFeature<?, ?>>>> features = new ArrayList<List<Supplier<ConfiguredFeature<?, ?>>>>(preFeatures.size());
preFeatures.forEach((list) -> {
features.add(Lists.newArrayList(list));
@ -31,8 +31,8 @@ public class FeaturesHelper {
EndFeatures.registerBiomeFeatures(biomeRegistry.getKey(biome), biome, features);
EndStructures.registerBiomeStructures(biomeRegistry.getKey(biome), biome, structures);
accessor.beSetFeatures(features);
accessor.beSetStructures(structures);
accessor.be_setFeatures(features);
accessor.be_setStructures(structures);
INJECTED.add(biome);
}
});

View file

@ -119,7 +119,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
private void setBiome(WorldGenLevel world, BlockPos pos, EndCaveBiome biome) {
IBiomeArray array = (IBiomeArray) world.getChunk(pos).getBiomes();
if (array != null) {
array.setBiome(biome.getActualBiome(), pos);
array.be_setBiome(biome.getActualBiome(), pos);
}
}

View file

@ -4,39 +4,39 @@
"package": "ru.betterend.mixin.common",
"compatibilityLevel": "JAVA_8",
"mixins": [
"EnchantmentScreenHandlerMixin",
"PlayerAdvancementTrackerMixin",
"CraftingScreenHandlerMixin",
"GenerationSettingsAccessor",
"NoiseChunkGeneratorMixin",
"BiomeGenerationSettingsAccessor",
"NoiseBasedChunkGeneratorMixin",
"ChunkBiomeContainerMixin",
"WeightedBiomePickerMixin",
"AnvilScreenHandlerMixin",
"ChorusPlantFeatureMixin",
"ServerPlayerEntityMixin",
"ComposterBlockAccessor",
"PlayerAdvancementsMixin",
"ChorusFlowerBlockMixin",
"EndPortalFeatureMixin",
"ComposterBlockAccessor",
"ChorusPlantBlockMixin",
"EndPodiumFeatureMixin",
"PotionBrewingAccessor",
"RecipeManagerAccessor",
"EndSpikeFeatureMixin",
"EnchantmentMenuMixin",
"MinecraftServerMixin",
"EndermanEntityMixin",
"TagGroupLoaderMixin",
"AbstractBlockMixin",
"BlockBehaviourMixin",
"DimensionTypeMixin",
"PlayerManagerMixin",
"RecipeManagerMixin",
"HostileEntityMixin",
"ArmorItemAccessor",
"BoneMealItemMixin",
"CraftingMenuMixin",
"LivingEntityMixin",
"PlayerEntityMixin",
"ServerWorldMixin",
"SlimeEntityMixin",
"ServerPlayerMixin",
"SpikeFeatureMixin",
"AnvilBlockMixin",
"BrewingAccessor",
"BiomeArrayMixin",
"EntityMixin"
"PlayerListMixin",
"ServerLevelMixin",
"AnvilMenuMixin",
"TagLoaderMixin",
"EnderManMixin",
"MonsterMixin",
"EntityMixin",
"PlayerMixin",
"SlimeMixin"
],
"injectors": {
"defaultRequire": 1