mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Tweaked Laser Wrench & Phantom Connector
This commit is contained in:
parent
2d48931421
commit
d3ff196ec0
6 changed files with 65 additions and 38 deletions
|
@ -36,7 +36,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IActAddItemOr
|
|||
this.setStepSound(soundTypeStone);
|
||||
|
||||
float f = 1F/16F;
|
||||
this.setBlockBounds(3*f, 0F, 3*f, 1-3*f, 1F, 1-3*f);
|
||||
this.setBlockBounds(2*f, 0F, 2*f, 1-2*f, 1-1*f, 1-2*f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -78,6 +78,10 @@ public class ItemCrafting{
|
|||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemLexicon), new ItemStack(InitItems.itemCanolaSeed), new ItemStack(Items.paper)));
|
||||
recipeBook = Util.GetRecipes.lastIRecipe();
|
||||
|
||||
//Clearing NBT Storage
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemLaserWrench), new ItemStack(InitItems.itemLaserWrench));
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemPhantomConnector), new ItemStack(InitItems.itemPhantomConnector));
|
||||
|
||||
//Rice Stuff
|
||||
if(ConfigCrafting.RICE_GADGETS.isEnabled()){
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Items.paper, 3),
|
||||
|
|
|
@ -16,6 +16,7 @@ import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler;
|
|||
import ellpeck.actuallyadditions.tile.TileEntityLaserRelay;
|
||||
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -25,29 +26,22 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
|
||||
|
||||
public ItemLaserWrench(){
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){
|
||||
if(player.isSneaking() && !world.isRemote){
|
||||
ItemPhantomConnector.clearStorage(stack);
|
||||
player.addChatComponentMessage(new ChatComponentText("Storage cleared!"));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityLaserRelay && !player.isSneaking()){
|
||||
if(tile instanceof TileEntityLaserRelay){
|
||||
if(!world.isRemote){
|
||||
if(ItemPhantomConnector.getStoredPosition(stack) == null){
|
||||
ItemPhantomConnector.storeConnection(stack, x, y, z, world);
|
||||
|
@ -55,33 +49,16 @@ public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
|
|||
}
|
||||
else{
|
||||
WorldPos savedPos = ItemPhantomConnector.getStoredPosition(stack);
|
||||
if(savedPos.getTileEntity() instanceof TileEntityLaserRelay){
|
||||
WorldPos otherPos = new WorldPos(world, x, y, z);
|
||||
int distance = (int)Vec3.createVectorHelper(otherPos.getX(), otherPos.getY(), otherPos.getZ()).distanceTo(Vec3.createVectorHelper(savedPos.getX(), savedPos.getY(), savedPos.getZ()));
|
||||
if(distance <= 15){
|
||||
if(!savedPos.isEqual(otherPos) && savedPos.getWorld() == otherPos.getWorld()){
|
||||
if(LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){
|
||||
player.addChatComponentMessage(new ChatComponentText("Connected!"));
|
||||
ItemPhantomConnector.clearStorage(stack);
|
||||
WorldPos otherPos = new WorldPos(world, x, y, z);
|
||||
if(savedPos.getTileEntity() instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){
|
||||
player.addChatComponentMessage(new ChatComponentText("Connected!"));
|
||||
ItemPhantomConnector.clearStorage(stack);
|
||||
|
||||
savedPos.update();
|
||||
otherPos.update();
|
||||
}
|
||||
else{
|
||||
player.addChatComponentMessage(new ChatComponentText("Couldn't connect!"));
|
||||
}
|
||||
}
|
||||
else{
|
||||
player.addChatComponentMessage(new ChatComponentText("Can't connect a Laser Relay to itself!"));
|
||||
}
|
||||
}
|
||||
else{
|
||||
player.addChatComponentMessage(new ChatComponentText("Too far away! Distance is "+distance+ "blocks!"));
|
||||
}
|
||||
savedPos.update();
|
||||
otherPos.update();
|
||||
}
|
||||
else{
|
||||
player.addChatComponentMessage(new ChatComponentText("The Laser Relay you were trying to connect to doesn't exist!"));
|
||||
ItemPhantomConnector.clearStorage(stack);
|
||||
player.addChatComponentMessage(new ChatComponentText("Couldn't connect!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +67,24 @@ public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||
WorldPos coords = ItemPhantomConnector.getStoredPosition(stack);
|
||||
if(coords != null){
|
||||
World world = coords.getWorld();
|
||||
if(world != null){
|
||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
|
||||
list.add("X: "+coords.getX());
|
||||
list.add("Y: "+coords.getY());
|
||||
list.add("Z: "+coords.getZ());
|
||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".inWorld.desc")+" "+world.provider.dimensionId);
|
||||
list.add(EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".clearStorage.desc"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShareTag(){
|
||||
return true;
|
||||
|
|
|
@ -26,10 +26,13 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPhantomConnector extends Item implements IActAddItemOrBlock{
|
||||
|
||||
public ItemPhantomConnector(){
|
||||
|
@ -73,6 +76,24 @@ public class ItemPhantomConnector extends Item implements IActAddItemOrBlock{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||
WorldPos coords = getStoredPosition(stack);
|
||||
if(coords != null){
|
||||
World world = coords.getWorld();
|
||||
if(world != null){
|
||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
|
||||
list.add("X: "+coords.getX());
|
||||
list.add("Y: "+coords.getY());
|
||||
list.add("Z: "+coords.getZ());
|
||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".inWorld.desc")+" "+world.provider.dimensionId);
|
||||
list.add(EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".clearStorage.desc"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static WorldPos getStoredPosition(ItemStack stack){
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
if(tag != null){
|
||||
|
|
|
@ -16,6 +16,7 @@ import ellpeck.actuallyadditions.util.WorldPos;
|
|||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
@ -99,6 +100,11 @@ public class LaserRelayConnectionHandler{
|
|||
* (Puts it into the correct network!)
|
||||
*/
|
||||
public boolean addConnection(WorldPos firstRelay, WorldPos secondRelay){
|
||||
int distance = (int)Vec3.createVectorHelper(firstRelay.getX(), firstRelay.getY(), firstRelay.getZ()).distanceTo(Vec3.createVectorHelper(secondRelay.getX(), secondRelay.getY(), secondRelay.getZ()));
|
||||
if(distance > 15 || firstRelay.isEqual(secondRelay) || firstRelay.getWorld() != secondRelay.getWorld()){
|
||||
return false;
|
||||
}
|
||||
|
||||
ArrayList<ConnectionPair> firstNetwork = this.getNetworkFor(firstRelay);
|
||||
ArrayList<ConnectionPair> secondNetwork = this.getNetworkFor(secondRelay);
|
||||
|
||||
|
|
|
@ -276,8 +276,9 @@ tooltip.actuallyadditions.onSuffix.desc=On
|
|||
tooltip.actuallyadditions.phantom.connected.desc=<Block connected!>
|
||||
tooltip.actuallyadditions.phantom.stored.desc=<Block stored to this Connector!>
|
||||
tooltip.actuallyadditions.phantom.unbound.desc=The Connection was cleared!
|
||||
tooltip.actuallyadditions.phantom.inWorld.desc=In World
|
||||
tooltip.actuallyadditions.phantom.boundTo.desc=Bound to
|
||||
tooltip.actuallyadditions.inWorld.desc=In World
|
||||
tooltip.actuallyadditions.boundTo.desc=Bound to
|
||||
tooltip.actuallyadditions.clearStorage.desc=Place in Crafting Grid to clear storage!
|
||||
tooltip.actuallyadditions.phantom.connectedRange.desc=The Connection is fine and working.
|
||||
tooltip.actuallyadditions.phantom.connectedNoRange.desc=The Connection is obstructed: It is either not in Range, not in loaded Chunks or not the right type of Block for this Phantom Device.
|
||||
tooltip.actuallyadditions.phantom.notConnected.desc=This isn't connected to anything!
|
||||
|
|
Loading…
Reference in a new issue