Fix a bunch of waterlogging edge cases. Closes #3188

This commit is contained in:
Vincent Lee committed 2020-03-19 21:25:17 -05:00
1 parent 9d99c7184f
commit 24b6f06a80
3 files changed
+22 -4

No files matched your search

@@ -46,6 +46,7 @@ import net.minecraftforge.fml.server.ServerLifecycleHooks;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.item.ItemTwigWand;
import vazkii.botania.common.item.lens.LensPiston;
import vazkii.botania.common.network.PacketBotaniaEffect;
import vazkii.botania.common.network.PacketHandler;
@@ -246,7 +247,7 @@ public class BlockPistonRelay extends BlockMod implements IWandable {
Material destMat = world.getBlockState(destPos.offset(dir)).getMaterial();
if(world.isAirBlock(destPos.offset(dir)) || destMat.isReplaceable()) {
world.setBlockState(destPos, Blocks.AIR.getDefaultState());
world.setBlockState(destPos.offset(dir), srcState);
world.setBlockState(destPos.offset(dir), LensPiston.unWaterlog(srcState));
mappedPositions.put(s, GlobalPos.of(world.getDimension().getType(), destPos.offset(dir)));
}
}
@@ -24,6 +24,7 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.particles.BlockParticleData;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.NonNullList;
@@ -153,7 +154,8 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
TileEntity newTile = block.createTileEntity(state, world);
world.setTileEntity(pos_, newTile);
}
world.destroyBlock(pos_, false);
world.playEvent(2001, pos_, Block.getStateId(state));
world.setBlockState(pos_, Blocks.AIR.getDefaultState());
ItemStack copyLens = new ItemStack(this);
copyLens.getOrCreateTag().putInt(TAG_LEVEL, getShardLevel(shard));
@@ -255,6 +257,10 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
state = NBTUtil.readBlockState(lens.getTag().getCompound(TAG_STATE));
}
if (entity.world.getDimension().doesWaterVaporize() && state.has(BlockStateProperties.WATERLOGGED)) {
state = state.with(BlockStateProperties.WATERLOGGED, false);
}
TileEntity tile = null;
CompoundNBT tilecmp = ItemNBTHelper.getCompound(lens, TAG_TILE, false);
if(tilecmp.contains("id"))
@@ -10,11 +10,13 @@
*/
package vazkii.botania.common.item.lens;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.material.PushReaction;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
@@ -40,8 +42,9 @@ public class LensPiston extends Lens {
if(state.getPushReaction() == PushReaction.NORMAL && state.getBlock() != Blocks.OBSIDIAN
&& state.getBlockHardness(entity.world, pos_) >= 0 && tile == null) {
entity.world.destroyBlock(rtr.getPos(), false);
entity.world.setBlockState(pos_, state, 1 | 2);
entity.world.playEvent(2001, rtr.getPos(), Block.getStateId(state));
entity.world.setBlockState(rtr.getPos(), Blocks.AIR.getDefaultState());
entity.world.setBlockState(pos_, unWaterlog(state));
}
}
}
@@ -50,4 +53,12 @@ public class LensPiston extends Lens {
return dead;
}
public static BlockState unWaterlog(BlockState state) {
if (state.has(BlockStateProperties.WATERLOGGED)) {
return state.with(BlockStateProperties.WATERLOGGED, false);
} else {
return state;
}
}
}