mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +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);
|
this.setStepSound(soundTypeStone);
|
||||||
|
|
||||||
float f = 1F/16F;
|
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
|
@Override
|
||||||
|
|
|
@ -78,6 +78,10 @@ public class ItemCrafting{
|
||||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemLexicon), new ItemStack(InitItems.itemCanolaSeed), new ItemStack(Items.paper)));
|
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemLexicon), new ItemStack(InitItems.itemCanolaSeed), new ItemStack(Items.paper)));
|
||||||
recipeBook = Util.GetRecipes.lastIRecipe();
|
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
|
//Rice Stuff
|
||||||
if(ConfigCrafting.RICE_GADGETS.isEnabled()){
|
if(ConfigCrafting.RICE_GADGETS.isEnabled()){
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Items.paper, 3),
|
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.tile.TileEntityLaserRelay;
|
||||||
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
|
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
|
||||||
import ellpeck.actuallyadditions.util.ModUtil;
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
|
import ellpeck.actuallyadditions.util.StringUtil;
|
||||||
import ellpeck.actuallyadditions.util.WorldPos;
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -25,29 +26,22 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.Vec3;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
|
public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
|
||||||
|
|
||||||
public ItemLaserWrench(){
|
public ItemLaserWrench(){
|
||||||
this.setMaxStackSize(1);
|
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
|
@Override
|
||||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){
|
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);
|
TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
if(tile instanceof TileEntityLaserRelay && !player.isSneaking()){
|
if(tile instanceof TileEntityLaserRelay){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
if(ItemPhantomConnector.getStoredPosition(stack) == null){
|
if(ItemPhantomConnector.getStoredPosition(stack) == null){
|
||||||
ItemPhantomConnector.storeConnection(stack, x, y, z, world);
|
ItemPhantomConnector.storeConnection(stack, x, y, z, world);
|
||||||
|
@ -55,33 +49,16 @@ public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
WorldPos savedPos = ItemPhantomConnector.getStoredPosition(stack);
|
WorldPos savedPos = ItemPhantomConnector.getStoredPosition(stack);
|
||||||
if(savedPos.getTileEntity() instanceof TileEntityLaserRelay){
|
WorldPos otherPos = new WorldPos(world, x, y, z);
|
||||||
WorldPos otherPos = new WorldPos(world, x, y, z);
|
if(savedPos.getTileEntity() instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){
|
||||||
int distance = (int)Vec3.createVectorHelper(otherPos.getX(), otherPos.getY(), otherPos.getZ()).distanceTo(Vec3.createVectorHelper(savedPos.getX(), savedPos.getY(), savedPos.getZ()));
|
player.addChatComponentMessage(new ChatComponentText("Connected!"));
|
||||||
if(distance <= 15){
|
ItemPhantomConnector.clearStorage(stack);
|
||||||
if(!savedPos.isEqual(otherPos) && savedPos.getWorld() == otherPos.getWorld()){
|
|
||||||
if(LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){
|
|
||||||
player.addChatComponentMessage(new ChatComponentText("Connected!"));
|
|
||||||
ItemPhantomConnector.clearStorage(stack);
|
|
||||||
|
|
||||||
savedPos.update();
|
savedPos.update();
|
||||||
otherPos.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!"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
player.addChatComponentMessage(new ChatComponentText("The Laser Relay you were trying to connect to doesn't exist!"));
|
player.addChatComponentMessage(new ChatComponentText("Couldn't connect!"));
|
||||||
ItemPhantomConnector.clearStorage(stack);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,6 +67,24 @@ public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
|
||||||
return false;
|
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
|
@Override
|
||||||
public boolean getShareTag(){
|
public boolean getShareTag(){
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -26,10 +26,13 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ItemPhantomConnector extends Item implements IActAddItemOrBlock{
|
public class ItemPhantomConnector extends Item implements IActAddItemOrBlock{
|
||||||
|
|
||||||
public ItemPhantomConnector(){
|
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){
|
public static WorldPos getStoredPosition(ItemStack stack){
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
if(tag != null){
|
if(tag != null){
|
||||||
|
|
|
@ -16,6 +16,7 @@ import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
@ -99,6 +100,11 @@ public class LaserRelayConnectionHandler{
|
||||||
* (Puts it into the correct network!)
|
* (Puts it into the correct network!)
|
||||||
*/
|
*/
|
||||||
public boolean addConnection(WorldPos firstRelay, WorldPos secondRelay){
|
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> firstNetwork = this.getNetworkFor(firstRelay);
|
||||||
ArrayList<ConnectionPair> secondNetwork = this.getNetworkFor(secondRelay);
|
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.connected.desc=<Block connected!>
|
||||||
tooltip.actuallyadditions.phantom.stored.desc=<Block stored to this Connector!>
|
tooltip.actuallyadditions.phantom.stored.desc=<Block stored to this Connector!>
|
||||||
tooltip.actuallyadditions.phantom.unbound.desc=The Connection was cleared!
|
tooltip.actuallyadditions.phantom.unbound.desc=The Connection was cleared!
|
||||||
tooltip.actuallyadditions.phantom.inWorld.desc=In World
|
tooltip.actuallyadditions.inWorld.desc=In World
|
||||||
tooltip.actuallyadditions.phantom.boundTo.desc=Bound to
|
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.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.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!
|
tooltip.actuallyadditions.phantom.notConnected.desc=This isn't connected to anything!
|
||||||
|
|
Loading…
Reference in a new issue