Commiting a chunk of code
This commit is contained in:
parent
85e1a62c5a
commit
b048fa280d
|
@ -0,0 +1,38 @@
|
|||
package com.pahimar.ee3.client.handler;
|
||||
|
||||
import com.pahimar.ee3.item.ItemMatterPickAxe;
|
||||
import com.pahimar.ee3.reference.ToolMode;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class DrawBlockHighlightEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event)
|
||||
{
|
||||
if (event.currentItem != null)
|
||||
{
|
||||
if (event.currentItem.getItem() instanceof ItemMatterPickAxe && event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
ToolMode toolMode = ((ItemMatterPickAxe) event.currentItem.getItem()).getCurrentToolMode(event.currentItem);
|
||||
|
||||
if (toolMode == ToolMode.SINGLE)
|
||||
{
|
||||
|
||||
}
|
||||
else if (toolMode == ToolMode.WIDE)
|
||||
{
|
||||
|
||||
}
|
||||
else if (toolMode == ToolMode.TALL)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package com.pahimar.ee3.handler;
|
|||
|
||||
import com.pahimar.ee3.client.gui.inventory.*;
|
||||
import com.pahimar.ee3.inventory.*;
|
||||
import com.pahimar.ee3.reference.GuiIds;
|
||||
import com.pahimar.ee3.reference.GuiId;
|
||||
import com.pahimar.ee3.tileentity.*;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -13,31 +13,31 @@ public class GuiHandler implements IGuiHandler
|
|||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
if (id == GuiIds.ALCHEMICAL_CHEST)
|
||||
if (id == GuiId.ALCHEMICAL_CHEST.ordinal())
|
||||
{
|
||||
TileEntityAlchemicalChest tileEntityAlchemicalChest = (TileEntityAlchemicalChest) world.getTileEntity(x, y, z);
|
||||
return new ContainerAlchemicalChest(player.inventory, tileEntityAlchemicalChest);
|
||||
}
|
||||
else if (id == GuiIds.GLASS_BELL)
|
||||
else if (id == GuiId.GLASS_BELL.ordinal())
|
||||
{
|
||||
TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y, z);
|
||||
return new ContainerGlassBell(player.inventory, tileEntityGlassBell);
|
||||
}
|
||||
else if (id == GuiIds.ALCHEMICAL_BAG)
|
||||
else if (id == GuiId.ALCHEMICAL_BAG.ordinal())
|
||||
{
|
||||
return new ContainerAlchemicalBag(player, new InventoryAlchemicalBag(player.getHeldItem()));
|
||||
}
|
||||
else if (id == GuiIds.CALCINATOR)
|
||||
else if (id == GuiId.CALCINATOR.ordinal())
|
||||
{
|
||||
TileEntityCalcinator tileEntityCalcinator = (TileEntityCalcinator) world.getTileEntity(x, y, z);
|
||||
return new ContainerCalcinator(player.inventory, tileEntityCalcinator);
|
||||
}
|
||||
else if (id == GuiIds.ALUDEL)
|
||||
else if (id == GuiId.ALUDEL.ordinal())
|
||||
{
|
||||
TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z);
|
||||
return new ContainerAludel(player.inventory, tileEntityAludel);
|
||||
}
|
||||
else if (id == GuiIds.RESEARCH_STATION)
|
||||
else if (id == GuiId.RESEARCH_STATION.ordinal())
|
||||
{
|
||||
TileEntityResearchStation tileEntityResearchStation = (TileEntityResearchStation) world.getTileEntity(x, y, z);
|
||||
return new ContainerResearchStation(player.inventory, tileEntityResearchStation);
|
||||
|
@ -49,31 +49,31 @@ public class GuiHandler implements IGuiHandler
|
|||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
if (id == GuiIds.ALCHEMICAL_CHEST)
|
||||
if (id == GuiId.ALCHEMICAL_CHEST.ordinal())
|
||||
{
|
||||
TileEntityAlchemicalChest tileEntityAlchemicalChest = (TileEntityAlchemicalChest) world.getTileEntity(x, y, z);
|
||||
return new GuiAlchemicalChest(player.inventory, tileEntityAlchemicalChest);
|
||||
}
|
||||
else if (id == GuiIds.GLASS_BELL)
|
||||
else if (id == GuiId.GLASS_BELL.ordinal())
|
||||
{
|
||||
TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y, z);
|
||||
return new GuiGlassBell(player.inventory, tileEntityGlassBell);
|
||||
}
|
||||
else if (id == GuiIds.ALCHEMICAL_BAG)
|
||||
else if (id == GuiId.ALCHEMICAL_BAG.ordinal())
|
||||
{
|
||||
return new GuiAlchemicalBag(player, new InventoryAlchemicalBag(player.getHeldItem()));
|
||||
}
|
||||
else if (id == GuiIds.CALCINATOR)
|
||||
else if (id == GuiId.CALCINATOR.ordinal())
|
||||
{
|
||||
TileEntityCalcinator tileEntityCalcinator = (TileEntityCalcinator) world.getTileEntity(x, y, z);
|
||||
return new GuiCalcinator(player.inventory, tileEntityCalcinator);
|
||||
}
|
||||
else if (id == GuiIds.ALUDEL)
|
||||
else if (id == GuiId.ALUDEL.ordinal())
|
||||
{
|
||||
TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z);
|
||||
return new GuiAludel(player.inventory, tileEntityAludel);
|
||||
}
|
||||
else if (id == GuiIds.RESEARCH_STATION)
|
||||
else if (id == GuiId.RESEARCH_STATION.ordinal())
|
||||
{
|
||||
TileEntityResearchStation tileEntityResearchStation = (TileEntityResearchStation) world.getTileEntity(x, y, z);
|
||||
return new GuiResearchStation(player.inventory, tileEntityResearchStation);
|
||||
|
|
17
src/main/java/com/pahimar/ee3/item/IModalTool.java
Normal file
17
src/main/java/com/pahimar/ee3/item/IModalTool.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.ToolMode;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IModalTool
|
||||
{
|
||||
public abstract List<ToolMode> getAvailableToolModes();
|
||||
|
||||
public abstract ToolMode getCurrentToolMode(ItemStack itemStack);
|
||||
|
||||
public abstract void setToolMode(ItemStack itemStack, ToolMode toolMode);
|
||||
|
||||
public abstract void changeToolMode(ItemStack itemStack);
|
||||
}
|
|
@ -1,10 +1,8 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.creativetab.CreativeTab;
|
||||
import com.pahimar.ee3.reference.Key;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.reference.Sounds;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import com.pahimar.ee3.reference.*;
|
||||
import com.pahimar.ee3.util.LogHelper;
|
||||
import com.pahimar.ee3.util.NBTHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -14,9 +12,13 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
public class ItemMatterPickAxe extends ItemPickaxe implements IKeyBound, IChargeable
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemMatterPickAxe extends ItemPickaxe implements IKeyBound, IChargeable, IModalTool
|
||||
{
|
||||
private short maxChargeLevel;
|
||||
|
||||
|
@ -87,6 +89,17 @@ public class ItemMatterPickAxe extends ItemPickaxe implements IKeyBound, ICharge
|
|||
return super.getDigSpeed(itemStack, block, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
LogHelper.info("Right click with the Dark Matter Pickaxe");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
|
@ -150,5 +163,51 @@ public class ItemMatterPickAxe extends ItemPickaxe implements IKeyBound, ICharge
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (key == Key.EXTRA)
|
||||
{
|
||||
changeToolMode(itemStack);
|
||||
LogHelper.info(getCurrentToolMode(itemStack));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ToolMode> getAvailableToolModes()
|
||||
{
|
||||
return Arrays.asList(ToolMode.SINGLE, ToolMode.WIDE, ToolMode.TALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolMode getCurrentToolMode(ItemStack itemStack)
|
||||
{
|
||||
if (NBTHelper.getShort(itemStack, Names.NBT.MODE) < ToolMode.TYPES.length)
|
||||
{
|
||||
return ToolMode.TYPES[NBTHelper.getShort(itemStack, Names.NBT.MODE)];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToolMode(ItemStack itemStack, ToolMode toolMode)
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.MODE, (short) toolMode.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeToolMode(ItemStack itemStack)
|
||||
{
|
||||
ToolMode currentToolMode = getCurrentToolMode(itemStack);
|
||||
|
||||
if (getAvailableToolModes().contains(currentToolMode))
|
||||
{
|
||||
if (getAvailableToolModes().indexOf(currentToolMode) == getAvailableToolModes().size() - 1)
|
||||
{
|
||||
setToolMode(itemStack, getAvailableToolModes().get(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
setToolMode(itemStack, getAvailableToolModes().get(getAvailableToolModes().indexOf(currentToolMode) + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.pahimar.ee3.proxy;
|
||||
|
||||
import com.pahimar.ee3.client.configuration.ClientConfiguration;
|
||||
import com.pahimar.ee3.client.handler.DrawBlockHighlightEventHandler;
|
||||
import com.pahimar.ee3.client.handler.ItemTooltipEventHandler;
|
||||
import com.pahimar.ee3.client.handler.KeyInputEventHandler;
|
||||
import com.pahimar.ee3.client.renderer.item.*;
|
||||
|
@ -26,6 +27,7 @@ public class ClientProxy extends CommonProxy
|
|||
super.registerEventHandlers();
|
||||
FMLCommonHandler.instance().bus().register(new KeyInputEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new ItemTooltipEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new DrawBlockHighlightEventHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
6
src/main/java/com/pahimar/ee3/reference/GuiId.java
Normal file
6
src/main/java/com/pahimar/ee3/reference/GuiId.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package com.pahimar.ee3.reference;
|
||||
|
||||
public enum GuiId
|
||||
{
|
||||
PORTABLE_CRAFTING, CALCINATOR, ALUDEL, ALCHEMICAL_CHEST, ALCHEMICAL_BAG, GLASS_BELL, RESEARCH_STATION;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.pahimar.ee3.reference;
|
||||
|
||||
public final class GuiIds
|
||||
{
|
||||
public static final int PORTABLE_CRAFTING = 0;
|
||||
public static final int CALCINATOR = 1;
|
||||
public static final int ALUDEL = 2;
|
||||
public static final int ALCHEMICAL_CHEST = 3;
|
||||
public static final int ALCHEMICAL_BAG = 4;
|
||||
public static final int GLASS_BELL = 5;
|
||||
public static final int RESEARCH_STATION = 6;
|
||||
}
|
8
src/main/java/com/pahimar/ee3/reference/ToolMode.java
Normal file
8
src/main/java/com/pahimar/ee3/reference/ToolMode.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package com.pahimar.ee3.reference;
|
||||
|
||||
public enum ToolMode
|
||||
{
|
||||
SINGLE, WIDE, TALL, SQUARE, CUBE;
|
||||
|
||||
public static final ToolMode[] TYPES = ToolMode.values();
|
||||
}
|
Loading…
Reference in a new issue