Some fixes to linking

This commit is contained in:
Calclavia 2014-01-28 17:26:40 +08:00
parent c37abd0ee5
commit 053236fa1f
5 changed files with 43 additions and 23 deletions

View file

@ -11,12 +11,13 @@ import org.modstats.ModstatInfo;
import org.modstats.Modstats;
import resonantinduction.core.handler.FluidEventHandler;
import resonantinduction.core.handler.LinkEventHandler;
import resonantinduction.core.handler.ToolModeLink;
import resonantinduction.core.prefab.part.PacketMultiPart;
import resonantinduction.core.resource.ResourceGenerator;
import resonantinduction.core.resource.fluid.BlockFluidMixture;
import resonantinduction.core.resource.fluid.TileLiquidMixture;
import resonantinduction.core.resource.item.ItemOreResource;
import calclavia.components.tool.ToolMode;
import calclavia.lib.content.ContentRegistry;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.network.PacketTile;
@ -81,11 +82,12 @@ public class ResonantInduction
ResonantInduction.LOGGER.setParent(FMLLog.getLogger());
NetworkRegistry.instance().registerGuiHandler(this, proxy);
Modstats.instance().getReporter().registerMod(this);
ToolMode.REGISTRY.add(new ToolModeLink());
Settings.load();
// Register Forge Events
MinecraftForge.EVENT_BUS.register(ResourceGenerator.INSTANCE);
MinecraftForge.EVENT_BUS.register(new LinkEventHandler());
MinecraftForge.EVENT_BUS.register(new FluidEventHandler());
fluidMixture = new Fluid("water");

View file

@ -3,50 +3,66 @@
*/
package resonantinduction.core.handler;
import calclavia.components.tool.ToolMode;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import universalelectricity.api.vector.VectorWorld;
import calclavia.components.event.MultitoolEvent;
import codechicken.multipart.ControlKeyModifer;
/**
* @author Calclavia
*/
public class LinkEventHandler
public class ToolModeLink extends ToolMode
{
@ForgeSubscribe
public void linkEvent(MultitoolEvent evt)
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
if (ControlKeyModifer.isControlDown(evt.player))
{
TileEntity tile = evt.world.getBlockTileEntity(evt.x, evt.y, evt.z);
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof ILinkable && this.hasLink(evt.toolStack))
if (ControlKeyModifer.isControlDown(player))
{
if (tile instanceof ILinkable)
{
if (!evt.world.isRemote)
if (!world.isRemote)
{
if (((ILinkable) tile).onLink(evt.player, this.getLink(evt.toolStack)))
if (((ILinkable) tile).onLink(player, this.getLink(stack)))
{
this.clearLink(evt.toolStack);
evt.player.addChatMessage("Link cleared.");
clearLink(stack);
player.addChatMessage("Link cleared.");
return true;
}
}
evt.setResult(Result.DENY);
}
else
}
if (!world.isRemote)
{
player.addChatMessage("Set link to block [" + x + ", " + y + ", " + z + "], Dimension: '" + world.provider.getDimensionName() + "'");
setLink(stack, new VectorWorld(world, x, y, z));
if (tile instanceof ILinkable)
{
if (!evt.world.isRemote)
if (!world.isRemote)
{
evt.player.addChatMessage("Set link to block [" + evt.x + ", " + evt.y + ", " + evt.z + "], Dimension: '" + evt.world.provider.getDimensionName() + "'");
this.setLink(evt.toolStack, new VectorWorld(evt.world, evt.x, evt.y, evt.z));
((ILinkable) tile).onLink(player, this.getLink(stack));
}
}
evt.setCanceled(true);
return true;
}
return false;
}
@Override
public String getName()
{
return "toolmode.link.name";
}
public boolean hasLink(ItemStack itemStack)
@ -78,4 +94,5 @@ public class LinkEventHandler
{
itemStack.getTagCompound().removeTag("link");
}
}

View file

@ -32,7 +32,7 @@ public class BlockBattery extends BlockIOBase implements ITileEntityProvider
public BlockBattery()
{
super("battery", Settings.getNextBlockID());
this.setTextureName(Reference.PREFIX + "machine");
this.setTextureName(Reference.PREFIX + "material_metal_side");
}
@Override

View file

@ -94,7 +94,7 @@ public class PartGearShaft extends PartMechanical
IMechanical instance = (IMechanical) ((IMechanical) checkTile).getInstance(checkDir.getOpposite());
// Only connect to shafts outside of this block space.
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this) && instance instanceof PartGearShaft)
if (instance != null && instance != this && instance instanceof PartGearShaft && instance.canConnect(checkDir.getOpposite(), this))
{
connections[checkDir.ordinal()] = instance;
getNetwork().merge(instance.getNetwork());

View file

@ -8,6 +8,7 @@ meta.resonantinduction.description=Resonant Induction is a Minecraft mod focusin
meta.resonantinduction.credits=Visit website for credits.
fluid.mixture=Mixture
toolmode.link.name=Linking
### Core
misc.resonantinduction.ingot=Ingot