mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Fix #3086
This commit is contained in:
1 parent
1d4616e689
commit
967e0888ec
1 file changed
+18
-1
@@ -24,6 +24,8 @@ import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
@@ -185,7 +187,7 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
|
||||
|
||||
if(player.canPlayerEdit(pos, side, stack)
|
||||
&& (!(block instanceof CommandBlockBlock) || player.canUseCommandBlock())) {
|
||||
BlockState newState = state.rotate(world, pos, Rotation.CLOCKWISE_90);
|
||||
BlockState newState = rotate(state, side.getAxis());
|
||||
if(newState != state) {
|
||||
world.setBlockState(pos, newState);
|
||||
return ActionResultType.SUCCESS;
|
||||
@@ -226,6 +228,21 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
private static BlockState rotate(BlockState old, Direction.Axis axis) {
|
||||
for (IProperty<?> prop : old.getProperties()) {
|
||||
if (prop.getName().equals("facing") && prop.getValueClass() == Direction.class) {
|
||||
IProperty<Direction> facingProp = (IProperty<Direction>) prop;
|
||||
|
||||
Direction newDir = old.get(facingProp).rotateAround(axis);
|
||||
if (facingProp.getAllowedValues().contains(newDir)) {
|
||||
return old.with(facingProp, newDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return old.rotate(Rotation.CLOCKWISE_90);
|
||||
}
|
||||
|
||||
public static void doParticleBeamWithOffset(World world, BlockPos orig, BlockPos end) {
|
||||
Vec3d origOffset = world.getBlockState(orig).getOffset(world, orig);
|
||||
Vector3 vorig = new Vector3(orig.getX() + origOffset.getX() + 0.5, orig.getY() + origOffset.getY() + 0.5, orig.getZ() + origOffset.getZ() + 0.5);
|
||||
|
||||
Reference in new issue
Block a user