From 4385059f473585639c460420ef67ad4ecd62b9ee Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Thu, 9 Sep 2021 00:47:35 +0200 Subject: Fix Compile errors --- .../java/re/jag/parquet/commands/CameraMode.java | 12 ++-- src/main/java/re/jag/parquet/commands/Rename.java | 2 +- src/main/java/re/jag/parquet/commands/Stats.java | 22 +++---- .../java/re/jag/parquet/commands/TimeDIff.java | 2 +- .../parquet/dispenser/BucketDispenserBehavior.java | 56 ++++++++++++------ .../dispenser/DyeItemDispenserBehavior.java | 6 +- .../dispenser/GlassBottleDispenserBehavior.java | 68 +++++++++++----------- .../dispenser/MusicDiscDispenserBehavior.java | 2 +- .../parquet/dispenser/PotionDispenserBehavior.java | 35 ++++++----- .../ShulkerPlacementDispenserBehavior.java | 44 ++++++-------- .../dispenser/WaterBucketDispenserBehavior.java | 20 +++---- .../parquet/mixin/AbstractTraderEntityMixin.java | 2 +- .../re/jag/parquet/mixin/FireWorkItemMixin.java | 4 +- .../re/jag/parquet/mixin/MinecraftServerMixin.java | 4 +- .../re/jag/parquet/mixin/SellMapFactoryMixin.java | 2 +- .../jag/parquet/mixin/ServerPlayerEntityMixin.java | 23 ++++---- 16 files changed, 160 insertions(+), 144 deletions(-) (limited to 'src/main/java/re') diff --git a/src/main/java/re/jag/parquet/commands/CameraMode.java b/src/main/java/re/jag/parquet/commands/CameraMode.java index 60f61be..378214c 100644 --- a/src/main/java/re/jag/parquet/commands/CameraMode.java +++ b/src/main/java/re/jag/parquet/commands/CameraMode.java @@ -48,9 +48,9 @@ public class CameraMode { } private static void remove_status_effects(ServerPlayerEntity player) { - player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getEntityId(), StatusEffects.NIGHT_VISION)); + player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getId(), StatusEffects.NIGHT_VISION)); player.removeStatusEffect(StatusEffects.NIGHT_VISION); - player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getEntityId(), StatusEffects.CONDUIT_POWER)); + player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getId(), StatusEffects.CONDUIT_POWER)); player.removeStatusEffect(StatusEffects.CONDUIT_POWER); } @@ -61,8 +61,8 @@ public class CameraMode { } else { add_status_effects(player); } - - player.setGameMode(GameMode.SPECTATOR); + + player.changeGameMode(GameMode.SPECTATOR); player.addVelocity(0,0.1,0); player.networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(player)); @@ -77,7 +77,7 @@ public class CameraMode { remove_status_effects(player); } - player.setGameMode(GameMode.SURVIVAL); + player.changeGameMode(GameMode.SURVIVAL); return 1; } @@ -91,7 +91,7 @@ public class CameraMode { remove_status_effects(player); } - player.setGameMode( player.getServer().getDefaultGameMode() ); + player.changeGameMode( player.getServer().getDefaultGameMode() ); return 1; } diff --git a/src/main/java/re/jag/parquet/commands/Rename.java b/src/main/java/re/jag/parquet/commands/Rename.java index 79d6040..2072cae 100644 --- a/src/main/java/re/jag/parquet/commands/Rename.java +++ b/src/main/java/re/jag/parquet/commands/Rename.java @@ -36,7 +36,7 @@ public class Rename { } private static boolean can_execute (ServerCommandSource _source) { - if(_source.getMinecraftServer().getDefaultGameMode().isCreative()) + if(_source.getWorld().getServer().getDefaultGameMode().isCreative()) return true; try { diff --git a/src/main/java/re/jag/parquet/commands/Stats.java b/src/main/java/re/jag/parquet/commands/Stats.java index 95803c5..ee15f22 100644 --- a/src/main/java/re/jag/parquet/commands/Stats.java +++ b/src/main/java/re/jag/parquet/commands/Stats.java @@ -16,7 +16,7 @@ import com.mojang.authlib.GameProfile; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.command.argument.ObjectiveArgumentType; +import net.minecraft.command.argument.ScoreboardObjectiveArgumentType; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.ServerScoreboard; @@ -45,16 +45,16 @@ public class Stats { StringArgumentType.getString(c, "criteria") )) )). - then(literal("import").then(argument("score", ObjectiveArgumentType.objective()). + then(literal("import").then(argument("score", ScoreboardObjectiveArgumentType.scoreboardObjective()). executes((c) -> import_stat_to_scoreboard( c.getSource(), StringArgumentType.getString(c, "player"), - ObjectiveArgumentType.getWritableObjective(c, "score"), 1)). + ScoreboardObjectiveArgumentType.getWritableObjective(c, "score"), 1)). then(argument("multiplier", FloatArgumentType.floatArg()). executes((c) -> import_stat_to_scoreboard( c.getSource(), StringArgumentType.getString(c, "player"), - ObjectiveArgumentType.getWritableObjective(c, "score"), + ScoreboardObjectiveArgumentType.getWritableObjective(c, "score"), FloatArgumentType.getFloat(c, "multiplier")) ) ) @@ -119,7 +119,7 @@ public class Stats { if (score < 0) return 0; - ServerScoreboard server_scoreboard = source.getMinecraftServer().getScoreboard(); + ServerScoreboard server_scoreboard = source.getWorld().getServer().getScoreboard(); ScoreboardPlayerScore player_score = server_scoreboard.getPlayerScore(player, objective); @@ -131,21 +131,23 @@ public class Stats { } private static ServerStatHandler get_player_stat_handler(ServerCommandSource source, String player_name) { - ServerPlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name); + ServerPlayerEntity player = source.getWorld().getServer().getPlayerManager().getPlayer(player_name); if (player != null) { return player.getStatHandler(); } // [ ] TODO 1.16 fix test - GameProfile profile = source.getMinecraftServer().getUserCache().findByName(player_name); - if (profile == null) { + Optional opt_profile = source.getWorld().getServer().getUserCache().findByName(player_name); + if (opt_profile.isEmpty()) { Parquet.LOG.debug("Savedata: User not in Usercache"); return null; } + GameProfile profile = opt_profile.get(); + UUID player_uuid = profile.getId(); - File file = source.getMinecraftServer().getSavePath(WorldSavePath.STATS).toFile(); + File file = source.getWorld().getServer().getSavePath(WorldSavePath.STATS).toFile(); File file2 = new File(file, player_uuid + ".json"); if (!file2.exists()) { @@ -153,7 +155,7 @@ public class Stats { return null; } - return new ServerStatHandler(source.getMinecraftServer(), file2); + return new ServerStatHandler(source.getWorld().getServer(), file2); } private static int print_player_stat(ServerCommandSource source, String player, String stat) { diff --git a/src/main/java/re/jag/parquet/commands/TimeDIff.java b/src/main/java/re/jag/parquet/commands/TimeDIff.java index 39ebe93..a1ef76b 100644 --- a/src/main/java/re/jag/parquet/commands/TimeDIff.java +++ b/src/main/java/re/jag/parquet/commands/TimeDIff.java @@ -17,7 +17,7 @@ public class TimeDIff { } private static int dt(ServerCommandSource _source) { - int current = _source.getMinecraftServer().getTicks(); + int current = _source.getWorld().getServer().getTicks(); _source.sendFeedback( new LiteralText( String.valueOf(current - last_server_time)), false) ; last_server_time = current; return 1; diff --git a/src/main/java/re/jag/parquet/dispenser/BucketDispenserBehavior.java b/src/main/java/re/jag/parquet/dispenser/BucketDispenserBehavior.java index ad7a6ca..5195dd3 100644 --- a/src/main/java/re/jag/parquet/dispenser/BucketDispenserBehavior.java +++ b/src/main/java/re/jag/parquet/dispenser/BucketDispenserBehavior.java @@ -1,55 +1,73 @@ package re.jag.parquet.dispenser; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.CauldronBlock; -import net.minecraft.block.DispenserBlock; -import net.minecraft.block.FluidDrainable; +import net.minecraft.block.*; import net.minecraft.block.dispenser.FallibleItemDispenserBehavior; +import net.minecraft.block.dispenser.ItemDispenserBehavior; import net.minecraft.block.entity.DispenserBlockEntity; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; +import net.minecraft.item.FluidModificationItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPointer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; +import net.minecraft.world.event.GameEvent; public class BucketDispenserBehavior extends FallibleItemDispenserBehavior { - public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { - //this.success = false; + private final ItemDispenserBehavior fallbackBehavior = new ItemDispenserBehavior(); + + public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { World world = pointer.getWorld(); + FluidModificationItem bucket_item = (FluidModificationItem) stack.getItem(); Item item; - BlockPos block_pos = pointer.getBlockPos().offset((Direction)pointer.getBlockState().get(DispenserBlock.FACING)); + BlockPos block_pos = pointer.getPos().offset((Direction)pointer.getBlockState().get(DispenserBlock.FACING)); BlockState state = world.getBlockState(block_pos); Block block = state.getBlock(); + + //original if (block instanceof FluidDrainable) { - Fluid fluid = ((FluidDrainable)block).tryDrainFluid(world, block_pos, state); - - if (!(fluid instanceof net.minecraft.fluid.FlowableFluid/*BaseFluid*/)) { + ItemStack itemStack = ((FluidDrainable)block).tryDrainFluid(world, block_pos, state); + if (itemStack.isEmpty()) { return super.dispenseSilently(pointer, stack); + } else { + world.emitGameEvent((Entity)null, GameEvent.FLUID_PICKUP, block_pos); + Item item2 = itemStack.getItem(); + stack.decrement(1); + if (stack.isEmpty()) { + return new ItemStack(item2); + } else { + if (((DispenserBlockEntity)pointer.getBlockEntity()).addToFirstFreeSlot(new ItemStack(item2)) < 0) { + this.fallbackBehavior.dispense(pointer, new ItemStack(item2)); + } + + return stack; + } } - - item = fluid.getBucketItem(); - } else if (block instanceof CauldronBlock) { - if(state.get(CauldronBlock.LEVEL) >= 3) { - ((CauldronBlock)block).setLevel(world, block_pos, state, 0); - //this.success = true; + } + + // New + else if (block instanceof LeveledCauldronBlock) { + if(state.get(LeveledCauldronBlock.LEVEL) >= 3) { + world.setBlockState(block_pos, Blocks.CAULDRON.getDefaultState()); this.setSuccess(true); item = Items.WATER_BUCKET; } else { return stack; } } else { - return super.dispenseSilently(pointer, stack); + return this.fallbackBehavior.dispense(pointer, stack); } stack.decrement(1); if (stack.isEmpty()) return new ItemStack(item); if (((DispenserBlockEntity)pointer.getBlockEntity()).addToFirstFreeSlot(new ItemStack(item)) < 0) - this.dispense(pointer, new ItemStack(item)); + this.fallbackBehavior.dispense(pointer, new ItemStack(item)); return stack; } } diff --git a/src/main/java/re/jag/parquet/dispenser/DyeItemDispenserBehavior.java b/src/main/java/re/jag/parquet/dispenser/DyeItemDispenserBehavior.java index a62a1c9..8f054ca 100644 --- a/src/main/java/re/jag/parquet/dispenser/DyeItemDispenserBehavior.java +++ b/src/main/java/re/jag/parquet/dispenser/DyeItemDispenserBehavior.java @@ -25,7 +25,7 @@ public class DyeItemDispenserBehavior extends FallibleItemDispenserBehavior{ public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { //this.success = false; World world = pointer.getWorld(); - BlockPos block_pos = pointer.getBlockPos().offset((Direction)pointer.getBlockState().get(DispenserBlock.FACING)); + BlockPos block_pos = pointer.getPos().offset((Direction)pointer.getBlockState().get(DispenserBlock.FACING)); BlockState state = world.getBlockState(block_pos); Block block = state.getBlock(); Item item = stack.getItem(); @@ -41,8 +41,8 @@ public class DyeItemDispenserBehavior extends FallibleItemDispenserBehavior{ ItemStack dropped_stack = dropped_stacks.get(0); ItemStack new_stack = new ItemStack(ShulkerBoxBlock.get(((DyeItem)item).getColor())); - if (dropped_stack.hasTag()) { - new_stack.setTag(dropped_stack.getTag().copy()); + if (dropped_stack.hasNbt()) { + new_stack.setNbt(dropped_stack.getNbt().copy()); } world.setBlockState(block_pos, Blocks.AIR.getDefaultState()); diff --git a/src/main/java/re/jag/parquet/dispenser/GlassBottleDispenserBehavior.java b/src/main/java/re/jag/parquet/dispenser/GlassBottleDispenserBehavior.java index a0c5844..24cb409 100644 --- a/src/main/java/re/jag/parquet/dispenser/GlassBottleDispenserBehavior.java +++ b/src/main/java/re/jag/parquet/dispenser/GlassBottleDispenserBehavior.java @@ -1,67 +1,69 @@ package re.jag.parquet.dispenser; -import net.minecraft.block.BeehiveBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.CauldronBlock; -import net.minecraft.block.DispenserBlock; +import net.minecraft.block.*; import net.minecraft.block.dispenser.FallibleItemDispenserBehavior; +import net.minecraft.block.dispenser.ItemDispenserBehavior; import net.minecraft.block.entity.BeehiveBlockEntity; import net.minecraft.block.entity.DispenserBlockEntity; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.potion.PotionUtil; import net.minecraft.potion.Potions; +import net.minecraft.server.world.ServerWorld; import net.minecraft.tag.BlockTags; import net.minecraft.tag.FluidTags; import net.minecraft.util.math.BlockPointer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; +import net.minecraft.world.event.GameEvent; public class GlassBottleDispenserBehavior extends FallibleItemDispenserBehavior { + private final ItemDispenserBehavior fallbackBehavior = new ItemDispenserBehavior(); - //TODO Port over to bucket? - private ItemStack insert_first_free_or_drop(BlockPointer blockPointer, ItemStack emptyBottleStack, ItemStack filledBottleStack) { + private ItemStack tryPutFilledBottle(BlockPointer pointer, ItemStack emptyBottleStack, ItemStack filledBottleStack) { emptyBottleStack.decrement(1); if (emptyBottleStack.isEmpty()) { + pointer.getWorld().emitGameEvent((Entity)null, GameEvent.FLUID_PICKUP, pointer.getPos()); return filledBottleStack.copy(); + } else { + if (((DispenserBlockEntity)pointer.getBlockEntity()).addToFirstFreeSlot(filledBottleStack.copy()) < 0) { + this.fallbackBehavior.dispense(pointer, filledBottleStack.copy()); + } + + return emptyBottleStack; } - if (((DispenserBlockEntity)blockPointer.getBlockEntity()).addToFirstFreeSlot(filledBottleStack.copy()) < 0) { - this.dispense(blockPointer, filledBottleStack.copy()); - } - return emptyBottleStack; } - + public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { //this.success = false; World world = pointer.getWorld(); - BlockPos block_pos = pointer.getBlockPos().offset((Direction)pointer.getBlockState().get(DispenserBlock.FACING)); + BlockPos block_pos = pointer.getPos().offset((Direction)pointer.getBlockState().get(DispenserBlock.FACING)); BlockState state = world.getBlockState(block_pos); Block block = state.getBlock(); - //if (block.matches(BlockTags.BEEHIVES) && ... - if (state.method_27851(BlockTags.BEEHIVES, (abstractBlockState) -> { return abstractBlockState.contains(BeehiveBlock.HONEY_LEVEL); }) - && ((Integer)state.get(BeehiveBlock.HONEY_LEVEL)).intValue() >= 5) { - ((BeehiveBlock)state.getBlock()).takeHoney(world, state, block_pos, null, BeehiveBlockEntity.BeeState.BEE_RELEASED); - //this.success = true; + + // Original Behavior + if (state.isIn(BlockTags.BEEHIVES, (bstate) -> { + return bstate.contains(BeehiveBlock.HONEY_LEVEL); + }) && (Integer)state.get(BeehiveBlock.HONEY_LEVEL) >= 5) { + ((BeehiveBlock)state.getBlock()).takeHoney(world, state, block_pos, (PlayerEntity)null, BeehiveBlockEntity.BeeState.BEE_RELEASED); this.setSuccess(true); - return insert_first_free_or_drop(pointer, stack, new ItemStack(Items.HONEY_BOTTLE)); - } - if (block instanceof CauldronBlock) { - int fill_level = state.get(CauldronBlock.LEVEL); - if(fill_level > 0) { - ((CauldronBlock)block).setLevel(world, block_pos, state, fill_level - 1); - //this.success = true; - this.setSuccess(true); - return insert_first_free_or_drop(pointer, stack, PotionUtil.setPotion( new ItemStack(Items.POTION), Potions.WATER ) ); - } - return stack; + return this.tryPutFilledBottle(pointer, stack, new ItemStack(Items.HONEY_BOTTLE)); + } else if (world.getFluidState(block_pos).isIn(FluidTags.WATER)) { + this.setSuccess(true); + return this.tryPutFilledBottle(pointer, stack, PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER)); } - if (world.getFluidState(block_pos).isIn(FluidTags.WATER)) { - //this.success = true; + + // New behavior + if (block instanceof LeveledCauldronBlock) { + /* TODO Check for Water */ + LeveledCauldronBlock.decrementFluidLevel(state, world, block_pos); this.setSuccess(true); - return insert_first_free_or_drop(pointer, stack, PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER)); - } + return tryPutFilledBottle(pointer, stack, PotionUtil.setPotion( new ItemStack(Items.POTION), Potions.WATER ) ); + } + return super.dispenseSilently(pointer, stack); } } diff --git a/src/main/java/re/jag/parquet/dispenser/MusicDiscDispenserBehavior.java b/src/main/java/re/jag/parquet/dispenser/MusicDiscDispenserBehavior.java index 9d9f109..4d2d037 100644 --- a/src/main/java/re/jag/parquet/dispenser/MusicDiscDispenserBehavior.java +++ b/src/main/java/re/jag/parquet/dispenser/MusicDiscDispenserBehavior.java @@ -15,7 +15,7 @@ public class MusicDiscDispenserBehavior extends FallibleItemDispenserBehavior { protected ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { World world = pointer.getWorld(); Direction direction = (Direction)pointer.getBlockState().get(DispenserBlock.FACING); - BlockPos block_pos = pointer.getBlockPos().offset(direction); + BlockPos block_pos = pointer.getPos().offset(direction); BlockState state = world.getBlockState(block_pos); if (state.isOf(Blocks.JUKEBOX)) { diff --git a/src/main/java/re/jag/parquet/dispenser/PotionDispenserBehavior.java b/src/main/java/re/jag/parquet/dispenser/PotionDispenserBehavior.java index a31ab3e..f326502 100644 --- a/src/main/java/re/jag/parquet/dispenser/PotionDispenserBehavior.java +++ b/src/main/java/re/jag/parquet/dispenser/PotionDispenserBehavior.java @@ -1,10 +1,8 @@ package re.jag.parquet.dispenser; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.CauldronBlock; -import net.minecraft.block.DispenserBlock; +import net.minecraft.block.*; import net.minecraft.block.dispenser.FallibleItemDispenserBehavior; +import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.potion.PotionUtil; @@ -13,28 +11,35 @@ import net.minecraft.util.math.BlockPointer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; +import net.minecraft.world.event.GameEvent; public class PotionDispenserBehavior extends FallibleItemDispenserBehavior { public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { - //this.success = false; World world = pointer.getWorld(); - BlockPos block_pos = pointer.getBlockPos().offset((Direction)pointer.getBlockState().get(DispenserBlock.FACING)); + BlockPos block_pos = pointer.getPos().offset((Direction)pointer.getBlockState().get(DispenserBlock.FACING)); BlockState state = world.getBlockState(block_pos); Block block = state.getBlock(); if (PotionUtil.getPotion(stack) == Potions.WATER) { if (block instanceof CauldronBlock) { - int fill_level = state.get(CauldronBlock.LEVEL); - if(fill_level < 3) { - ((CauldronBlock)block).setLevel(world, block_pos, state, fill_level + 1); - //this.success = true; - this.setSuccess(true); - return new ItemStack(Items.GLASS_BOTTLE, 1); - } - return stack; + world.setBlockState(block_pos, Blocks.WATER_CAULDRON.getDefaultState()); + world.syncWorldEvent(1047, block_pos, 0); + world.emitGameEvent((Entity)null, GameEvent.FLUID_PLACE, block_pos); + + return new ItemStack(Items.GLASS_BOTTLE, 1); + + } else if (block instanceof LeveledCauldronBlock) { + if (((LeveledCauldronBlock) block).isFull(state)) + return stack; + + world.setBlockState(block_pos, (BlockState)state.with(LeveledCauldronBlock.LEVEL, (Integer)state.get(LeveledCauldronBlock.LEVEL) + 1)); + world.syncWorldEvent(1047, block_pos, 0); + this.setSuccess(true); } + return stack; } - return super.dispenseSilently(pointer, stack); + + return super.dispenseSilently(pointer, stack); } } diff --git a/src/main/java/re/jag/parquet/dispenser/ShulkerPlacementDispenserBehavior.java b/src/main/java/re/jag/parquet/dispenser/ShulkerPlacementDispenserBehavior.java index 42c5f10..2671775 100644 --- a/src/main/java/re/jag/parquet/dispenser/ShulkerPlacementDispenserBehavior.java +++ b/src/main/java/re/jag/parquet/dispenser/ShulkerPlacementDispenserBehavior.java @@ -1,11 +1,6 @@ package re.jag.parquet.dispenser; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.CauldronBlock; -import net.minecraft.block.DispenserBlock; -import net.minecraft.block.ShulkerBoxBlock; +import net.minecraft.block.*; import net.minecraft.block.dispenser.BlockPlacementDispenserBehavior; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; @@ -16,37 +11,34 @@ import net.minecraft.util.math.Direction; public class ShulkerPlacementDispenserBehavior extends BlockPlacementDispenserBehavior{ protected ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { - //this.success = false; - Item item = stack.getItem(); if (item instanceof BlockItem) { Direction direction = (Direction)pointer.getBlockState().get(DispenserBlock.FACING); - BlockPos block_pos = pointer.getBlockPos().offset(direction); + BlockPos block_pos = pointer.getPos().offset(direction); Block block = ((BlockItem)item).getBlock(); if (block instanceof ShulkerBoxBlock && !pointer.getWorld().isClient()) { BlockState state = pointer.getWorld().getBlockState(block_pos); - if (state.getBlock() instanceof CauldronBlock) { - int fill_level = state.get(CauldronBlock.LEVEL); - if (fill_level > 0) { - ItemStack itemStack5 = new ItemStack(Blocks.SHULKER_BOX, 1); - if (stack.hasTag()) { - itemStack5.setTag(stack.getTag().copy()); - } - ((CauldronBlock)state.getBlock()).setLevel(pointer.getWorld(), block_pos, state, fill_level - 1); - - //this.success = true; - this.setSuccess(true); - return itemStack5; + Block facing_block = state.getBlock(); + + if (facing_block instanceof LeveledCauldronBlock) { + /* TODO Check for WATER!!!!! */ + + ItemStack itemStack5 = new ItemStack(Blocks.SHULKER_BOX, 1); + + if (stack.hasNbt()) { + itemStack5.setNbt(stack.getNbt().copy()); } - - //fail if cauldron empty - return stack; - } + + LeveledCauldronBlock.decrementFluidLevel(state, pointer.getWorld(), block_pos); + + this.setSuccess(true); + return itemStack5; + } } } - return super.dispenseSilently(pointer, stack); + return super.dispenseSilently(pointer, stack); } } diff --git a/src/main/java/re/jag/parquet/dispenser/WaterBucketDispenserBehavior.java b/src/main/java/re/jag/parquet/dispenser/WaterBucketDispenserBehavior.java index d11e1e5..1f1e41e 100644 --- a/src/main/java/re/jag/parquet/dispenser/WaterBucketDispenserBehavior.java +++ b/src/main/java/re/jag/parquet/dispenser/WaterBucketDispenserBehavior.java @@ -1,10 +1,8 @@ package re.jag.parquet.dispenser; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.CauldronBlock; -import net.minecraft.block.DispenserBlock; +import net.minecraft.block.*; import net.minecraft.block.dispenser.FallibleItemDispenserBehavior; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BucketItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -19,11 +17,10 @@ public class WaterBucketDispenserBehavior extends FallibleItemDispenserBehavior{ //this.success = false; BucketItem bucket_item = (BucketItem)stack.getItem(); - BlockPos block_pos = pointer.getBlockPos().offset((Direction)pointer.getBlockState().get(DispenserBlock.FACING)); + BlockPos block_pos = pointer.getPos().offset((Direction)pointer.getBlockState().get(DispenserBlock.FACING)); World world = pointer.getWorld(); if (bucket_item.placeFluid(null, world, block_pos, null)) { - bucket_item.onEmptied(world, stack, block_pos); - //this.success = true; + bucket_item.onEmptied((PlayerEntity)null, world, stack, block_pos); this.setSuccess(true); return new ItemStack(Items.BUCKET); } @@ -32,12 +29,9 @@ public class WaterBucketDispenserBehavior extends FallibleItemDispenserBehavior{ Block facing_block = state.getBlock(); if ( facing_block instanceof CauldronBlock) { - if (state.get(CauldronBlock.LEVEL) >= 3) { - return stack; - } - ((CauldronBlock)facing_block).setLevel(world, block_pos, state, 3); - - //this.success = true; + world.setBlockState(block_pos, Blocks.WATER_CAULDRON.getDefaultState().with(LeveledCauldronBlock.LEVEL, 3)); + world.syncWorldEvent(1047, block_pos, 0); + this.setSuccess(true); return new ItemStack(Items.BUCKET, 1); } diff --git a/src/main/java/re/jag/parquet/mixin/AbstractTraderEntityMixin.java b/src/main/java/re/jag/parquet/mixin/AbstractTraderEntityMixin.java index c6a9e2e..538e712 100644 --- a/src/main/java/re/jag/parquet/mixin/AbstractTraderEntityMixin.java +++ b/src/main/java/re/jag/parquet/mixin/AbstractTraderEntityMixin.java @@ -20,7 +20,7 @@ public class AbstractTraderEntityMixin { @Inject(method="trade", at = @At("RETURN")) private void onTrade(TradeOffer tradeOffer, CallbackInfo ci) { if ( Parquet.settings.stats_villager_trades && this.customer instanceof ServerPlayerEntity) { - ((ServerPlayerEntity)customer).incrementStat( CustomStats.TRADED.getOrCreateStat( tradeOffer.getMutableSellItem().getItem() ) ); + ((ServerPlayerEntity)customer).incrementStat( CustomStats.TRADED.getOrCreateStat( tradeOffer.getSellItem().getItem() ) ); } } } diff --git a/src/main/java/re/jag/parquet/mixin/FireWorkItemMixin.java b/src/main/java/re/jag/parquet/mixin/FireWorkItemMixin.java index cc8023b..d95f7ff 100644 --- a/src/main/java/re/jag/parquet/mixin/FireWorkItemMixin.java +++ b/src/main/java/re/jag/parquet/mixin/FireWorkItemMixin.java @@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.At; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.FireworkItem; +import net.minecraft.item.FireworkRocketItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; @@ -15,7 +15,7 @@ import net.minecraft.world.World; import net.minecraft.stat.Stats; -@Mixin(FireworkItem.class) +@Mixin(FireworkRocketItem.class) public class FireWorkItemMixin extends Item{ public FireWorkItemMixin(Settings settings) { diff --git a/src/main/java/re/jag/parquet/mixin/MinecraftServerMixin.java b/src/main/java/re/jag/parquet/mixin/MinecraftServerMixin.java index d8a30cf..f6a4a27 100644 --- a/src/main/java/re/jag/parquet/mixin/MinecraftServerMixin.java +++ b/src/main/java/re/jag/parquet/mixin/MinecraftServerMixin.java @@ -5,12 +5,14 @@ import net.minecraft.server.MinecraftServer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(MinecraftServer.class) public class MinecraftServerMixin { + /* @Inject(method = "getServerModName", at = @At("RETURN"), cancellable = true) protected void onGetServerModName(CallbackInfoReturnable cir) { cir.setReturnValue("vanilla++™"); - } + }*/ } diff --git a/src/main/java/re/jag/parquet/mixin/SellMapFactoryMixin.java b/src/main/java/re/jag/parquet/mixin/SellMapFactoryMixin.java index b08cbee..9ff91f6 100644 --- a/src/main/java/re/jag/parquet/mixin/SellMapFactoryMixin.java +++ b/src/main/java/re/jag/parquet/mixin/SellMapFactoryMixin.java @@ -41,7 +41,7 @@ public class SellMapFactoryMixin implements TradeOffers.Factory { BlockPos blockPos = new BlockPos(0,0,0); ItemStack itemStack = FilledMapItem.createMap(serverWorld, blockPos.getX(), blockPos.getZ(), (byte)2, true, true); FilledMapItem.fillExplorationMap(serverWorld, itemStack); - MapState.addDecorationsTag(itemStack, blockPos, "+", this.iconType); + MapState.addDecorationsNbt(itemStack, blockPos, "+", this.iconType); itemStack.setCustomName(new LiteralText("Mojang-award for code quality")); return new TradeOffer(new ItemStack(Items.EMERALD, this.price), new ItemStack(Items.COMPASS), itemStack, this.maxUses, this.experience, 0.2F); } diff --git a/src/main/java/re/jag/parquet/mixin/ServerPlayerEntityMixin.java b/src/main/java/re/jag/parquet/mixin/ServerPlayerEntityMixin.java index 2a96568..b636f2d 100644 --- a/src/main/java/re/jag/parquet/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/re/jag/parquet/mixin/ServerPlayerEntityMixin.java @@ -19,9 +19,9 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.world.World; import re.jag.parquet.interfaces.CameraModeData; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtElement; @Mixin(ServerPlayerEntity.class) public abstract class ServerPlayerEntityMixin extends PlayerEntity implements CameraModeData{ @@ -42,8 +42,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Ca public void teleport(ServerWorld arg, double d, double e, double f, float g, float h) {} @Inject(method="writeCustomDataToTag", at = @At("RETURN")) - private void onWriteCustomDataToTag(CompoundTag arg, CallbackInfo ci) { - arg.put("ParquetSavedPos", (Tag)toListTag(new double[] { saved_x, saved_y, saved_z, saved_yaw, saved_pitch })); + private void onWriteCustomDataToTag(NbtCompound arg, CallbackInfo ci) { + arg.put("ParquetSavedPos", (NbtElement) toNbtList(new double[] { saved_x, saved_y, saved_z, saved_yaw, saved_pitch })); arg.putString("ParquetSavedDimension", this.saved_dimension); @@ -51,8 +51,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Ca } @Inject(method="readCustomDataFromTag", at = @At("RETURN")) - private void onReadCustomDataFromTag(CompoundTag arg, CallbackInfo ci) { - ListTag lv = arg.getList("ParquetSavedPos", 6); + private void onReadCustomDataFromTag(NbtCompound arg, CallbackInfo ci) { + NbtList lv = arg.getList("ParquetSavedPos", 6); this.saved_dimension = arg.getString("ParquetSavedDimension"); @@ -74,8 +74,9 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Ca this.saved_y = getY(); this.saved_z = getZ(); - this.saved_pitch = pitch; - this.saved_yaw = yaw; + + this.saved_pitch = getPitch(); + this.saved_yaw = getYaw(); this.saved_dimension = this.world.getRegistryKey().getValue().toString(); @@ -88,8 +89,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Ca public boolean restoreCameraPosition() { if (this.save_active) { - this.teleport(server.getWorld( RegistryKey.of(Registry.DIMENSION, new Identifier(this.saved_dimension))) , saved_x, saved_y, saved_z, saved_yaw, saved_pitch); - + this.teleport(server.getWorld( RegistryKey.of(Registry.WORLD_KEY, new Identifier(this.saved_dimension))) , saved_x, saved_y, saved_z, saved_yaw, saved_pitch); + this.save_active = false; return true; -- cgit v1.2.3