mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
only delete connected conveyors, and only when crouching
This commit is contained in:
parent
6d67a31dff
commit
0338c6a8fd
@ -35,6 +35,16 @@ public class BlockConveyorChute extends BlockConveyorBase implements IToolable {
|
|||||||
return super.getTravelLocation(world, x, y, z, itemPos, speed);
|
return super.getTravelLocation(world, x, y, z, itemPos, speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ForgeDirection getInputDirection(World world, int x, int y, int z) {
|
||||||
|
return ForgeDirection.UP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ForgeDirection getOutputDirection(World world, int x, int y, int z) {
|
||||||
|
return ForgeDirection.DOWN;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForgeDirection getTravelDirection(World world, int x, int y, int z, Vec3 itemPos) {
|
public ForgeDirection getTravelDirection(World world, int x, int y, int z, Vec3 itemPos) {
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,16 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
|
|
||||||
public class BlockConveyorLift extends BlockConveyorBase implements IToolable {
|
public class BlockConveyorLift extends BlockConveyorBase implements IToolable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ForgeDirection getInputDirection(World world, int x, int y, int z) {
|
||||||
|
return ForgeDirection.DOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ForgeDirection getOutputDirection(World world, int x, int y, int z) {
|
||||||
|
return ForgeDirection.UP;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForgeDirection getTravelDirection(World world, int x, int y, int z, Vec3 itemPos) {
|
public ForgeDirection getTravelDirection(World world, int x, int y, int z, Vec3 itemPos) {
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
package com.hbm.items.tool;
|
package com.hbm.items.tool;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import com.hbm.blocks.ILookOverlay;
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.blocks.network.BlockConveyorBase;
|
import com.hbm.blocks.network.BlockConveyorBase;
|
||||||
import com.hbm.blocks.network.BlockConveyorBendable;
|
import com.hbm.blocks.network.BlockConveyorBendable;
|
||||||
import com.hbm.blocks.network.BlockCraneBase;
|
import com.hbm.blocks.network.BlockCraneBase;
|
||||||
|
import com.hbm.main.MainRegistry;
|
||||||
import com.hbm.render.util.RenderOverhead;
|
import com.hbm.render.util.RenderOverhead;
|
||||||
import com.hbm.util.I18nUtil;
|
import com.hbm.util.I18nUtil;
|
||||||
import com.hbm.wiaj.WorldInAJar;
|
import com.hbm.wiaj.WorldInAJar;
|
||||||
@ -32,11 +35,12 @@ import net.minecraft.util.MovingObjectPosition;
|
|||||||
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
|
|
||||||
public class ItemConveyorWand extends Item {
|
public class ItemConveyorWand extends Item implements ILookOverlay {
|
||||||
|
|
||||||
public ItemConveyorWand() {
|
public ItemConveyorWand() {
|
||||||
setHasSubtypes(true);
|
setHasSubtypes(true);
|
||||||
@ -307,6 +311,8 @@ public class ItemConveyorWand extends Item {
|
|||||||
// In creative, auto delete connected conveyors
|
// In creative, auto delete connected conveyors
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer playerEntity) {
|
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer playerEntity) {
|
||||||
|
if(!playerEntity.isSneaking()) return false;
|
||||||
|
|
||||||
World world = playerEntity.worldObj;
|
World world = playerEntity.worldObj;
|
||||||
Block block = world.getBlock(x, y, z);
|
Block block = world.getBlock(x, y, z);
|
||||||
|
|
||||||
@ -316,9 +322,11 @@ public class ItemConveyorWand extends Item {
|
|||||||
EntityPlayerMP player = (EntityPlayerMP) playerEntity;
|
EntityPlayerMP player = (EntityPlayerMP) playerEntity;
|
||||||
|
|
||||||
if(!world.isRemote && block instanceof BlockConveyorBase) {
|
if(!world.isRemote && block instanceof BlockConveyorBase) {
|
||||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
BlockConveyorBase conveyor = (BlockConveyorBase) block;
|
||||||
breakExtra(world, player, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, 32);
|
ForgeDirection input = conveyor.getInputDirection(world, x, y, z);
|
||||||
}
|
ForgeDirection output = conveyor.getOutputDirection(world, x, y, z);
|
||||||
|
breakExtra(world, player, x + input.offsetX, y + input.offsetY, z + input.offsetZ, 32);
|
||||||
|
breakExtra(world, player, x + output.offsetX, y + output.offsetY, z + output.offsetZ, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -332,6 +340,10 @@ public class ItemConveyorWand extends Item {
|
|||||||
int meta = world.getBlockMetadata(x, y, z);
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
if(!(block instanceof BlockConveyorBase)) return;
|
if(!(block instanceof BlockConveyorBase)) return;
|
||||||
|
|
||||||
|
BlockConveyorBase conveyor = (BlockConveyorBase) block;
|
||||||
|
ForgeDirection input = conveyor.getInputDirection(world, x, y, z);
|
||||||
|
ForgeDirection output = conveyor.getOutputDirection(world, x, y, z);
|
||||||
|
|
||||||
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
|
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
|
||||||
if(event.isCanceled())
|
if(event.isCanceled())
|
||||||
return;
|
return;
|
||||||
@ -342,10 +354,8 @@ public class ItemConveyorWand extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
||||||
|
breakExtra(world, player, x + input.offsetX, y + input.offsetY, z + input.offsetZ, depth);
|
||||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
breakExtra(world, player, x + output.offsetX, y + output.offsetY, z + output.offsetZ, depth);
|
||||||
breakExtra(world, player, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, depth);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempts to construct a conveyor between two points, including bends, lifts, and chutes
|
// attempts to construct a conveyor between two points, including bends, lifts, and chutes
|
||||||
@ -392,7 +402,7 @@ public class ItemConveyorWand extends Item {
|
|||||||
ForgeDirection horDir = dir == ForgeDirection.UP || dir == ForgeDirection.DOWN ? ForgeDirection.getOrientation(getFacingMeta(player)).getOpposite() : dir;
|
ForgeDirection horDir = dir == ForgeDirection.UP || dir == ForgeDirection.DOWN ? ForgeDirection.getOrientation(getFacingMeta(player)).getOpposite() : dir;
|
||||||
|
|
||||||
// Initial dropdown to floor level, if possible
|
// Initial dropdown to floor level, if possible
|
||||||
if(y > ty) {
|
if(hasVertical && y > ty) {
|
||||||
if(routeWorld.getBlock(x, y - 1, z).isReplaceable(routeWorld, x, y - 1, z)) {
|
if(routeWorld.getBlock(x, y - 1, z).isReplaceable(routeWorld, x, y - 1, z)) {
|
||||||
dir = ForgeDirection.DOWN;
|
dir = ForgeDirection.DOWN;
|
||||||
}
|
}
|
||||||
@ -492,4 +502,18 @@ public class ItemConveyorWand extends Item {
|
|||||||
return Math.abs(x1 - x2) + Math.abs(y1 - y2) + Math.abs(z1 - z2);
|
return Math.abs(x1 - x2) + Math.abs(y1 - y2) + Math.abs(z1 - z2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||||
|
EntityPlayer player = MainRegistry.proxy.me();
|
||||||
|
if(player == null || !player.isSneaking()) return;
|
||||||
|
|
||||||
|
Block block = world.getBlock(x, y, z);
|
||||||
|
if(block instanceof BlockConveyorBase) {
|
||||||
|
List<String> text = new ArrayList<>();
|
||||||
|
text.add("Break whole conveyor line");
|
||||||
|
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(block.getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user