feat: commit changes (might contain bugs)
This commit is contained in:
parent
8c3c9a6fde
commit
c4637fff54
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,6 +4,7 @@
|
|||
/gradle
|
||||
/gradlew
|
||||
/gradlew.bat
|
||||
/off
|
||||
|
||||
## ForgeGradle
|
||||
/run
|
||||
|
|
|
@ -35,11 +35,16 @@ repositories {
|
|||
name = "jitpack"
|
||||
url = "https://jitpack.io"
|
||||
}
|
||||
/* flatDir {
|
||||
dirs 'libs'
|
||||
}*/
|
||||
}
|
||||
dependencies {
|
||||
implementation "com.github.GTNewHorizons:NotEnoughItems:master-SNAPSHOT:dev"
|
||||
implementation "com.github.GTNewHorizons:EnderStorage:master-SNAPSHOT:dev"
|
||||
implementation "com.github.GTNewHorizons:waila:master-SNAPSHOT:dev"
|
||||
|
||||
// implementation "mozeintel:ProjectE:1.7.10-PE1.10.1"
|
||||
}
|
||||
|
||||
ext.configFile = file "build.properties"
|
||||
|
|
|
@ -102,6 +102,7 @@ public class EquivalentExchange3
|
|||
|
||||
CraftingHandler.init();
|
||||
Recipes.init();
|
||||
RecipesTransmutationStone.init();
|
||||
|
||||
// Register our fuels
|
||||
GameRegistry.registerFuelHandler(new FuelHandler());
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.pahimar.ee3.api.event;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
@ -10,14 +10,14 @@ import net.minecraftforge.event.world.BlockEvent;
|
|||
public class WorldTransmutationEvent extends BlockEvent
|
||||
{
|
||||
public final ForgeDirection sideHit;
|
||||
public final EntityLiving entityLiving;
|
||||
public final EntityPlayer player;
|
||||
public final ItemStack heldItemStack;
|
||||
|
||||
public WorldTransmutationEvent(int x, int y, int z, World world, Block block, int blockMetaData, ForgeDirection sideHit, EntityLiving entityLiving)
|
||||
public WorldTransmutationEvent(int x, int y, int z, World world, Block block, int blockMetaData, ForgeDirection sideHit, EntityPlayer entityLiving)
|
||||
{
|
||||
super(x, y, z, world, block, blockMetaData);
|
||||
this.sideHit = sideHit;
|
||||
this.entityLiving = entityLiving;
|
||||
this.player = entityLiving;
|
||||
this.heldItemStack = entityLiving.getHeldItem();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.pahimar.ee3.api.exchange;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.pahimar.ee3.knowledge.PlayerKnowledge;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ITransmutationContainer extends IInventory {
|
||||
|
||||
int getXCoord();
|
||||
|
||||
int getYCoord();
|
||||
|
||||
int getZCoord();
|
||||
|
||||
Set<ItemStack> getPlayerKnowledge();
|
||||
|
||||
void consumeInventoryForEnergyValue(ItemStack outputItemStack);
|
||||
|
||||
EnergyValue getAvailableEnergy();
|
||||
|
||||
void updateEnergyValueFromInventory();
|
||||
|
||||
void handlePlayerKnowledgeUpdate(PlayerKnowledge playerKnowledge);
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package com.pahimar.ee3.block;
|
||||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.reference.GUIs;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.reference.RenderIds;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAugmentationTable;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockAugmentationTable extends BlockTileEntityEE
|
||||
{
|
||||
public BlockAugmentationTable()
|
||||
{
|
||||
super(Material.rock);
|
||||
this.setHardness(2.0f);
|
||||
this.setBlockName(Names.Blocks.AUGMENTATION_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int metaData)
|
||||
{
|
||||
return new TileEntityAugmentationTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return RenderIds.augmentationTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (player.isSneaking())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (world.getTileEntity(x, y, z) instanceof TileEntityAugmentationTable)
|
||||
{
|
||||
player.openGui(EquivalentExchange3.instance, GUIs.AUGMENTATION_TABLE.ordinal(), world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import com.pahimar.ee3.inventory.ContainerAugmentationTable;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAugmentationTable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAugmentationTable extends GuiContainer
|
||||
{
|
||||
private TileEntityAugmentationTable tileEntityAugmentationTable;
|
||||
|
||||
public GuiAugmentationTable(InventoryPlayer inventoryPlayer, TileEntityAugmentationTable tileEntityAugmentationTable)
|
||||
{
|
||||
super(new ContainerAugmentationTable(inventoryPlayer, tileEntityAugmentationTable));
|
||||
this.tileEntityAugmentationTable = tileEntityAugmentationTable;
|
||||
xSize = 188;
|
||||
ySize = 199;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.mc.getTextureManager().bindTexture(Textures.Gui.AUGMENTATION_TABLE);
|
||||
|
||||
int xStart = (width - xSize) / 2;
|
||||
int yStart = (height - ySize) / 2;
|
||||
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import com.pahimar.ee3.inventory.ContainerPortableCrafting;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.util.NBTHelper;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiPortableCrafting extends GuiContainer {
|
||||
|
||||
public GuiPortableCrafting(EntityPlayer player, World world, int x, int y, int z) {
|
||||
super(new ContainerPortableCrafting(player.inventory, world, x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float arg0, int arg1, int arg2) {
|
||||
GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f);
|
||||
this.mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/crafting_table.png"));
|
||||
int var5 = (this.width - this.xSize) / 2;
|
||||
int var6 = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal((String)"container.crafting"), 28, 6, 0x404040);
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal((String)"container.inventory"), 8, this.ySize - 96 + 2, 0x404040);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
if (this.mc.thePlayer != null) {
|
||||
for (ItemStack itemStack : this.mc.thePlayer.inventory.mainInventory) {
|
||||
if (itemStack == null || !NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN)) continue;
|
||||
NBTHelper.removeTag(itemStack, Names.NBT.CRAFTING_GUI_OPEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -11,13 +11,17 @@ import com.pahimar.ee3.tileentity.TileEntityAlchemyArray;
|
|||
import com.pahimar.ee3.tileentity.TileEntityDummyArray;
|
||||
import com.pahimar.ee3.tileentity.TileEntityEE;
|
||||
import com.pahimar.ee3.util.IModalTool;
|
||||
import com.pahimar.ee3.util.TransmutationHelper;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -32,6 +36,8 @@ import org.lwjgl.opengl.GL11;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class DrawBlockHighlightEventHandler
|
||||
{
|
||||
private static int pulse;
|
||||
private static boolean doInc;
|
||||
@SubscribeEvent
|
||||
public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event)
|
||||
{
|
||||
|
@ -39,32 +45,18 @@ public class DrawBlockHighlightEventHandler
|
|||
{
|
||||
if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
if (event.currentItem.getItem() instanceof ItemDarkMatterShovel)
|
||||
{
|
||||
drawSelectionBoxForShovel(event, (IModalTool) event.currentItem.getItem());
|
||||
}
|
||||
else if (event.currentItem.getItem() instanceof ItemDarkMatterPickAxe)
|
||||
{
|
||||
drawSelectionBoxForPickAxe(event, (IModalTool) event.currentItem.getItem());
|
||||
}
|
||||
else if (event.currentItem.getItem() instanceof ItemDarkMatterHammer)
|
||||
{
|
||||
drawSelectionBoxForHammer(event, (IModalTool) event.currentItem.getItem());
|
||||
}
|
||||
else if (event.currentItem.getItem() instanceof ItemDarkMatterAxe)
|
||||
{
|
||||
drawSelectionBoxForAxe(event, (IModalTool) event.currentItem.getItem());
|
||||
}
|
||||
else if (event.currentItem.getItem() instanceof ItemDarkMatterHoe)
|
||||
{
|
||||
drawSelectionBoxForHoe(event, (IModalTool) event.currentItem.getItem());
|
||||
}
|
||||
else if (event.currentItem.getItem() instanceof ItemChalk)
|
||||
if (event.currentItem.getItem() instanceof ItemChalk)
|
||||
{
|
||||
// if should draw
|
||||
drawAlchemyArrayOverlay(event);
|
||||
}
|
||||
}
|
||||
if (event.currentItem != null && event.currentItem.getItem() instanceof ITransmutationStone && event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
TransmutationHelper.updateTargetBlock(event.player.worldObj, event.target.blockX, event.target.blockY, event.target.blockZ);
|
||||
if (Minecraft.isGuiEnabled() && Minecraft.getMinecraft().inGameHasFocus) {
|
||||
this.drawInWorldTransmutationOverlay(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,4 +445,121 @@ public class DrawBlockHighlightEventHandler
|
|||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawInWorldTransmutationOverlay(final DrawBlockHighlightEvent event) {
|
||||
final double x = event.target.blockX + 0.5f;
|
||||
final double y = event.target.blockY + 0.5f;
|
||||
final double z = event.target.blockZ + 0.5f;
|
||||
final double iPX = (event.player).prevPosX + ((event.player).posX - (event.player).prevPosX) * event.partialTicks;
|
||||
final double iPY = (event.player).prevPosY + ((event.player).posY - (event.player).prevPosY) * event.partialTicks;
|
||||
final double iPZ = (event.player).prevPosZ + ((event.player).posZ - (event.player).prevPosZ) * event.partialTicks;
|
||||
//final int texture = event.context.renderEngine.func_78341_b("/mods/ee3/textures/effects/noise.png");
|
||||
float xScale = 1.0f;
|
||||
float yScale = 1.0f;
|
||||
float zScale = 1.0f;
|
||||
float xShift = 0.1f;
|
||||
float yShift = 0.1f;
|
||||
float zShift = 0.1f;
|
||||
int itemChargeLevel = 0;
|
||||
final int chargeLevel = 1 + itemChargeLevel * 2;
|
||||
final ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit);
|
||||
switch (sideHit) {
|
||||
case UP: {
|
||||
xScale = chargeLevel + 0.1f;
|
||||
zScale = chargeLevel + 0.1f;
|
||||
xShift = 0.0f;
|
||||
zShift = 0.0f;
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
xScale = chargeLevel + 0.1f;
|
||||
zScale = chargeLevel + 0.1f;
|
||||
xShift = 0.0f;
|
||||
yShift = -yShift;
|
||||
zShift = 0.0f;
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
xScale = chargeLevel + 0.1f;
|
||||
yScale = chargeLevel + 0.1f;
|
||||
xShift = 0.0f;
|
||||
yShift = 0.0f;
|
||||
zShift = -zShift;
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
xScale = chargeLevel + 0.1f;
|
||||
yScale = chargeLevel + 0.1f;
|
||||
xShift = 0.0f;
|
||||
yShift = 0.0f;
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
yScale = chargeLevel + 0.1f;
|
||||
zScale = chargeLevel + 0.1f;
|
||||
yShift = 0.0f;
|
||||
zShift = 0.0f;
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
yScale = chargeLevel + 0.1f;
|
||||
zScale = chargeLevel + 0.1f;
|
||||
xShift = -xShift;
|
||||
yShift = 0.0f;
|
||||
zShift = 0.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glDisable(2884);
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
final ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
|
||||
final int zCorrection = (i == 2) ? -1 : 1;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
|
||||
GL11.glScalef(1.0f * xScale, 1.0f * yScale, 1.0f * zScale);
|
||||
GL11.glRotatef(90.0f, (float)forgeDir.offsetX, (float)forgeDir.offsetY, (float)forgeDir.offsetZ);
|
||||
GL11.glTranslated(0.0, 0.0, (double)(0.5f * zCorrection));
|
||||
GL11.glClear(256);
|
||||
renderPulsingQuad(new ResourceLocation("ee3", "textures/effects/noise.png"), 0.75f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glEnable(2884);
|
||||
GL11.glDepthMask(true);
|
||||
}
|
||||
|
||||
public static void renderPulsingQuad(final ResourceLocation texture, final float maxTransparency) {
|
||||
final float pulseTransparency = getPulseValue() * maxTransparency / 3000.0f;
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glEnable(32826);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, pulseTransparency);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(1.0f, 1.0f, 1.0f, pulseTransparency);
|
||||
tessellator.addVertexWithUV(-0.5, 0.5, 0.0, 0.0, 1.0);
|
||||
tessellator.addVertexWithUV(0.5, 0.5, 0.0, 1.0, 1.0);
|
||||
tessellator.addVertexWithUV(0.5, -0.5, 0.0, 1.0, 0.0);
|
||||
tessellator.addVertexWithUV(-0.5, -0.5, 0.0, 0.0, 0.0);
|
||||
tessellator.draw();
|
||||
GL11.glDisable(3042);
|
||||
GL11.glDisable(32826);
|
||||
}
|
||||
|
||||
private static int getPulseValue() {
|
||||
if (DrawBlockHighlightEventHandler.doInc) {
|
||||
DrawBlockHighlightEventHandler.pulse += 8;
|
||||
}
|
||||
else {
|
||||
DrawBlockHighlightEventHandler.pulse -= 8;
|
||||
}
|
||||
if (DrawBlockHighlightEventHandler.pulse == 3000) {
|
||||
DrawBlockHighlightEventHandler.doInc = false;
|
||||
}
|
||||
if (DrawBlockHighlightEventHandler.pulse == 0) {
|
||||
DrawBlockHighlightEventHandler.doInc = true;
|
||||
}
|
||||
return DrawBlockHighlightEventHandler.pulse;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
package com.pahimar.ee3.client.renderer.item;
|
||||
|
||||
import com.pahimar.ee3.client.renderer.model.ModelAugmentationTable;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ItemRendererAugmentationTable implements IItemRenderer
|
||||
{
|
||||
private final ModelAugmentationTable modelAugmentationTable;
|
||||
|
||||
public ItemRendererAugmentationTable()
|
||||
{
|
||||
modelAugmentationTable = new ModelAugmentationTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType itemRenderType, ItemStack itemStack, ItemRendererHelper itemRendererHelper)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data)
|
||||
{
|
||||
switch (itemRenderType)
|
||||
{
|
||||
case ENTITY:
|
||||
{
|
||||
renderAugmentationTable(0.0F, 0.0F, 0.0F);
|
||||
return;
|
||||
}
|
||||
case EQUIPPED:
|
||||
{
|
||||
renderAugmentationTable(1.0F, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
{
|
||||
renderAugmentationTable(1.5F, 1.5F, 1.5F);
|
||||
return;
|
||||
}
|
||||
case INVENTORY:
|
||||
{
|
||||
renderAugmentationTable(0.0F, 0.0F, 0.0F);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderAugmentationTable(float x, float y, float z)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
// Scale, Translate, Rotate
|
||||
GL11.glScalef(0.33F, 0.33F, 0.33F);
|
||||
GL11.glTranslatef(x, y, z);
|
||||
|
||||
// Bind texture
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.Model.AUGMENTATION_TABLE);
|
||||
|
||||
// Render
|
||||
modelAugmentationTable.render();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package com.pahimar.ee3.client.renderer.tileentity;
|
||||
|
||||
import com.pahimar.ee3.client.renderer.model.ModelAugmentationTable;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAugmentationTable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TileEntityRendererAugmentationTable extends TileEntitySpecialRenderer
|
||||
{
|
||||
private final ModelAugmentationTable modelAugmentationTable = new ModelAugmentationTable();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityAugmentationTable)
|
||||
{
|
||||
TileEntityAugmentationTable tileEntityAugmentationTable = (TileEntityAugmentationTable) tileEntity;
|
||||
ForgeDirection direction = tileEntityAugmentationTable.getOrientation();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
// Scale, Translate, Rotate
|
||||
scaleTranslateRotate(x, y, z, direction);
|
||||
|
||||
// Bind texture
|
||||
this.bindTexture(Textures.Model.AUGMENTATION_TABLE);
|
||||
|
||||
// Render
|
||||
modelAugmentationTable.render();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private void scaleTranslateRotate(double x, double y, double z, ForgeDirection orientation)
|
||||
{
|
||||
if (orientation == ForgeDirection.NORTH)
|
||||
{
|
||||
GL11.glTranslated(x + 0.4d, y + 0.42d, z + 0.5d);
|
||||
GL11.glScalef(0.25F, 0.27F, 0.25F);
|
||||
GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
else if (orientation == ForgeDirection.EAST)
|
||||
{
|
||||
GL11.glTranslated(x + 0.5d, y + 0.42d, z + 0.4d);
|
||||
GL11.glScalef(0.25F, 0.27F, 0.25F);
|
||||
GL11.glRotatef(90, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
else if (orientation == ForgeDirection.SOUTH)
|
||||
{
|
||||
GL11.glTranslated(x + 0.6d, y + 0.42d, z + 0.5d);
|
||||
GL11.glScalef(0.25F, 0.27F, 0.25F);
|
||||
GL11.glRotatef(0, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
else if (orientation == ForgeDirection.WEST)
|
||||
{
|
||||
GL11.glTranslated(x + 0.5d, y + 0.42d, z + 0.6d);
|
||||
GL11.glScalef(0.25F, 0.27F, 0.25F);
|
||||
GL11.glRotatef(-90, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ public class CreativeTab
|
|||
@Override
|
||||
public Item getTabIconItem()
|
||||
{
|
||||
return ModItems.stonePhilosophers;
|
||||
return ModItems.shardMinium;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,154 @@
|
|||
package com.pahimar.ee3.handler;
|
||||
|
||||
import com.pahimar.ee3.item.ITransmutationStone;
|
||||
import com.pahimar.ee3.util.TransmutationHelper;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class DrawBlockHighlightHandler {
|
||||
private static int pulse;
|
||||
private static boolean doInc;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDrawBlockHighlightEvent(final DrawBlockHighlightEvent event) {
|
||||
final Minecraft minecraft = FMLClientHandler.instance().getClient();
|
||||
if (event.currentItem != null && event.currentItem.getItem() instanceof ITransmutationStone && event.target.typeOfHit == MovingObjectType.BLOCK) {
|
||||
TransmutationHelper.updateTargetBlock(event.player.worldObj, event.target.blockX, event.target.blockY, event.target.blockZ);
|
||||
/*if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus && ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION) {
|
||||
this.drawInWorldTransmutationOverlay(event);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/*public void drawInWorldTransmutationOverlay(final DrawBlockHighlightEvent event) {
|
||||
final double x = event.target.blockX + 0.5f;
|
||||
final double y = event.target.blockY + 0.5f;
|
||||
final double z = event.target.blockZ + 0.5f;
|
||||
final double iPX = ((Entity)event.player).prevPosX + (((Entity)event.player).posX - ((Entity)event.player).prevPosX) * event.partialTicks;
|
||||
final double iPY = ((Entity)event.player).prevPosY + (((Entity)event.player).posY - ((Entity)event.player).prevPosY) * event.partialTicks;
|
||||
final double iPZ = ((Entity)event.player).prevPosZ + (((Entity)event.player).posZ - ((Entity)event.player).prevPosZ) * event.partialTicks;
|
||||
final int texture = event.context.renderEngine.func_78341_b("/mods/ee3/textures/effects/noise.png");
|
||||
float xScale = 1.0f;
|
||||
float yScale = 1.0f;
|
||||
float zScale = 1.0f;
|
||||
float xShift = 0.1f;
|
||||
float yShift = 0.1f;
|
||||
float zShift = 0.1f;
|
||||
int itemChargeLevel = 0;
|
||||
if (event.currentItem.getItem() instanceof IChargeable) {
|
||||
itemChargeLevel = ((IChargeable)event.currentItem.getItem()).getCharge(event.currentItem);
|
||||
}
|
||||
final int chargeLevel = 1 + itemChargeLevel * 2;
|
||||
final ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit);
|
||||
switch (sideHit) {
|
||||
case UP: {
|
||||
xScale = chargeLevel + 0.1f;
|
||||
zScale = chargeLevel + 0.1f;
|
||||
xShift = 0.0f;
|
||||
zShift = 0.0f;
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
xScale = chargeLevel + 0.1f;
|
||||
zScale = chargeLevel + 0.1f;
|
||||
xShift = 0.0f;
|
||||
yShift = -yShift;
|
||||
zShift = 0.0f;
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
xScale = chargeLevel + 0.1f;
|
||||
yScale = chargeLevel + 0.1f;
|
||||
xShift = 0.0f;
|
||||
yShift = 0.0f;
|
||||
zShift = -zShift;
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
xScale = chargeLevel + 0.1f;
|
||||
yScale = chargeLevel + 0.1f;
|
||||
xShift = 0.0f;
|
||||
yShift = 0.0f;
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
yScale = chargeLevel + 0.1f;
|
||||
zScale = chargeLevel + 0.1f;
|
||||
yShift = 0.0f;
|
||||
zShift = 0.0f;
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
yScale = chargeLevel + 0.1f;
|
||||
zScale = chargeLevel + 0.1f;
|
||||
xShift = -xShift;
|
||||
yShift = 0.0f;
|
||||
zShift = 0.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glDisable(2884);
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
final ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
|
||||
final int zCorrection = (i == 2) ? -1 : 1;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
|
||||
GL11.glScalef(1.0f * xScale, 1.0f * yScale, 1.0f * zScale);
|
||||
GL11.glRotatef(90.0f, (float)forgeDir.offsetX, (float)forgeDir.offsetY, (float)forgeDir.offsetZ);
|
||||
GL11.glTranslated(0.0, 0.0, (double)(0.5f * zCorrection));
|
||||
GL11.glClear(256);
|
||||
renderPulsingQuad(texture, 0.75f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glEnable(2884);
|
||||
GL11.glDepthMask(true);
|
||||
}
|
||||
|
||||
public static void renderPulsingQuad(final int texture, final float maxTransparency) {
|
||||
final float pulseTransparency = getPulseValue() * maxTransparency / 3000.0f;
|
||||
GL11.glBindTexture(3553, texture);
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glEnable(32826);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, pulseTransparency);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(1.0f, 1.0f, 1.0f, pulseTransparency);
|
||||
tessellator.addVertexWithUV(-0.5, 0.5, 0.0, 0.0, 1.0);
|
||||
tessellator.addVertexWithUV(0.5, 0.5, 0.0, 1.0, 1.0);
|
||||
tessellator.addVertexWithUV(0.5, -0.5, 0.0, 1.0, 0.0);
|
||||
tessellator.addVertexWithUV(-0.5, -0.5, 0.0, 0.0, 0.0);
|
||||
tessellator.draw();
|
||||
GL11.glDisable(3042);
|
||||
GL11.glDisable(32826);
|
||||
}
|
||||
|
||||
private static int getPulseValue() {
|
||||
if (DrawBlockHighlightHandler.doInc) {
|
||||
DrawBlockHighlightHandler.pulse += 8;
|
||||
}
|
||||
else {
|
||||
DrawBlockHighlightHandler.pulse -= 8;
|
||||
}
|
||||
if (DrawBlockHighlightHandler.pulse == 3000) {
|
||||
DrawBlockHighlightHandler.doInc = false;
|
||||
}
|
||||
if (DrawBlockHighlightHandler.pulse == 0) {
|
||||
DrawBlockHighlightHandler.doInc = true;
|
||||
}
|
||||
return DrawBlockHighlightHandler.pulse;
|
||||
}*/
|
||||
|
||||
static {
|
||||
DrawBlockHighlightHandler.pulse = 0;
|
||||
DrawBlockHighlightHandler.doInc = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.pahimar.ee3.handler;
|
||||
|
||||
import com.pahimar.ee3.util.ItemUtil;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
|
||||
public class EntityLivingHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityLivingDeath(LivingDeathEvent event) {
|
||||
if (event.source.getDamageType().equals("player")) {
|
||||
ItemUtil.dropMiniumShard((EntityPlayer)event.source.getSourceOfDamage(), event.entityLiving);
|
||||
}
|
||||
if (event.source.getSourceOfDamage() instanceof EntityArrow && ((EntityArrow)event.source.getSourceOfDamage()).shootingEntity != null && ((EntityArrow)event.source.getSourceOfDamage()).shootingEntity instanceof EntityPlayer) {
|
||||
ItemUtil.dropMiniumShard((EntityPlayer)((EntityArrow)event.source.getSourceOfDamage()).shootingEntity, event.entityLiving);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
194
src/main/java/com/pahimar/ee3/handler/EquivalencyHandler.java
Normal file
194
src/main/java/com/pahimar/ee3/handler/EquivalencyHandler.java
Normal file
|
@ -0,0 +1,194 @@
|
|||
package com.pahimar.ee3.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.pahimar.ee3.util.ItemStackUtils;
|
||||
import com.pahimar.ee3.util.LogHelper;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class EquivalencyHandler
|
||||
{
|
||||
private static final EquivalencyHandler instance;
|
||||
private static ArrayList<ArrayList<ItemStack>> equivalencyList;
|
||||
|
||||
public static EquivalencyHandler instance() {
|
||||
return EquivalencyHandler.instance;
|
||||
}
|
||||
|
||||
public ArrayList<ArrayList<ItemStack>> getAllLists() {
|
||||
return EquivalencyHandler.equivalencyList;
|
||||
}
|
||||
|
||||
public void addObjects(final Object obj1, final Object obj2) {
|
||||
final ItemStack stack1 = ItemStackUtils.convertObjectToItemStack(obj1);
|
||||
final ItemStack stack2 = ItemStackUtils.convertObjectToItemStack(obj2);
|
||||
ArrayList<ItemStack> currentList = new ArrayList();
|
||||
final Integer stack1Index = this.getIndexInList(stack1);
|
||||
final Integer stack2Index = this.getIndexInList(stack2);
|
||||
if (stack1Index != null && stack2Index != null) {
|
||||
return;
|
||||
}
|
||||
if (stack1Index != null && stack2Index == null) {
|
||||
currentList = EquivalencyHandler.equivalencyList.get(stack1Index);
|
||||
currentList.add(stack2);
|
||||
EquivalencyHandler.equivalencyList.set(stack1Index, currentList);
|
||||
}
|
||||
else if (stack1Index == null && stack2Index != null) {
|
||||
currentList = EquivalencyHandler.equivalencyList.get(stack2Index);
|
||||
currentList.add(stack1);
|
||||
EquivalencyHandler.equivalencyList.set(stack2Index, currentList);
|
||||
}
|
||||
else if (stack1Index == null && stack2Index == null) {
|
||||
currentList.add(stack1);
|
||||
currentList.add(stack2);
|
||||
EquivalencyHandler.equivalencyList.add(currentList);
|
||||
}
|
||||
}
|
||||
|
||||
public void addObjects(final Object... objList) {
|
||||
if (objList.length < 2) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < objList.length - 1; ++i) {
|
||||
this.addObjects(objList[i], objList[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getIndexInList(final Object obj) {
|
||||
final ItemStack checkStack = ItemStackUtils.convertObjectToItemStack(obj);
|
||||
for (int i = 0; i < EquivalencyHandler.equivalencyList.size(); ++i) {
|
||||
final ArrayList<ItemStack> currentList = EquivalencyHandler.equivalencyList.get(i);
|
||||
for (final ItemStack currentStack : currentList) {
|
||||
if (ItemStack.areItemStacksEqual(checkStack, currentStack)) {
|
||||
return new Integer(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Integer getIndexInList(final Item id, final int meta) {
|
||||
for (int i = 0; i < EquivalencyHandler.equivalencyList.size(); ++i) {
|
||||
final ArrayList<ItemStack> currentList = EquivalencyHandler.equivalencyList.get(i);
|
||||
for (final ItemStack currentStack : currentList) {
|
||||
if (id == currentStack.getItem() && meta == currentStack.getItemDamage()) {
|
||||
return new Integer(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getEquivalencyList(final Object obj) {
|
||||
final ItemStack checkStack = ItemStackUtils.convertObjectToItemStack(obj);
|
||||
if (checkStack == null) {
|
||||
return null;
|
||||
}
|
||||
for (final ArrayList<ItemStack> list : EquivalencyHandler.equivalencyList) {
|
||||
for (final ItemStack currentStack : list) {
|
||||
if (ItemStack.areItemStacksEqual(checkStack, currentStack)) {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getEquivalencyList(final Item id, final int meta) {
|
||||
for (final ArrayList<ItemStack> list : EquivalencyHandler.equivalencyList) {
|
||||
for (final ItemStack currentStack : list) {
|
||||
if (id == currentStack.getItem() && meta == currentStack.getItemDamage()) {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getNextInList(final Object obj) {
|
||||
final ItemStack checkStack = ItemStackUtils.convertObjectToItemStack(obj);
|
||||
if (checkStack != null) {
|
||||
return this.getNextInList(checkStack.getItem(), checkStack.getItemDamage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getNextInList(final Item id, final int meta) {
|
||||
final ArrayList<ItemStack> list = this.getEquivalencyList(id, meta);
|
||||
ItemStack returnStack = null;
|
||||
int i = 0;
|
||||
if (list != null) {
|
||||
if (list.size() == 1) {
|
||||
return list.get(i);
|
||||
}
|
||||
while (i < list.size()) {
|
||||
final ItemStack currentStack = list.get(i);
|
||||
if (id == currentStack.getItem() && meta == currentStack.getItemDamage()) {
|
||||
returnStack = list.get((i + 1) % list.size());
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
public ItemStack getPrevInList(final Object obj) {
|
||||
final ItemStack checkStack = ItemStackUtils.convertObjectToItemStack(obj);
|
||||
if (checkStack != null) {
|
||||
return this.getPrevInList(checkStack.getItem(), checkStack.getItemDamage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getPrevInList(final Item id, final int meta) {
|
||||
final ArrayList<ItemStack> list = this.getEquivalencyList(id, meta);
|
||||
ItemStack returnStack = null;
|
||||
int i = 0;
|
||||
if (list != null) {
|
||||
if (list.size() == 1) {
|
||||
return list.get(i);
|
||||
}
|
||||
while (i < list.size()) {
|
||||
final ItemStack currentStack = list.get(i);
|
||||
if (id == currentStack.getItem() && meta == currentStack.getItemDamage()) {
|
||||
final int index = (i - 1 + list.size()) % list.size();
|
||||
returnStack = list.get(index);
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
public boolean areEquivalent(final Object obj1, final Object obj2) {
|
||||
return this.getEquivalencyList(obj1) != null && this.getEquivalencyList(obj2) != null && ((ItemStackUtils.convertObjectToItemStack(obj1).getItem() == ItemStackUtils.convertObjectToItemStack(obj2).getItem() && ItemStackUtils.convertObjectToItemStack(obj1).getItemDamage() == ItemStackUtils.convertObjectToItemStack(obj2).getItemDamage()) || this.getEquivalencyList(obj1).equals(this.getEquivalencyList(obj2)));
|
||||
}
|
||||
|
||||
public boolean areWorldEquivalent(final Object obj1, final Object obj2) {
|
||||
final ItemStack first = ItemStackUtils.convertObjectToItemStack(obj1);
|
||||
if (first == null) {
|
||||
return false;
|
||||
}
|
||||
final ItemStack second = ItemStackUtils.convertObjectToItemStack(obj2);
|
||||
return second != null && (this.getEquivalencyList(first.getItem(), first.getItemDamage()) != null && this.getEquivalencyList(second.getItem(), second.getItemDamage()) != null) && ((first.getItem() == second.getItem() && first.getItemDamage() == second.getItemDamage()) || this.getEquivalencyList(first.getItem(), first.getItemDamage()).equals(this.getEquivalencyList(second.getItem(), second.getItemDamage())));
|
||||
}
|
||||
|
||||
public void debug() {
|
||||
int i = 0;
|
||||
for (final ArrayList list : EquivalencyHandler.equivalencyList) {
|
||||
LogHelper.log(Level.INFO, "equivalencyList[" + i + "]: " + list.toString());
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
instance = new EquivalencyHandler();
|
||||
EquivalencyHandler.equivalencyList = new ArrayList();
|
||||
}
|
||||
}
|
|
@ -13,7 +13,10 @@ public class GuiHandler implements IGuiHandler
|
|||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z)
|
||||
{
|
||||
if (id == GUIs.ALCHEMICAL_CHEST.ordinal())
|
||||
if (id == GUIs.PORTABLE_CRAFTING.ordinal()) {
|
||||
return new ContainerPortableCrafting(entityPlayer.inventory, world, x, y, z);
|
||||
}
|
||||
else if (id == GUIs.ALCHEMICAL_CHEST.ordinal())
|
||||
{
|
||||
TileEntityAlchemicalChest tileEntityAlchemicalChest = (TileEntityAlchemicalChest) world.getTileEntity(x, y, z);
|
||||
return new ContainerAlchemicalChest(entityPlayer.inventory, tileEntityAlchemicalChest);
|
||||
|
@ -46,11 +49,6 @@ public class GuiHandler implements IGuiHandler
|
|||
TileEntityResearchStation tileEntityResearchStation = (TileEntityResearchStation) world.getTileEntity(x, y, z);
|
||||
return new ContainerResearchStation(entityPlayer.inventory, tileEntityResearchStation);
|
||||
}
|
||||
else if (id == GUIs.AUGMENTATION_TABLE.ordinal())
|
||||
{
|
||||
TileEntityAugmentationTable tileEntityAugmentationTable = (TileEntityAugmentationTable) world.getTileEntity(x, y, z);
|
||||
return new ContainerAugmentationTable(entityPlayer.inventory, tileEntityAugmentationTable);
|
||||
}
|
||||
else if (id == GUIs.TRANSMUTATION_TABLET.ordinal())
|
||||
{
|
||||
TileEntityTransmutationTablet tileEntityTransmutationTablet = (TileEntityTransmutationTablet) world.getTileEntity(x, y, z);
|
||||
|
@ -76,7 +74,10 @@ public class GuiHandler implements IGuiHandler
|
|||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z)
|
||||
{
|
||||
if (id == GUIs.ALCHEMICAL_CHEST.ordinal())
|
||||
if (id == GUIs.PORTABLE_CRAFTING.ordinal()) {
|
||||
return new GuiPortableCrafting(entityPlayer, world, x, y, z);
|
||||
}
|
||||
else if (id == GUIs.ALCHEMICAL_CHEST.ordinal())
|
||||
{
|
||||
TileEntityAlchemicalChest tileEntityAlchemicalChest = (TileEntityAlchemicalChest) world.getTileEntity(x, y, z);
|
||||
return new GuiAlchemicalChest(entityPlayer.inventory, tileEntityAlchemicalChest);
|
||||
|
@ -109,11 +110,6 @@ public class GuiHandler implements IGuiHandler
|
|||
TileEntityResearchStation tileEntityResearchStation = (TileEntityResearchStation) world.getTileEntity(x, y, z);
|
||||
return new GuiResearchStation(entityPlayer.inventory, tileEntityResearchStation);
|
||||
}
|
||||
else if (id == GUIs.AUGMENTATION_TABLE.ordinal())
|
||||
{
|
||||
TileEntityAugmentationTable tileEntityAugmentationTable = (TileEntityAugmentationTable) world.getTileEntity(x, y, z);
|
||||
return new GuiAugmentationTable(entityPlayer.inventory, tileEntityAugmentationTable);
|
||||
}
|
||||
else if (id == GUIs.TRANSMUTATION_TABLET.ordinal())
|
||||
{
|
||||
TileEntityTransmutationTablet tileEntityTransmutationTablet = (TileEntityTransmutationTablet) world.getTileEntity(x, y, z);
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
package com.pahimar.ee3.handler;
|
||||
|
||||
import com.pahimar.ee3.api.event.WorldTransmutationEvent;
|
||||
import com.pahimar.ee3.util.TransmutationHelper;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class WorldTransmutationHandler {
|
||||
public static void handleWorldTransmutation(EntityPlayer thePlayer, int originX, int originY, int originZ, byte rangeX, byte rangeY, byte rangeZ, ForgeDirection sideHit, Block block, int metadata) {
|
||||
//actionRequestEvent actionRequestEvent = null;
|
||||
WorldTransmutationEvent actionEvent = null;
|
||||
int lowerBoundX = -1 * rangeX / 2;
|
||||
int upperBoundX = -1 * lowerBoundX;
|
||||
int lowerBoundY = -1 * rangeY / 2;
|
||||
int upperBoundY = -1 * lowerBoundY;
|
||||
int lowerBoundZ = -1 * rangeZ / 2;
|
||||
int upperBoundZ = -1 * lowerBoundZ;
|
||||
boolean anySuccess = false;
|
||||
double xShift = 0.0;
|
||||
double yShift = 0.0;
|
||||
double zShift = 0.0;
|
||||
int xSign = 1;
|
||||
int ySign = 1;
|
||||
int zSign = 1;
|
||||
switch (sideHit) {
|
||||
case UP: {
|
||||
yShift = 1.5;
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
yShift = 0.1;
|
||||
ySign = -1;
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
zShift = 1.0;
|
||||
zSign = -1;
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
zShift = 1.0;
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
xShift = 1.0;
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
xShift = 1.0;
|
||||
xSign = -1;
|
||||
}
|
||||
}
|
||||
for (int x = lowerBoundX; x <= upperBoundX; ++x) {
|
||||
for (int y = lowerBoundY; y <= upperBoundY; ++y) {
|
||||
for (int z = lowerBoundZ; z <= upperBoundZ; ++z) {
|
||||
actionEvent = new WorldTransmutationEvent(originX + x, originY + y, originZ + z, thePlayer.worldObj, block, metadata, sideHit, thePlayer);
|
||||
if (actionEvent != null) {
|
||||
//actionRequestEvent = new ActionRequestEvent(thePlayer, actionEvent, originX + x, originY + y, originZ + z, sideHit);
|
||||
//MinecraftForge.EVENT_BUS.post(actionRequestEvent);
|
||||
//if (actionRequestEvent.allowEvent != Event.Result.DENY) {
|
||||
MinecraftForge.EVENT_BUS.post(actionEvent);
|
||||
//}
|
||||
/*if (actionEvent.actionResult == ActionEvent.ActionResult.SUCCESS) {
|
||||
if (!anySuccess) {
|
||||
anySuccess = true;
|
||||
}
|
||||
PacketDispatcher.sendPacketToAllAround((double)(originX + x), (double)(originY + y), (double)(originZ + z), 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle("largesmoke", originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * xSign, 0.05 * ySign, 0.0 * zSign)));
|
||||
PacketDispatcher.sendPacketToAllAround((double)(originX + x), (double)(originY + y), (double)(originZ + z), 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle("largeexplode", originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * xSign, 0.15 * ySign, 0.0 * zSign)));
|
||||
}
|
||||
else if (actionEvent.actionResult == ActionEvent.ActionResult.FAILURE && actionEvent.world.func_72798_a(originX + x, originY + y, originZ + z) != 0) {
|
||||
PacketDispatcher.sendPacketToAllAround((double)(originX + x), (double)(originY + y), (double)(originZ + z), 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle("reddust", originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * xSign, 0.05 * ySign, 0.0 * zSign)));
|
||||
PacketDispatcher.sendPacketToAllAround((double)(originX + x), (double)(originY + y), (double)(originZ + z), 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle("witchMagic", originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * xSign, 0.05 * ySign, 0.0 * zSign)));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (anySuccess) {
|
||||
//PacketDispatcher.sendPacketToAllAround((double)originX, (double)originY, (double)originZ, 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSoundEvent(thePlayer.field_71092_bJ, "mods.ee3.sound.transmute", originX, originY, originZ, 0.5f, 1.0f)));
|
||||
}
|
||||
else {
|
||||
//PacketDispatcher.sendPacketToAllAround((double)originX, (double)originY, (double)originZ, 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSoundEvent(thePlayer.field_71092_bJ, "mods.ee3.sound.fail", originX, originY, originZ, 1.5f, 1.5f)));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldTransmutationEvent(WorldTransmutationEvent event) {
|
||||
Block block = event.world.getBlock(event.x, event.y, event.z);
|
||||
int meta = event.world.getBlockMetadata(event.x, event.y, event.z);
|
||||
boolean result = false;
|
||||
if (block != null) {
|
||||
meta = block.damageDropped(meta);
|
||||
}
|
||||
ItemStack worldStack = new ItemStack(block, 1, meta);
|
||||
ItemStack targetStack = new ItemStack(event.block, 1, event.blockMetadata);
|
||||
ItemStack handItem = event.player.getCurrentEquippedItem();
|
||||
if (!worldStack.isItemEqual(targetStack) && EquivalencyHandler.instance().areWorldEquivalent(worldStack, targetStack) && handItem != null && handItem.getItemDamage() <= handItem.getMaxDamage()) {
|
||||
result = TransmutationHelper.transmuteInWorld(event.world, event.player, handItem, event.x, event.y, event.z, event.block, event.blockMetadata);
|
||||
}
|
||||
if (result) {
|
||||
//event.actionResult = ActionEvent.ActionResult.SUCCESS;
|
||||
int currentSlot = event.player.inventory.currentItem;
|
||||
handItem.damageItem(1, event.player);
|
||||
if (handItem.stackSize < 1) {
|
||||
event.player.inventory.setInventorySlotContents(currentSlot, (ItemStack)null);
|
||||
//PacketDispatcher.sendPacketToPlayer(PacketTypeHandler.populatePacket(new PacketItemUpdate((byte)currentSlot, (byte)0)), (Player)event.player);
|
||||
event.player.worldObj.playSoundAtEntity(event.player, "random.break", 0.8f, 0.8f + event.player.worldObj.rand.nextFloat() * 0.4f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//event.actionResult = ActionEvent.ActionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,6 @@ public class ModBlocks
|
|||
public static final BlockTileEntityEE calcinator = new BlockCalcinator();
|
||||
public static final BlockTileEntityEE glassBell = new BlockGlassBell();
|
||||
public static final BlockTileEntityEE researchStation = new BlockResearchStation();
|
||||
public static final BlockTileEntityEE augmentationTable = new BlockAugmentationTable();
|
||||
public static final BlockEE ashInfusedStone = new BlockAshInfusedStone();
|
||||
public static final BlockTileEntityEE alchemyArray = new BlockAlchemyArray();
|
||||
public static final BlockTileEntityEE dummyArray = new BlockDummyArray();
|
||||
|
@ -31,7 +30,6 @@ public class ModBlocks
|
|||
GameRegistry.registerBlock(aludel, Names.Blocks.ALUDEL);
|
||||
GameRegistry.registerBlock(glassBell, Names.Blocks.GLASS_BELL);
|
||||
GameRegistry.registerBlock(researchStation, Names.Blocks.RESEARCH_STATION);
|
||||
GameRegistry.registerBlock(augmentationTable, Names.Blocks.AUGMENTATION_TABLE);
|
||||
GameRegistry.registerBlock(alchemicalChest, ItemBlockAlchemicalChest.class, Names.Blocks.ALCHEMICAL_CHEST);
|
||||
GameRegistry.registerBlock(chalkBlock, Names.Blocks.CHALK);
|
||||
GameRegistry.registerBlock(alchemicalFuelBlock, ItemBlockAlchemicalFuel.class, Names.Blocks.ALCHEMICAL_FUEL);
|
||||
|
|
|
@ -17,25 +17,7 @@ public class ModItems
|
|||
public static final ItemEE stonePhilosophers = new ItemPhilosophersStone();
|
||||
public static final ItemEE alchemicalUpgrade = new ItemAlchemicalInventoryUpgrade();
|
||||
public static final ItemEE chalk = new ItemChalk();
|
||||
public static final ItemEE diviningRod = new ItemDiviningRod();
|
||||
public static final ItemEE alchenomicon = new ItemAlchenomicon();
|
||||
public static final ItemEE matter = new ItemMatter();
|
||||
public static final ItemEE gem = new ItemGem();
|
||||
public static final ItemEE lootBall = new ItemLootBall();
|
||||
public static final ItemEE knowledgeScroll = new ItemKnowledgeScroll();
|
||||
public static final ItemEE potionLethe = new ItemPotionLethe();
|
||||
|
||||
public static final ItemToolEE shovelDarkMatter = new ItemDarkMatterShovel();
|
||||
public static final ItemToolEE pickAxeDarkMatter = new ItemDarkMatterPickAxe();
|
||||
public static final ItemEE hammerDarkMatter = new ItemDarkMatterHammer();
|
||||
public static final ItemToolEE axeDarkMatter = new ItemDarkMatterAxe();
|
||||
public static final ItemDarkMatterHoe hoeDarkMatter = new ItemDarkMatterHoe();
|
||||
public static final ItemDarkMatterFishingRod fishingRodDarkMatter = new ItemDarkMatterFishingRod();
|
||||
public static final ItemDarkMatterShears shearsDarkMatter = new ItemDarkMatterShears();
|
||||
|
||||
public static final ItemDarkMatterBow bowDarkMatter = new ItemDarkMatterBow();
|
||||
public static final ItemDarkMatterArrow arrowDarkMatter = new ItemDarkMatterArrow();
|
||||
public static final ItemDarkMatterSword swordDarkMatter = new ItemDarkMatterSword();
|
||||
|
||||
public static void init()
|
||||
{
|
||||
|
@ -48,29 +30,6 @@ public class ModItems
|
|||
GameRegistry.registerItem(stonePhilosophers, Names.Items.PHILOSOPHERS_STONE);
|
||||
GameRegistry.registerItem(chalk, Names.Items.CHALK);
|
||||
GameRegistry.registerItem(alchemicalUpgrade, Names.Items.ALCHEMICAL_UPGRADE);
|
||||
GameRegistry.registerItem(diviningRod, Names.Items.DIVINING_ROD);
|
||||
GameRegistry.registerItem(alchenomicon, Names.Items.ALCHENOMICON, Names.Items.ALCHEMICAL_TOME);
|
||||
GameRegistry.registerItem(matter, Names.Items.MATTER);
|
||||
GameRegistry.registerItem(gem, Names.Items.GEM);
|
||||
GameRegistry.registerItem(lootBall, Names.Items.LOOT_BALL);
|
||||
GameRegistry.registerItem(knowledgeScroll, Names.Items.KNOWLEDGE_SCROLL);
|
||||
GameRegistry.registerItem(potionLethe, Names.Items.POTION_LETHE);
|
||||
|
||||
GameRegistry.registerItem(shovelDarkMatter, Names.Tools.DARK_MATTER_SHOVEL);
|
||||
GameRegistry.registerItem(pickAxeDarkMatter, Names.Tools.DARK_MATTER_PICKAXE);
|
||||
GameRegistry.registerItem(hammerDarkMatter, Names.Tools.DARK_MATTER_HAMMER);
|
||||
GameRegistry.registerItem(axeDarkMatter, Names.Tools.DARK_MATTER_AXE);
|
||||
GameRegistry.registerItem(hoeDarkMatter, Names.Tools.DARK_MATTER_HOE);
|
||||
GameRegistry.registerItem(fishingRodDarkMatter, Names.Tools.DARK_MATTER_FISHING_ROD);
|
||||
GameRegistry.registerItem(shearsDarkMatter, Names.Tools.DARK_MATTER_SHEARS);
|
||||
|
||||
GameRegistry.registerItem(bowDarkMatter, Names.Weapons.DARK_MATTER_BOW);
|
||||
GameRegistry.registerItem(arrowDarkMatter, Names.Weapons.DARK_MATTER_ARROW);
|
||||
GameRegistry.registerItem(swordDarkMatter, Names.Weapons.DARK_MATTER_SWORD);
|
||||
|
||||
// Helm
|
||||
// Chest
|
||||
// Leggings
|
||||
// Boots
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,21 +39,6 @@ public class Recipes
|
|||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.stoneInert), "sis", "igi", "sis", 's', Blocks.stone, 'i', "ingotIron", 'g', "ingotGold"));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.diviningRod), " s ", " s ", "s s", 's', "stickWood"));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.augmentationTable), "i ", "sss", "p p", 'i', "ingotIron", 's', "slabWood", 'p', "plankWood"));
|
||||
|
||||
GameRegistry.addShapedRecipe(new ItemStack(ModItems.shovelDarkMatter), "m", "d", "d", 'm', new ItemStack(ModItems.matter, 1, 0), 'd', Items.diamond);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(ModItems.pickAxeDarkMatter), "mmm", " d ", " d ", 'm', new ItemStack(ModItems.matter, 1, 0), 'd', Items.diamond);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(ModItems.hammerDarkMatter), "mmm", "mdm", " d ", 'm', new ItemStack(ModItems.matter, 1, 0), 'd', Items.diamond);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(ModItems.axeDarkMatter), "mm ", "md ", " d ", 'm', new ItemStack(ModItems.matter, 1, 0), 'd', Items.diamond);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(ModItems.hoeDarkMatter), "mm ", " d ", " d ", 'm', new ItemStack(ModItems.matter, 1, 0), 'd', Items.diamond);
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.fishingRodDarkMatter), " w", " ws", "m s", 'm', new ItemStack(ModItems.matter, 1, 0), 'w', "stickWood", 's', new ItemStack(Items.string)));
|
||||
GameRegistry.addShapedRecipe(new ItemStack(ModItems.shearsDarkMatter), "m ", " m", 'm', new ItemStack(ModItems.matter, 1, 0));
|
||||
|
||||
GameRegistry.addShapedRecipe(new ItemStack(ModItems.bowDarkMatter), "sm ", "s m", "sm ", 'm', new ItemStack(ModItems.matter, 1, 0), 's', new ItemStack(Items.string));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.arrowDarkMatter, 64), " m", " s ", "f ", 'm', new ItemStack(ModItems.matter, 1, 0), 's', "stickWood", 'f', new ItemStack(Items.feather)));
|
||||
GameRegistry.addShapedRecipe(new ItemStack(ModItems.swordDarkMatter), "m", "m", "d", 'm', new ItemStack(ModItems.matter, 1, 0), 'd', Items.diamond);
|
||||
}
|
||||
|
||||
private static void initAludelRecipes()
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
package com.pahimar.ee3.init;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.pahimar.ee3.handler.EquivalencyHandler;
|
||||
import com.pahimar.ee3.util.ItemStackUtils;
|
||||
import com.pahimar.ee3.util.RecipeHelper;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
|
||||
public class RecipesTransmutationStone {
|
||||
|
||||
private static ItemStack philStone;
|
||||
private static ItemStack miniumStone;
|
||||
public static List<ItemStack> transmutationStones;
|
||||
private static ItemStack anyCoal;
|
||||
private static ItemStack anyWood;
|
||||
private static ItemStack anyPlank;
|
||||
private static ItemStack anySandStone;
|
||||
private static ItemStack dyeBoneMeal;
|
||||
|
||||
public static void init() {
|
||||
initEquivalencyList();
|
||||
for (ItemStack stone : RecipesTransmutationStone.transmutationStones) {
|
||||
initTransmutationRecipes(stone);
|
||||
initEquivalenceRecipes(stone);
|
||||
initDestructorRecipes(stone);
|
||||
initPortableSmeltingRecipes(stone);
|
||||
}
|
||||
}
|
||||
|
||||
public static void initTransmutationRecipes(ItemStack transmutationStone) {
|
||||
RecipeHelper.addRecipe(Items.flint, transmutationStone, Blocks.cobblestone, Blocks.cobblestone, Blocks.cobblestone, Blocks.cobblestone);
|
||||
RecipeHelper.addRecipe(new ItemStack(Blocks.cobblestone, 4), transmutationStone, Items.flint);
|
||||
RecipeHelper.addRecipe(Blocks.gravel, transmutationStone, Blocks.dirt, Blocks.dirt, Blocks.dirt, Blocks.dirt);
|
||||
RecipeHelper.addRecipe(new ItemStack(Blocks.dirt, 4), transmutationStone, Blocks.gravel);
|
||||
RecipeHelper.addRecipe(new ItemStack(Blocks.sand, 4), transmutationStone, RecipesTransmutationStone.anySandStone);
|
||||
RecipeHelper.addRecipe(Blocks.planks, transmutationStone, Items.stick, Items.stick);
|
||||
RecipeHelper.addRecipe(Blocks.log, transmutationStone, RecipesTransmutationStone.anyPlank, RecipesTransmutationStone.anyPlank, RecipesTransmutationStone.anyPlank, RecipesTransmutationStone.anyPlank);
|
||||
RecipeHelper.addRecipe(Items.clay_ball, transmutationStone, Blocks.gravel, Blocks.gravel, Blocks.gravel, Blocks.gravel);
|
||||
RecipeHelper.addRecipe(Items.clay_ball, transmutationStone, RecipesTransmutationStone.anySandStone, RecipesTransmutationStone.anySandStone, RecipesTransmutationStone.anySandStone, RecipesTransmutationStone.anySandStone);
|
||||
RecipeHelper.addRecipe(Items.clay_ball, transmutationStone, Items.flint, Items.flint, Items.flint, Items.flint);
|
||||
RecipeHelper.addRecipe(new ItemStack(Blocks.gravel, 4), transmutationStone, Items.clay_ball);
|
||||
RecipeHelper.addRecipe(Blocks.obsidian, transmutationStone, RecipesTransmutationStone.anyWood, RecipesTransmutationStone.anyWood);
|
||||
RecipeHelper.addRecipe(new ItemStack(Blocks.log, 2), transmutationStone, Blocks.obsidian);
|
||||
RecipeHelper.addRecipe(new ItemStack(Items.clay_ball, 4), transmutationStone, Blocks.clay);
|
||||
RecipeHelper.addRecipe(Items.iron_ingot, transmutationStone, Blocks.obsidian, Blocks.obsidian, Blocks.obsidian, Blocks.obsidian);
|
||||
RecipeHelper.addRecipe(Items.iron_ingot, transmutationStone, Blocks.clay, Blocks.clay, Blocks.clay, Blocks.clay);
|
||||
RecipeHelper.addRecipe(new ItemStack(Blocks.clay, 4), transmutationStone, Items.iron_ingot);
|
||||
RecipeHelper.addRecipe(Items.gold_ingot, transmutationStone, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot);
|
||||
RecipeHelper.addRecipe(new ItemStack(Items.iron_ingot, 8), transmutationStone, Items.gold_ingot);
|
||||
RecipeHelper.addRecipe(Items.diamond, transmutationStone, Items.gold_ingot, Items.gold_ingot, Items.gold_ingot, Items.gold_ingot);
|
||||
RecipeHelper.addRecipe(new ItemStack(Items.gold_ingot, 4), transmutationStone, Items.diamond);
|
||||
RecipeHelper.addRecipe(Blocks.gold_block, transmutationStone, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block);
|
||||
RecipeHelper.addRecipe(new ItemStack(Blocks.iron_block, 8), transmutationStone, Blocks.gold_block);
|
||||
RecipeHelper.addRecipe(Blocks.diamond_block, transmutationStone, Blocks.gold_block, Blocks.gold_block, Blocks.gold_block, Blocks.gold_block);
|
||||
RecipeHelper.addRecipe(new ItemStack(Blocks.gold_block, 4), transmutationStone, Blocks.diamond_block);
|
||||
RecipeHelper.addRecipe(Items.ender_pearl, transmutationStone, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot);
|
||||
RecipeHelper.addRecipe(new ItemStack(Items.iron_ingot, 4), transmutationStone, Items.ender_pearl);
|
||||
}
|
||||
|
||||
public static void initEquivalenceRecipes(ItemStack stone) {
|
||||
for (ArrayList<ItemStack> itemStackList : EquivalencyHandler.instance().getAllLists()) {
|
||||
ItemStack[] currentList = new ItemStack[itemStackList.size()];
|
||||
currentList = itemStackList.toArray(currentList);
|
||||
for (int i = 0; i < currentList.length; ++i) {
|
||||
int outputI = (i == currentList.length - 1) ? 0 : (i + 1);
|
||||
RecipeHelper.addRecipe(currentList[outputI], stone, ItemStackUtils.convertSingleStackToPluralStacks(currentList[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void initReconstructiveRecipes(ItemStack stone) {
|
||||
RecipeHelper.addRecipe(Items.bone, stone, RecipesTransmutationStone.dyeBoneMeal, RecipesTransmutationStone.dyeBoneMeal, RecipesTransmutationStone.dyeBoneMeal);
|
||||
RecipeHelper.addRecipe(Items.blaze_rod, stone, Items.blaze_powder, Items.blaze_powder);
|
||||
}
|
||||
|
||||
public static void initDestructorRecipes(ItemStack stone) {
|
||||
RecipeHelper.addRecipe(Blocks.cobblestone, stone, Blocks.stone);
|
||||
RecipeHelper.addRecipe(Blocks.sand, stone, Blocks.glass);
|
||||
RecipeHelper.addRecipe(new ItemStack(Items.glowstone_dust, 4), stone, Blocks.glowstone);
|
||||
RecipeHelper.addRecipe(new ItemStack(Items.brick, 4), stone, Blocks.brick_block);
|
||||
}
|
||||
|
||||
public static void initPortableSmeltingRecipes(ItemStack stone) {
|
||||
Map furnaceMap = FurnaceRecipes.smelting().getSmeltingList();
|
||||
Iterator<ItemStack> iterFurnaceKeyMap = furnaceMap.keySet().iterator();
|
||||
while (iterFurnaceKeyMap.hasNext()) {
|
||||
ItemStack furnaceMapKey = iterFurnaceKeyMap.next();
|
||||
RecipeHelper.addSmeltingRecipe(furnaceMapKey, stone, RecipesTransmutationStone.anyCoal);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void initEquivalencyList() {
|
||||
EquivalencyHandler.instance().addObjects(Blocks.sand, Blocks.dirt, Blocks.cobblestone, Blocks.grass);
|
||||
EquivalencyHandler.instance().addObjects(Blocks.yellow_flower, Blocks.red_flower);
|
||||
EquivalencyHandler.instance().addObjects(Blocks.red_mushroom, Blocks.brown_mushroom);
|
||||
EquivalencyHandler.instance().addObjects(Items.pumpkin_seeds, Items.melon_seeds);
|
||||
EquivalencyHandler.instance().addObjects(Blocks.pumpkin, Blocks.melon_block);
|
||||
EquivalencyHandler.instance().addObjects(Blocks.spruce_stairs, Blocks.birch_stairs, Blocks.jungle_stairs);
|
||||
EquivalencyHandler.instance().addObjects(new ItemStack(Items.paper, 3), new ItemStack(Items.reeds, 3));
|
||||
EquivalencyHandler.instance().addObjects(new ItemStack(Items.flint, 2), new ItemStack(Blocks.gravel, 2), new ItemStack(Blocks.sandstone, 2, 0), new ItemStack(Blocks.sandstone, 2, 1), new ItemStack(Blocks.sandstone, 2, 2));
|
||||
EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.planks, 4));
|
||||
EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.log, 4));
|
||||
EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.wooden_slab, 4));
|
||||
EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.sapling, 4));
|
||||
EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.leaves, 4));
|
||||
EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.tallgrass, 3));
|
||||
EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.wool, 16));
|
||||
EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.stonebrick, 4));
|
||||
EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Items.dye, 16, 3, 4, 15));
|
||||
}
|
||||
|
||||
static {
|
||||
RecipesTransmutationStone.philStone = new ItemStack(ModItems.stonePhilosophers, 1, 32767);
|
||||
RecipesTransmutationStone.miniumStone = new ItemStack(ModItems.stoneMinium, 1, 32767);
|
||||
RecipesTransmutationStone.transmutationStones = Arrays.asList(RecipesTransmutationStone.miniumStone, RecipesTransmutationStone.philStone);
|
||||
RecipesTransmutationStone.anyCoal = new ItemStack(Items.coal, 1, 32767);
|
||||
RecipesTransmutationStone.anyWood = new ItemStack(Blocks.log, 1, 32767);
|
||||
RecipesTransmutationStone.anyPlank = new ItemStack(Blocks.planks, 1, 32767);
|
||||
RecipesTransmutationStone.anySandStone = new ItemStack(Blocks.sandstone, 1, 32767);
|
||||
RecipesTransmutationStone.dyeBoneMeal = new ItemStack(Items.dye, 1, 15);
|
||||
}
|
||||
|
||||
}
|
|
@ -16,7 +16,6 @@ public class TileEntities
|
|||
GameRegistry.registerTileEntityWithAlternatives(TileEntityCalcinator.class, Names.Blocks.CALCINATOR, "tile." + Names.Blocks.CALCINATOR);
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityGlassBell.class, Names.Blocks.GLASS_BELL, "tile." + Names.Blocks.GLASS_BELL);
|
||||
GameRegistry.registerTileEntity(TileEntityResearchStation.class, Names.Blocks.RESEARCH_STATION);
|
||||
GameRegistry.registerTileEntity(TileEntityAugmentationTable.class, Names.Blocks.AUGMENTATION_TABLE);
|
||||
GameRegistry.registerTileEntity(TileEntityAlchemyArray.class, Names.Blocks.ALCHEMY_ARRAY);
|
||||
GameRegistry.registerTileEntity(TileEntityDummyArray.class, Names.Blocks.DUMMY_ARRAY);
|
||||
GameRegistry.registerTileEntity(TileEntityTransmutationTablet.class, Names.Blocks.TRANSMUTATION_TABLET);
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.item.ItemGem;
|
||||
import com.pahimar.ee3.item.ItemToolEE;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAugmentationTable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerAugmentationTable extends ContainerEE
|
||||
{
|
||||
private TileEntityAugmentationTable tileEntityAugmentationTable;
|
||||
|
||||
public ContainerAugmentationTable(InventoryPlayer inventoryPlayer, TileEntityAugmentationTable tileEntityAugmentationTable)
|
||||
{
|
||||
this.tileEntityAugmentationTable = tileEntityAugmentationTable;
|
||||
|
||||
this.addSlotToContainer(new Slot(tileEntityAugmentationTable, TileEntityAugmentationTable.INPUT_SLOT_INVENTORY_INDEX, 36, 50));
|
||||
this.addSlotToContainer(new Slot(tileEntityAugmentationTable, TileEntityAugmentationTable.AUGMENT_SLOT_INVENTORY_INDEX, 72, 50));
|
||||
this.addSlotToContainer(new Slot(tileEntityAugmentationTable, TileEntityAugmentationTable.OUTPUT_SLOT_INVENTORY_INDEX, 136, 50));
|
||||
|
||||
// Add the player's inventory slots to the container
|
||||
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
||||
{
|
||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 14 + inventoryColumnIndex * 18, 106 + inventoryRowIndex * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the player's action bar slots to the container
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 14 + actionBarSlotIndex * 18, 164));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
||||
{
|
||||
ItemStack itemStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
|
||||
ItemStack slotItemStack = slot.getStack();
|
||||
itemStack = slotItemStack.copy();
|
||||
|
||||
/**
|
||||
* If we are shift-clicking an item out of the AugmentationTable's container,
|
||||
* attempt to put it in the first available slot in the player's
|
||||
* inventory
|
||||
*/
|
||||
if (slotIndex < TileEntityAugmentationTable.INVENTORY_SIZE)
|
||||
{
|
||||
if (!this.mergeItemStack(slotItemStack, TileEntityAugmentationTable.INVENTORY_SIZE, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* If the stack being shift-clicked into the AugmentationTable's container
|
||||
* is a tool(?), first try to put it in the tool slot.
|
||||
*/
|
||||
//TODO: create IAugmentable(?) interface
|
||||
if (slotItemStack.getItem() instanceof ItemToolEE)
|
||||
{
|
||||
if (!this.mergeItemStack(slotItemStack, TileEntityAugmentationTable.INPUT_SLOT_INVENTORY_INDEX, TileEntityAugmentationTable.AUGMENT_SLOT_INVENTORY_INDEX, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the stack being shift-clicked into the AugmentationTable's container
|
||||
* is an augment(?), try to put it in the augment slot.
|
||||
*/
|
||||
else if (slotItemStack.getItem() instanceof ItemGem)
|
||||
{
|
||||
if (!this.mergeItemStack(slotItemStack, TileEntityAugmentationTable.AUGMENT_SLOT_INVENTORY_INDEX, TileEntityAugmentationTable.OUTPUT_SLOT_INVENTORY_INDEX, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the stack is not augmentable or an augment don't add it in a slot
|
||||
*/
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotItemStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityPlayer)
|
||||
{
|
||||
return this.tileEntityAugmentationTable.isUseableByPlayer(entityPlayer);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.util.NBTHelper;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ContainerWorkbench;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ContainerPortableCrafting extends ContainerWorkbench {
|
||||
|
||||
public ContainerPortableCrafting(InventoryPlayer inv, World world, int x, int y, int z) {
|
||||
super(inv, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
if (!player.worldObj.isRemote) {
|
||||
InventoryPlayer invPlayer = player.inventory;
|
||||
for (ItemStack itemStack : invPlayer.mainInventory) {
|
||||
if (itemStack == null || !NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN)) continue;
|
||||
NBTHelper.removeTag(itemStack, Names.NBT.CRAFTING_GUI_OPEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.inventory.element.IElementButtonHandler;
|
||||
import com.pahimar.ee3.inventory.element.IElementSliderHandler;
|
||||
import com.pahimar.ee3.inventory.element.IElementTextFieldHandler;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class ContainerPortableTransmutation extends ContainerEE implements IElementTextFieldHandler, IElementSliderHandler, IElementButtonHandler {
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleElementButtonClick(String elementName, int mouseButton) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleElementSliderUpdate(String elementName, int elementValue) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleElementTextFieldUpdate(String elementName, String updatedText) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.pahimar.ee3.inventory;
|
|||
import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy;
|
||||
import com.pahimar.ee3.api.exchange.EnergyValue;
|
||||
import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
|
||||
import com.pahimar.ee3.api.exchange.ITransmutationContainer;
|
||||
import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy;
|
||||
import com.pahimar.ee3.inventory.element.IElementButtonHandler;
|
||||
import com.pahimar.ee3.inventory.element.IElementSliderHandler;
|
||||
|
@ -36,7 +37,7 @@ import java.util.*;
|
|||
public class ContainerTransmutationTablet extends ContainerEE implements IElementTextFieldHandler, IElementSliderHandler, IElementButtonHandler {
|
||||
|
||||
private InventoryTransmutationTablet inventoryTransmutationTablet;
|
||||
private final TileEntityTransmutationTablet transmutationTablet;
|
||||
private final ITransmutationContainer transmutationTablet;
|
||||
private final World world;
|
||||
private EnergyValue energyValue;
|
||||
private String searchTerm;
|
||||
|
@ -158,7 +159,7 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
|
|||
|
||||
PacketHandler.INSTANCE.sendToAllAround(
|
||||
new MessagePlayerKnowledge(transmutationTablet, knownItemStacks),
|
||||
new NetworkRegistry.TargetPoint(world.provider.dimensionId, transmutationTablet.xCoord, transmutationTablet.yCoord, transmutationTablet.zCoord, 5d)
|
||||
new NetworkRegistry.TargetPoint(world.provider.dimensionId, transmutationTablet.getXCoord(), transmutationTablet.getYCoord(), transmutationTablet.getZCoord(), 5d)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
14
src/main/java/com/pahimar/ee3/item/ITransmutationStone.java
Normal file
14
src/main/java/com/pahimar/ee3/item/ITransmutationStone.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ITransmutationStone
|
||||
{
|
||||
void openPortableCraftingGUI(final EntityPlayer p0, final ItemStack p1);
|
||||
|
||||
void openPortableTransmutationGUI(final EntityPlayer p0, final ItemStack p1);
|
||||
|
||||
void transmuteBlock(final ItemStack p0, final EntityPlayer p1, final World p2, final int p3, final int p4, final int p5, final int p6);
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
|
||||
public class ItemDarkMatterArrow extends ItemEE
|
||||
{
|
||||
public ItemDarkMatterArrow()
|
||||
{
|
||||
super();
|
||||
this.setMaxStackSize(64);
|
||||
this.setUnlocalizedName(Names.Weapons.DARK_MATTER_ARROW);
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.pahimar.ee3.reference.*;
|
||||
import com.pahimar.ee3.util.CommonSoundHelper;
|
||||
import com.pahimar.ee3.util.IChargeable;
|
||||
import com.pahimar.ee3.util.IKeyBound;
|
||||
import com.pahimar.ee3.util.NBTHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemDarkMatterAxe extends ItemToolModalEE implements IKeyBound, IChargeable
|
||||
{
|
||||
private static final Set blocksEffectiveAgainst = Sets.newHashSet(new Block[]{Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin});
|
||||
|
||||
public ItemDarkMatterAxe()
|
||||
{
|
||||
super(3.0f, Material.Tools.DARK_MATTER, blocksEffectiveAgainst);
|
||||
this.setUnlocalizedName(Names.Tools.DARK_MATTER_AXE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float func_150893_a(ItemStack itemStack, Block block)
|
||||
{
|
||||
return block.getMaterial() != net.minecraft.block.material.Material.wood && block.getMaterial() != net.minecraft.block.material.Material.plants && block.getMaterial() != net.minecraft.block.material.Material.vine ? super.func_150893_a(itemStack, block) : this.efficiencyOnProperMaterial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getToolClasses(ItemStack itemStack)
|
||||
{
|
||||
return ImmutableSet.of("axe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getMaxChargeLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) != null) {
|
||||
return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChargeLevel(ItemStack itemStack, short chargeLevel)
|
||||
{
|
||||
if (chargeLevel <= this.getMaxChargeLevel())
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, chargeLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void increaseChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (getChargeLevel(itemStack) < this.getMaxChargeLevel())
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decreaseChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (getChargeLevel(itemStack)> 0)
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key)
|
||||
{
|
||||
if (key == Key.CHARGE)
|
||||
{
|
||||
if (!entityPlayer.isSneaking())
|
||||
{
|
||||
if (getChargeLevel(itemStack) == this.getMaxChargeLevel())
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.FAIL, 1.5f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
increaseChargeLevel(itemStack);
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.CHARGE_UP, 0.5F, 0.5F + 0.5F * (getChargeLevel(itemStack) * 1.0F / this.getMaxChargeLevel()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getChargeLevel(itemStack) == 0)
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.FAIL, 1.5f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
decreaseChargeLevel(itemStack);
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.CHARGE_DOWN, 0.5F, 1.0F - (0.5F - 0.5F * (getChargeLevel(itemStack) * 1.0F / this.getMaxChargeLevel())));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key == Key.EXTRA)
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.TOCK, 0.5f, 1.5F);
|
||||
changeToolMode(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ToolMode> getAvailableToolModes()
|
||||
{
|
||||
// TODO
|
||||
return Arrays.asList(ToolMode.STANDARD);
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
|
||||
public class ItemDarkMatterBow extends ItemEE
|
||||
{
|
||||
public ItemDarkMatterBow()
|
||||
{
|
||||
super();
|
||||
this.setUnlocalizedName(Names.Weapons.DARK_MATTER_BOW);
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.creativetab.CreativeTab;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemFishingRod;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemDarkMatterFishingRod extends ItemFishingRod
|
||||
{
|
||||
public ItemDarkMatterFishingRod()
|
||||
{
|
||||
super();
|
||||
this.setCreativeTab(CreativeTab.EE3_TAB);
|
||||
this.setNoRepair();
|
||||
this.setUnlocalizedName(Names.Tools.DARK_MATTER_FISHING_ROD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
|
||||
}
|
||||
|
||||
protected String getUnwrappedUnlocalizedName(String unlocalizedName)
|
||||
{
|
||||
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.Key;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.reference.ToolMode;
|
||||
import com.pahimar.ee3.util.IChargeable;
|
||||
import com.pahimar.ee3.util.IKeyBound;
|
||||
import com.pahimar.ee3.util.IModalTool;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemDarkMatterHammer extends ItemEE implements IKeyBound, IChargeable, IModalTool
|
||||
{
|
||||
public ItemDarkMatterHammer()
|
||||
{
|
||||
super();
|
||||
this.setUnlocalizedName(Names.Tools.DARK_MATTER_HAMMER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getMaxChargeLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChargeLevel(ItemStack itemStack, short chargeLevel)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void increaseChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decreaseChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ToolMode> getAvailableToolModes()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolMode getCurrentToolMode(ItemStack itemStack)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToolMode(ItemStack itemStack, ToolMode toolMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeToolMode(ItemStack itemStack)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,200 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.creativetab.CreativeTab;
|
||||
import com.pahimar.ee3.reference.*;
|
||||
import com.pahimar.ee3.util.*;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemDarkMatterHoe extends ItemHoe implements IKeyBound, IChargeable, IModalTool
|
||||
{
|
||||
public ItemDarkMatterHoe()
|
||||
{
|
||||
super(Material.Tools.DARK_MATTER);
|
||||
this.setCreativeTab(CreativeTab.EE3_TAB);
|
||||
this.setNoRepair();
|
||||
this.maxStackSize = 1;
|
||||
this.setUnlocalizedName(Names.Tools.DARK_MATTER_HOE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
|
||||
}
|
||||
|
||||
protected String getUnwrappedUnlocalizedName(String unlocalizedName)
|
||||
{
|
||||
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShareTag()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.getItem() instanceof IChargeable)
|
||||
{
|
||||
return ((IChargeable) itemStack.getItem()).getChargeLevel(itemStack) > 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.getItem() instanceof IChargeable)
|
||||
{
|
||||
return (double) (((IChargeable) itemStack.getItem()).getMaxChargeLevel() - ((IChargeable) itemStack.getItem()).getChargeLevel(itemStack)) / (double) ((IChargeable) itemStack.getItem()).getMaxChargeLevel();
|
||||
}
|
||||
|
||||
return 1d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getMaxChargeLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) != null) {
|
||||
return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChargeLevel(ItemStack itemStack, short chargeLevel)
|
||||
{
|
||||
if (chargeLevel <= this.getMaxChargeLevel())
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, chargeLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void increaseChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (getChargeLevel(itemStack) < this.getMaxChargeLevel())
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decreaseChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (getChargeLevel(itemStack) > 0)
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key)
|
||||
{
|
||||
if (key == Key.CHARGE)
|
||||
{
|
||||
if (!entityPlayer.isSneaking())
|
||||
{
|
||||
if (getChargeLevel(itemStack) == this.getMaxChargeLevel())
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.FAIL, 1.5f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
increaseChargeLevel(itemStack);
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.CHARGE_UP, 0.5F, 0.5F + 0.5F * (getChargeLevel(itemStack) * 1.0F / this.getMaxChargeLevel()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getChargeLevel(itemStack) == 0)
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.FAIL, 1.5f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
decreaseChargeLevel(itemStack);
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.CHARGE_DOWN, 0.5F, 1.0F - (0.5F - 0.5F * (getChargeLevel(itemStack) * 1.0F / this.getMaxChargeLevel())));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key == Key.EXTRA)
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.TOCK, 0.5f, 1.5F);
|
||||
changeToolMode(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ToolMode> getAvailableToolModes()
|
||||
{
|
||||
// TODO
|
||||
return Arrays.asList(ToolMode.STANDARD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolMode getCurrentToolMode(ItemStack itemStack)
|
||||
{
|
||||
if (NBTHelper.getShort(itemStack, Names.NBT.MODE) != null && 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,157 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.pahimar.ee3.creativetab.CreativeTab;
|
||||
import com.pahimar.ee3.reference.*;
|
||||
import com.pahimar.ee3.util.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemDarkMatterPickAxe extends ItemToolModalEE implements IKeyBound, IChargeable
|
||||
{
|
||||
private static final Set blocksEffectiveAgainst = Sets.newHashSet(new Block[]{Blocks.cobblestone, Blocks.double_stone_slab, Blocks.stone_slab, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone, Blocks.iron_ore, Blocks.iron_block, Blocks.coal_ore, Blocks.gold_block, Blocks.gold_ore, Blocks.diamond_ore, Blocks.diamond_block, Blocks.ice, Blocks.netherrack, Blocks.lapis_ore, Blocks.lapis_block, Blocks.redstone_ore, Blocks.lit_redstone_ore, Blocks.rail, Blocks.detector_rail, Blocks.golden_rail, Blocks.activator_rail});
|
||||
|
||||
public ItemDarkMatterPickAxe()
|
||||
{
|
||||
super(2f, Material.Tools.DARK_MATTER, blocksEffectiveAgainst);
|
||||
this.setCreativeTab(CreativeTab.EE3_TAB);
|
||||
this.setNoRepair();
|
||||
this.setUnlocalizedName(Names.Tools.DARK_MATTER_PICKAXE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_150897_b(Block block)
|
||||
{
|
||||
return block == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : (block != Blocks.diamond_block && block != Blocks.diamond_ore ? (block != Blocks.emerald_ore && block != Blocks.emerald_block ? (block != Blocks.gold_block && block != Blocks.gold_ore ? (block != Blocks.iron_block && block != Blocks.iron_ore ? (block != Blocks.lapis_block && block != Blocks.lapis_ore ? (block != Blocks.redstone_ore && block != Blocks.lit_redstone_ore ? (block.getMaterial() == net.minecraft.block.material.Material.rock || (block.getMaterial() == net.minecraft.block.material.Material.iron || block.getMaterial() == net.minecraft.block.material.Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float func_150893_a(ItemStack itemStack, Block block)
|
||||
{
|
||||
return block.getMaterial() != net.minecraft.block.material.Material.iron && block.getMaterial() != net.minecraft.block.material.Material.anvil && block.getMaterial() != net.minecraft.block.material.Material.rock ? super.func_150893_a(itemStack, block) : this.efficiencyOnProperMaterial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getToolClasses(ItemStack itemStack)
|
||||
{
|
||||
return ImmutableSet.of("pickaxe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed(ItemStack itemStack, Block block, int meta)
|
||||
{
|
||||
if ((ForgeHooks.isToolEffective(itemStack, block, meta) || block == Blocks.obsidian || block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore) && (itemStack.getItem() instanceof IChargeable))
|
||||
{
|
||||
return super.getDigSpeed(itemStack, block, meta) + (((IChargeable) itemStack.getItem()).getChargeLevel(itemStack) * 12f);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// TODO
|
||||
LogHelper.info("Right click with the Dark Matter Pickaxe");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getMaxChargeLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) != null) {
|
||||
return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChargeLevel(ItemStack itemStack, short chargeLevel)
|
||||
{
|
||||
if (chargeLevel <= this.getMaxChargeLevel())
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, chargeLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void increaseChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (getChargeLevel(itemStack) < this.getMaxChargeLevel())
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decreaseChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (getChargeLevel(itemStack) > 0)
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key)
|
||||
{
|
||||
if (key == Key.CHARGE)
|
||||
{
|
||||
if (!entityPlayer.isSneaking())
|
||||
{
|
||||
if (getChargeLevel(itemStack) == this.getMaxChargeLevel())
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.FAIL, 1.5f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
increaseChargeLevel(itemStack);
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.CHARGE_UP, 0.5F, 0.5F + 0.5F * (getChargeLevel(itemStack) * 1.0F / this.getMaxChargeLevel()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getChargeLevel(itemStack) == 0)
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.FAIL, 1.5f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
decreaseChargeLevel(itemStack);
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.CHARGE_DOWN, 0.5F, 1.0F - (0.5F - 0.5F * (getChargeLevel(itemStack) * 1.0F / this.getMaxChargeLevel())));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key == Key.EXTRA)
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.TOCK, 0.5f, 1.5F);
|
||||
changeToolMode(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ToolMode> getAvailableToolModes()
|
||||
{
|
||||
return Arrays.asList(ToolMode.STANDARD, ToolMode.WIDE, ToolMode.TALL);
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
|
||||
public class ItemDarkMatterShears extends ItemEE
|
||||
{
|
||||
public ItemDarkMatterShears()
|
||||
{
|
||||
super();
|
||||
this.setUnlocalizedName(Names.Tools.DARK_MATTER_SHEARS);
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.pahimar.ee3.reference.*;
|
||||
import com.pahimar.ee3.util.CommonSoundHelper;
|
||||
import com.pahimar.ee3.util.IChargeable;
|
||||
import com.pahimar.ee3.util.IKeyBound;
|
||||
import com.pahimar.ee3.util.NBTHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemDarkMatterShovel extends ItemToolModalEE implements IKeyBound, IChargeable
|
||||
{
|
||||
private static final Set blocksEffectiveAgainst = Sets.newHashSet(new Block[]{Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, Blocks.snow_layer, Blocks.snow, Blocks.clay, Blocks.farmland, Blocks.soul_sand, Blocks.mycelium});
|
||||
|
||||
public ItemDarkMatterShovel()
|
||||
{
|
||||
super(1.0f, Material.Tools.DARK_MATTER, blocksEffectiveAgainst);
|
||||
this.setUnlocalizedName(Names.Tools.DARK_MATTER_SHOVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_150897_b(Block block)
|
||||
{
|
||||
return block == Blocks.snow_layer || block == Blocks.snow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getToolClasses(ItemStack itemStack)
|
||||
{
|
||||
return ImmutableSet.of("shovel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getMaxChargeLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getChargeLevel(ItemStack itemStack) {
|
||||
|
||||
if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) != null) {
|
||||
return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChargeLevel(ItemStack itemStack, short chargeLevel)
|
||||
{
|
||||
if (chargeLevel <= this.getMaxChargeLevel())
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, chargeLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void increaseChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (getChargeLevel(itemStack) < this.getMaxChargeLevel())
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decreaseChargeLevel(ItemStack itemStack)
|
||||
{
|
||||
if (getChargeLevel(itemStack) > 0)
|
||||
{
|
||||
NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key)
|
||||
{
|
||||
if (key == Key.CHARGE)
|
||||
{
|
||||
if (!entityPlayer.isSneaking())
|
||||
{
|
||||
if (getChargeLevel(itemStack) == this.getMaxChargeLevel())
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.FAIL, 1.5f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
increaseChargeLevel(itemStack);
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.CHARGE_UP, 0.5F, 0.5F + 0.5F * (getChargeLevel(itemStack) * 1.0F / this.getMaxChargeLevel()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getChargeLevel(itemStack) == 0)
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.FAIL, 1.5f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
decreaseChargeLevel(itemStack);
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.CHARGE_DOWN, 0.5F, 1.0F - (0.5F - 0.5F * (getChargeLevel(itemStack) * 1.0F / this.getMaxChargeLevel())));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key == Key.EXTRA)
|
||||
{
|
||||
CommonSoundHelper.playSoundAtPlayer(entityPlayer, Sounds.TOCK, 0.5f, 1.5F);
|
||||
changeToolMode(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ToolMode> getAvailableToolModes()
|
||||
{
|
||||
// TODO
|
||||
return Arrays.asList(ToolMode.STANDARD);
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.creativetab.CreativeTab;
|
||||
import com.pahimar.ee3.reference.Material;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import com.pahimar.ee3.util.IChargeable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
|
||||
public class ItemDarkMatterSword extends ItemSword
|
||||
{
|
||||
public ItemDarkMatterSword()
|
||||
{
|
||||
super(Material.Tools.DARK_MATTER);
|
||||
this.setCreativeTab(CreativeTab.EE3_TAB);
|
||||
this.setNoRepair();
|
||||
this.maxStackSize = 1;
|
||||
this.setUnlocalizedName(Names.Weapons.DARK_MATTER_SWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
|
||||
}
|
||||
|
||||
protected String getUnwrappedUnlocalizedName(String unlocalizedName)
|
||||
{
|
||||
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShareTag()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.getItem() instanceof IChargeable)
|
||||
{
|
||||
return ((IChargeable) itemStack.getItem()).getChargeLevel(itemStack) > 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.getItem() instanceof IChargeable)
|
||||
{
|
||||
return (double) (((IChargeable) itemStack.getItem()).getMaxChargeLevel() - ((IChargeable) itemStack.getItem()).getChargeLevel(itemStack)) / (double) ((IChargeable) itemStack.getItem()).getMaxChargeLevel();
|
||||
}
|
||||
|
||||
return 1d;
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
|
||||
public class ItemDiviningRod extends ItemEE
|
||||
{
|
||||
public ItemDiviningRod()
|
||||
{
|
||||
super();
|
||||
this.setHasSubtypes(true);
|
||||
this.setUnlocalizedName(Names.Items.DIVINING_ROD);
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemGem extends ItemEE
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
public ItemGem()
|
||||
{
|
||||
super();
|
||||
this.setMaxStackSize(64);
|
||||
this.setHasSubtypes(true);
|
||||
this.setUnlocalizedName(Names.Items.GEM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return String.format("item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.GEM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return String.format("item.%s%s%s", Textures.RESOURCE_PREFIX, Names.Items.GEM, Names.Items.GEM_SUBTYPES[MathHelper.clamp_int(itemStack.getItemDamage(), 0, Names.Items.GEM_SUBTYPES.length - 1)]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs creativeTab, List list)
|
||||
{
|
||||
for (int meta = 0; meta < Names.Items.GEM_SUBTYPES.length; ++meta)
|
||||
{
|
||||
list.add(new ItemStack(this, 1, meta));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
return icons[MathHelper.clamp_int(meta, 0, Names.Items.GEM_SUBTYPES.length - 1)];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
icons = new IIcon[Names.Items.GEM_SUBTYPES.length];
|
||||
|
||||
for (int i = 0; i < Names.Items.GEM_SUBTYPES.length; i++)
|
||||
{
|
||||
icons[i] = iconRegister.registerIcon(Textures.RESOURCE_PREFIX + Names.Items.GEM + Names.Items.GEM_SUBTYPES[i]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
|
||||
public class ItemKnowledgeScroll extends ItemEE
|
||||
{
|
||||
public ItemKnowledgeScroll()
|
||||
{
|
||||
super();
|
||||
this.setUnlocalizedName(Names.Items.KNOWLEDGE_SCROLL);
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
|
||||
public class ItemLootBall extends ItemEE
|
||||
{
|
||||
public ItemLootBall()
|
||||
{
|
||||
super();
|
||||
this.setUnlocalizedName(Names.Items.LOOT_BALL);
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemMatter extends ItemEE
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
public ItemMatter()
|
||||
{
|
||||
super();
|
||||
this.setMaxStackSize(64);
|
||||
this.setHasSubtypes(true);
|
||||
this.setUnlocalizedName(Names.Items.MATTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return String.format("item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.MATTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return String.format("item.%s%s%s", Textures.RESOURCE_PREFIX, Names.Items.MATTER, Names.Items.MATTER_SUBTYPES[MathHelper.clamp_int(itemStack.getItemDamage(), 0, Names.Items.MATTER_SUBTYPES.length - 1)]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs creativeTab, List list)
|
||||
{
|
||||
for (int meta = 0; meta < Names.Items.MATTER_SUBTYPES.length; ++meta)
|
||||
{
|
||||
list.add(new ItemStack(this, 1, meta));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
return icons[MathHelper.clamp_int(meta, 0, Names.Items.MATTER_SUBTYPES.length - 1)];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
icons = new IIcon[Names.Items.MATTER_SUBTYPES.length];
|
||||
|
||||
for (int i = 0; i < Names.Items.MATTER_SUBTYPES.length; i++)
|
||||
{
|
||||
icons[i] = iconRegister.registerIcon(Textures.RESOURCE_PREFIX + Names.Items.MATTER + Names.Items.MATTER_SUBTYPES[i]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,22 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.reference.GUIs;
|
||||
import com.pahimar.ee3.reference.Key;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.util.IKeyBound;
|
||||
import com.pahimar.ee3.util.LogHelper;
|
||||
import com.pahimar.ee3.util.IOverlayItem;
|
||||
import com.pahimar.ee3.util.NBTHelper;
|
||||
import com.pahimar.ee3.util.TransmutationHelper;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class ItemMiniumStone extends ItemEE implements IKeyBound
|
||||
public class ItemMiniumStone extends ItemEE implements IKeyBound, IOverlayItem, ITransmutationStone
|
||||
{
|
||||
public ItemMiniumStone()
|
||||
{
|
||||
|
@ -42,6 +48,11 @@ public class ItemMiniumStone extends ItemEE implements IKeyBound
|
|||
return copiedStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect(ItemStack itemStack, int renderPass)
|
||||
|
@ -52,6 +63,45 @@ public class ItemMiniumStone extends ItemEE implements IKeyBound
|
|||
@Override
|
||||
public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key)
|
||||
{
|
||||
LogHelper.info("{} {} {}", entityPlayer.toString(), itemStack.toString(), key.toString());
|
||||
if (key == Key.EXTRA) {
|
||||
if (!entityPlayer.isSneaking()) {
|
||||
openPortableCraftingGUI(entityPlayer, itemStack);
|
||||
} else {
|
||||
//this.openPortableTransmutationGUI(entityPlayer, itemStack);
|
||||
}
|
||||
} else if (key == Key.TOGGLE && TransmutationHelper.targetBlockStack != null) {
|
||||
if (!entityPlayer.isSneaking()) {
|
||||
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.getItem(), TransmutationHelper.targetBlockStack.getItemDamage());
|
||||
}
|
||||
else {
|
||||
TransmutationHelper.targetBlockStack = TransmutationHelper.getPreviousBlock(TransmutationHelper.targetBlockStack.getItem(), TransmutationHelper.targetBlockStack.getItemDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int sideHit, float hitVecX, float hitVecY, float hitVecZ) {
|
||||
if (world.isRemote) {
|
||||
this.transmuteBlock(itemStack, entityPlayer, world, x, y, z, sideHit);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transmuteBlock(final ItemStack itemStack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int sideHit) {
|
||||
EquivalentExchange3.proxy.transmuteBlock(itemStack, player, world, x, y, z, ForgeDirection.getOrientation(sideHit));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openPortableCraftingGUI(EntityPlayer thePlayer, ItemStack itemStack) {
|
||||
NBTHelper.setBoolean(itemStack, Names.NBT.CRAFTING_GUI_OPEN, true);
|
||||
thePlayer.openGui((Object)EquivalentExchange3.instance, GUIs.PORTABLE_CRAFTING.ordinal(), thePlayer.worldObj, (int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openPortableTransmutationGUI(EntityPlayer thePlayer, ItemStack itemStack) {
|
||||
NBTHelper.setBoolean(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN, true);
|
||||
//thePlayer.openGui((Object)EquivalentExchange3.instance, 1, thePlayer.worldObj, (int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
|
||||
public class ItemPotionLethe extends ItemEE
|
||||
{
|
||||
public ItemPotionLethe()
|
||||
{
|
||||
super();
|
||||
this.setUnlocalizedName(Names.Items.POTION_LETHE);
|
||||
}
|
||||
}
|
|
@ -31,5 +31,6 @@ public class PacketHandler {
|
|||
INSTANCE.registerMessage(MessageTileEntityResearchStation.class, MessageTileEntityResearchStation.class, 17, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageSyncBlacklist.class, MessageSyncBlacklist.class, 18, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageSetBlacklistEntry.class, MessageSetBlacklistEntry.class, 19, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageTransmutateEvent.class, MessageTransmutateEvent.class, 20, Side.SERVER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.pahimar.ee3.network.message;
|
||||
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.pahimar.ee3.api.exchange.ITransmutationContainer;
|
||||
import com.pahimar.ee3.knowledge.PlayerKnowledge;
|
||||
import com.pahimar.ee3.tileentity.TileEntityTransmutationTablet;
|
||||
import com.pahimar.ee3.util.CompressionHelper;
|
||||
import com.pahimar.ee3.util.SerializationHelper;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
|
@ -10,6 +10,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
@ -23,12 +24,12 @@ public class MessagePlayerKnowledge implements IMessage, IMessageHandler<Message
|
|||
public MessagePlayerKnowledge(){
|
||||
}
|
||||
|
||||
public MessagePlayerKnowledge(TileEntityTransmutationTablet transmutationTablet, Collection<ItemStack> knownItemStacks) {
|
||||
public MessagePlayerKnowledge(ITransmutationContainer transmutationTablet, Collection<ItemStack> knownItemStacks) {
|
||||
|
||||
if (transmutationTablet != null) {
|
||||
this.xCoord = transmutationTablet.xCoord;
|
||||
this.yCoord = transmutationTablet.yCoord;
|
||||
this.zCoord = transmutationTablet.zCoord;
|
||||
this.xCoord = transmutationTablet.getXCoord();
|
||||
this.yCoord = transmutationTablet.getYCoord();
|
||||
this.zCoord = transmutationTablet.getZCoord();
|
||||
}
|
||||
else {
|
||||
this.xCoord = 0;
|
||||
|
@ -96,9 +97,8 @@ public class MessagePlayerKnowledge implements IMessage, IMessageHandler<Message
|
|||
if (message.yCoord != Integer.MIN_VALUE) {
|
||||
|
||||
TileEntity tileEntity = FMLClientHandler.instance().getWorldClient().getTileEntity(message.xCoord, message.yCoord, message.zCoord);
|
||||
|
||||
if (tileEntity instanceof TileEntityTransmutationTablet) {
|
||||
((TileEntityTransmutationTablet) tileEntity).handlePlayerKnowledgeUpdate(message.playerKnowledge);
|
||||
if (tileEntity instanceof ITransmutationContainer) {
|
||||
((ITransmutationContainer) tileEntity).handlePlayerKnowledgeUpdate(message.playerKnowledge);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package com.pahimar.ee3.network.message;
|
||||
|
||||
import com.pahimar.ee3.handler.WorldTransmutationHandler;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class MessageTransmutateEvent implements IMessage, IMessageHandler<MessageTransmutateEvent, IMessage> {
|
||||
|
||||
public int originX;
|
||||
public int originY;
|
||||
public int originZ;
|
||||
public ForgeDirection sideHit;
|
||||
public byte rangeX = 0;
|
||||
public byte rangeY = 0;
|
||||
public byte rangeZ = 0;
|
||||
public Block block;
|
||||
public int metadata;
|
||||
|
||||
public MessageTransmutateEvent() {}
|
||||
|
||||
public MessageTransmutateEvent(int originX, int originY, int originZ, ForgeDirection sideHit, Block block, int metadata) {
|
||||
this.originX = originX;
|
||||
this.originY = originY;
|
||||
this.originZ = originZ;
|
||||
this.sideHit = sideHit;
|
||||
this.block = block;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageTransmutateEvent message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
WorldTransmutationHandler.handleWorldTransmutation(player, message.originX, message.originY, message.originZ, message.rangeX, message.rangeY, message.rangeZ, message.sideHit, message.block, message.metadata);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
originX = buf.readInt();
|
||||
originY = buf.readInt();
|
||||
originZ = buf.readInt();
|
||||
sideHit = ForgeDirection.getOrientation(buf.readInt());
|
||||
rangeX = buf.readByte();
|
||||
rangeY = buf.readByte();
|
||||
rangeZ = buf.readByte();
|
||||
block = Block.getBlockById(buf.readInt());
|
||||
metadata = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(originX);
|
||||
buf.writeInt(originY);
|
||||
buf.writeInt(originZ);
|
||||
buf.writeInt(sideHit.ordinal());
|
||||
buf.writeByte(rangeX);
|
||||
buf.writeByte(rangeY);
|
||||
buf.writeByte(rangeZ);
|
||||
buf.writeInt(Block.getIdFromBlock(block));
|
||||
buf.writeInt(metadata);
|
||||
}
|
||||
|
||||
}
|
|
@ -10,15 +10,24 @@ import com.pahimar.ee3.client.settings.Keybindings;
|
|||
import com.pahimar.ee3.client.util.ClientParticleHelper;
|
||||
import com.pahimar.ee3.client.util.ClientSoundHelper;
|
||||
import com.pahimar.ee3.init.ModBlocks;
|
||||
import com.pahimar.ee3.network.PacketHandler;
|
||||
import com.pahimar.ee3.network.message.MessageTransmutateEvent;
|
||||
import com.pahimar.ee3.reference.RenderIds;
|
||||
import com.pahimar.ee3.settings.ChalkSettings;
|
||||
import com.pahimar.ee3.tileentity.*;
|
||||
import com.pahimar.ee3.util.TransmutationHelper;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class ClientProxy extends CommonProxy
|
||||
{
|
||||
|
@ -79,15 +88,22 @@ public class ClientProxy extends CommonProxy
|
|||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.calcinator), new ItemRendererCalcinator());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.glassBell), new ItemRendererGlassBell());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.researchStation), new ItemRendererResearchStation());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.augmentationTable), new ItemRendererAugmentationTable());
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAlchemicalChest.class, new TileEntityRendererAlchemicalChest());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCalcinator.class, new TileEntityRendererCalcinator());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAludel.class, new TileEntityRendererAludel());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityGlassBell.class, new TileEntityRendererGlassBell());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityResearchStation.class, new TileEntityRendererResearchStation());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAugmentationTable.class, new TileEntityRendererAugmentationTable());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAlchemyArray.class, new TileEntityRendererAlchemyArray());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTransmutationTablet.class, new TileEntityRendererTransmutationTablet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, ForgeDirection sideHit) {
|
||||
if (TransmutationHelper.targetBlockStack != null && itemStack != null) {
|
||||
ItemStack stack = TransmutationHelper.targetBlockStack;
|
||||
Block targetBlock = Block.getBlockFromItem(stack.getItem());
|
||||
PacketHandler.INSTANCE.sendToServer(new MessageTransmutateEvent(x, y, z, sideHit, targetBlock, stack.getItemDamage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ public abstract class CommonProxy implements IProxy
|
|||
FMLCommonHandler.instance().bus().register(itemEventHandler);
|
||||
MinecraftForge.EVENT_BUS.register(itemEventHandler);
|
||||
MinecraftForge.EVENT_BUS.register(new WorldEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new EntityLivingHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new WorldTransmutationHandler());
|
||||
MinecraftForge.EVENT_BUS.register(playerEventHandler);
|
||||
FMLCommonHandler.instance().bus().register(playerEventHandler);
|
||||
FMLCommonHandler.instance().bus().register(craftingHandler);
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package com.pahimar.ee3.proxy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IProxy
|
||||
{
|
||||
public abstract ClientProxy getClientProxy();
|
||||
|
@ -13,4 +18,6 @@ public interface IProxy
|
|||
public abstract void playSound(String soundName, float xCoord, float yCoord, float zCoord, float volume, float pitch);
|
||||
|
||||
public abstract void spawnParticle(String particleName, double xCoord, double yCoord, double zCoord, double xVelocity, double yVelocity, double zVelocity);
|
||||
|
||||
void transmuteBlock(final ItemStack itemStack, final EntityPlayer player, final World world, final int x, final int y, final int z, final ForgeDirection sideHit);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package com.pahimar.ee3.proxy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class ServerProxy extends CommonProxy
|
||||
{
|
||||
@Override
|
||||
|
@ -31,4 +36,10 @@ public class ServerProxy extends CommonProxy
|
|||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, ForgeDirection sideHit)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ public enum GUIs
|
|||
ALCHEMICAL_BAG,
|
||||
GLASS_BELL,
|
||||
RESEARCH_STATION,
|
||||
AUGMENTATION_TABLE,
|
||||
ALCHENOMICON,
|
||||
TRANSMUTATION_TABLET,
|
||||
SYMBOL_SELECTION,
|
||||
|
|
|
@ -19,7 +19,6 @@ public class EETestSuite extends EnergyValueTestSuite {
|
|||
add(ModBlocks.aludel, 1794);
|
||||
add(ModBlocks.glassBell, 7);
|
||||
add(ModBlocks.researchStation, 520);
|
||||
add(ModBlocks.augmentationTable, 284);
|
||||
add(new ItemStack(ModBlocks.alchemicalChest, 1, 0), 576);
|
||||
add(new ItemStack(ModBlocks.alchemicalChest, 1, 1), 16448);
|
||||
add(new ItemStack(ModBlocks.alchemicalChest, 1, 2), 65600);
|
||||
|
@ -47,36 +46,7 @@ public class EETestSuite extends EnergyValueTestSuite {
|
|||
add(new ItemStack(ModItems.alchemicalUpgrade, 1, 0), null);
|
||||
add(new ItemStack(ModItems.alchemicalUpgrade, 1, 1), null);
|
||||
add(new ItemStack(ModItems.alchemicalUpgrade, 1, 2), null);
|
||||
add(ModItems.diviningRod, 16);
|
||||
add(ModItems.alchenomicon, 8352);
|
||||
add(new ItemStack(ModItems.matter, 1, 0), null);
|
||||
add(new ItemStack(ModItems.matter, 1, 1), null);
|
||||
add(new ItemStack(ModItems.matter, 1, 2), null);
|
||||
add(new ItemStack(ModItems.matter, 1, 3), null);
|
||||
add(new ItemStack(ModItems.matter, 1, 4), null);
|
||||
add(new ItemStack(ModItems.matter, 1, 5), null);
|
||||
add(new ItemStack(ModItems.matter, 1, 6), null);
|
||||
add(new ItemStack(ModItems.matter, 1, 7), null);
|
||||
add(new ItemStack(ModItems.matter, 1, 8), null);
|
||||
add(new ItemStack(ModItems.gem, 1, 0), null);
|
||||
add(new ItemStack(ModItems.gem, 1, 1), null);
|
||||
add(new ItemStack(ModItems.gem, 1, 2), null);
|
||||
add(new ItemStack(ModItems.gem, 1, 3), null);
|
||||
add(new ItemStack(ModItems.gem, 1, 4), null);
|
||||
add(new ItemStack(ModItems.gem, 1, 5), null);
|
||||
add(new ItemStack(ModItems.gem, 1, 6), null);
|
||||
add(ModItems.lootBall, null);
|
||||
add(ModItems.knowledgeScroll, null);
|
||||
add(ModItems.potionLethe, null);
|
||||
add(ModItems.shovelDarkMatter, null);
|
||||
add(ModItems.pickAxeDarkMatter, null);
|
||||
add(ModItems.hammerDarkMatter, null);
|
||||
add(ModItems.axeDarkMatter, null);
|
||||
add(ModItems.hoeDarkMatter, null);
|
||||
add(ModItems.fishingRodDarkMatter, null);
|
||||
add(ModItems.shearsDarkMatter, null);
|
||||
add(ModItems.bowDarkMatter, null);
|
||||
add(ModItems.swordDarkMatter, null);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
package com.pahimar.ee3.tileentity;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class TileEntityAugmentationTable extends TileEntityEE implements IInventory
|
||||
{
|
||||
public static final int INVENTORY_SIZE = 3;
|
||||
public static final int INPUT_SLOT_INVENTORY_INDEX = 0;
|
||||
public static final int AUGMENT_SLOT_INVENTORY_INDEX = 1;
|
||||
public static final int OUTPUT_SLOT_INVENTORY_INDEX = 2;
|
||||
|
||||
/**
|
||||
* The ItemStacks that hold the items currently being used in the Glass Bell
|
||||
*/
|
||||
private ItemStack[] inventory;
|
||||
|
||||
public TileEntityAugmentationTable()
|
||||
{
|
||||
inventory = new ItemStack[INVENTORY_SIZE];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return inventory.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIndex)
|
||||
{
|
||||
return inventory[slotIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotIndex, int decrementAmount)
|
||||
{
|
||||
ItemStack itemStack = getStackInSlot(slotIndex);
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (itemStack.stackSize <= decrementAmount)
|
||||
{
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemStack = itemStack.splitStack(decrementAmount);
|
||||
if (itemStack.stackSize == 0)
|
||||
{
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex)
|
||||
{
|
||||
ItemStack itemStack = getStackInSlot(slotIndex);
|
||||
if (itemStack != null)
|
||||
{
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
inventory[slotIndex] = itemStack;
|
||||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return this.hasCustomName() ? this.getCustomName() : Names.Containers.AUGMENTATION_TABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return this.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityplayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbtTagCompound);
|
||||
|
||||
// Write the ItemStacks in the inventory to NBT
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex)
|
||||
{
|
||||
if (inventory[currentIndex] != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte) currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag("Items", tagList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbtTagCompound);
|
||||
|
||||
// Read in the ItemStacks in the inventory from NBT
|
||||
NBTTagList tagList = nbtTagCompound.getTagList("Items", 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
||||
byte slotIndex = tagCompound.getByte("Slot");
|
||||
if (slotIndex >= 0 && slotIndex < inventory.length)
|
||||
{
|
||||
inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.pahimar.ee3.tileentity;
|
|||
import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy;
|
||||
import com.pahimar.ee3.api.exchange.EnergyValue;
|
||||
import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
|
||||
import com.pahimar.ee3.api.exchange.ITransmutationContainer;
|
||||
import com.pahimar.ee3.block.BlockAshInfusedStoneSlab;
|
||||
import com.pahimar.ee3.item.ItemAlchenomicon;
|
||||
import com.pahimar.ee3.item.ItemMiniumStone;
|
||||
|
@ -25,7 +26,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class TileEntityTransmutationTablet extends TileEntityEE implements ISidedInventory {
|
||||
public class TileEntityTransmutationTablet extends TileEntityEE implements ISidedInventory, ITransmutationContainer {
|
||||
|
||||
public static final int INVENTORY_SIZE = 10;
|
||||
public static final int ITEM_INPUT_1 = 0;
|
||||
|
@ -53,9 +54,14 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
|||
inventory = new ItemStack[INVENTORY_SIZE];
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnergyValue getAvailableEnergy()
|
||||
{
|
||||
if (inventory[STONE_INDEX] != null && inventory[STONE_INDEX].getItem() instanceof ItemMiniumStone) {
|
||||
return availableEnergy;
|
||||
} else {
|
||||
return new EnergyValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
public EnergyValue getStoredEnergy()
|
||||
|
@ -71,6 +77,7 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
|||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ItemStack> getPlayerKnowledge() {
|
||||
|
||||
if (playerKnowledge != null) {
|
||||
|
@ -81,6 +88,7 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerKnowledgeUpdate(PlayerKnowledge playerKnowledge) {
|
||||
this.playerKnowledge = playerKnowledge;
|
||||
}
|
||||
|
@ -88,6 +96,7 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
|||
/**
|
||||
* https://github.com/pahimar/Equivalent-Exchange-3/issues/1062
|
||||
*/
|
||||
@Override
|
||||
public void consumeInventoryForEnergyValue(ItemStack outputItemStack) {
|
||||
|
||||
EnergyValue outputEnergyValue = EnergyValueRegistryProxy.getEnergyValueForStack(outputItemStack);
|
||||
|
@ -126,10 +135,11 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
|||
updateEnergyValueFromInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEnergyValueFromInventory() {
|
||||
|
||||
float newEnergyValue = storedEnergy.getValue();
|
||||
for (int i = 0; i <= STONE_INDEX; i++) {
|
||||
for (int i = 0; i < STONE_INDEX; i++) {
|
||||
if (inventory[i] != null && EnergyValueRegistryProxy.hasEnergyValue(inventory[i])) {
|
||||
newEnergyValue += EnergyValueRegistryProxy.getEnergyValueForStack(inventory[i]).getValue();
|
||||
}
|
||||
|
@ -351,4 +361,19 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getXCoord() {
|
||||
return xCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYCoord() {
|
||||
return yCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZCoord() {
|
||||
return zCoord;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.pahimar.ee3.util;
|
|||
|
||||
import com.pahimar.ee3.reference.Reference;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class EntityHelper
|
||||
|
@ -23,4 +25,8 @@ public class EntityHelper
|
|||
entity.getEntityData().setTag(Reference.LOWERCASE_MOD_ID, nbtTagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isHostileEntity(final EntityLivingBase entity) {
|
||||
return entity instanceof IMob;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,13 @@ package com.pahimar.ee3.util;
|
|||
|
||||
import com.pahimar.ee3.reference.Comparators;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemStackUtils {
|
||||
|
@ -83,4 +87,26 @@ public class ItemStackUtils {
|
|||
public static void setOwnerName(ItemStack itemStack, EntityPlayer entityPlayer) {
|
||||
NBTHelper.setString(itemStack, Names.NBT.OWNER, entityPlayer.getDisplayName());
|
||||
}
|
||||
|
||||
public static ItemStack convertObjectToItemStack(final Object obj) {
|
||||
if (obj instanceof Item) {
|
||||
return new ItemStack((Item)obj);
|
||||
}
|
||||
if (obj instanceof Block) {
|
||||
return new ItemStack((Block)obj);
|
||||
}
|
||||
if (obj instanceof ItemStack) {
|
||||
return (ItemStack)obj;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Object[] convertSingleStackToPluralStacks(final ItemStack stack) {
|
||||
final ArrayList<ItemStack> list = new ArrayList<>();
|
||||
for (int i = 0; i < stack.stackSize; ++i) {
|
||||
final ItemStack currentStack = new ItemStack(stack.getItem(), 1, stack.getItemDamage());
|
||||
list.add(currentStack);
|
||||
}
|
||||
return list.toArray();
|
||||
}
|
||||
}
|
||||
|
|
22
src/main/java/com/pahimar/ee3/util/ItemUtil.java
Normal file
22
src/main/java/com/pahimar/ee3/util/ItemUtil.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package com.pahimar.ee3.util;
|
||||
|
||||
import com.pahimar.ee3.init.ModItems;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class ItemUtil {
|
||||
|
||||
private static double rand;
|
||||
|
||||
public static void dropMiniumShard(final EntityPlayer player, final EntityLivingBase entity) {
|
||||
if (EntityHelper.isHostileEntity(entity)) {
|
||||
ItemUtil.rand = Math.random();
|
||||
if (ItemUtil.rand < 0.15) {
|
||||
entity.dropItem(ModItems.shardMinium, 1);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,12 @@ package com.pahimar.ee3.util;
|
|||
|
||||
import com.pahimar.ee3.exchange.OreStack;
|
||||
import com.pahimar.ee3.exchange.WrappedStack;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
|
@ -224,4 +229,78 @@ public class RecipeHelper
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void addRecipe(final ItemStack output, final Object... input) {
|
||||
GameRegistry.addShapelessRecipe(output, input);
|
||||
}
|
||||
|
||||
public static void addRecipe(final ItemStack output, final ItemStack transmutationStone, final Object... input) {
|
||||
final Object[] inputs = new Object[input.length + 1];
|
||||
System.arraycopy(input, 0, inputs, 0, input.length);
|
||||
inputs[input.length] = transmutationStone;
|
||||
addRecipe(output, inputs);
|
||||
}
|
||||
|
||||
public static void addRecipe(final Block output, final Object... input) {
|
||||
addRecipe(new ItemStack(output), input);
|
||||
}
|
||||
|
||||
public static void addRecipe(final Block output, final int count, final Object... input) {
|
||||
addRecipe(new ItemStack(output, count), input);
|
||||
}
|
||||
|
||||
public static void addRecipe(final Item output, final Object... input) {
|
||||
addRecipe(new ItemStack(output), input);
|
||||
}
|
||||
|
||||
public static void addRecipe(final Item output, final int count, final Object... input) {
|
||||
addRecipe(new ItemStack(output, count), input);
|
||||
}
|
||||
|
||||
public static Object[] getMetaCycle(final Object input, final int n) {
|
||||
final ArrayList<ItemStack> list = new ArrayList<>();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
final ItemStack stack = ItemStackUtils.convertObjectToItemStack(input);
|
||||
stack.setItemDamage(i);
|
||||
list.add(stack);
|
||||
}
|
||||
return list.toArray();
|
||||
}
|
||||
|
||||
public static Object[] getMetaCycle(final Object input, final int n, final int... excludedMeta) {
|
||||
final ArrayList<ItemStack> list = new ArrayList<>();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
for (final int j : excludedMeta) {
|
||||
if (i == j) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (i >= n) {
|
||||
break;
|
||||
}
|
||||
final ItemStack stack = ItemStackUtils.convertObjectToItemStack(input);
|
||||
stack.setItemDamage(i);
|
||||
list.add(stack);
|
||||
}
|
||||
return list.toArray();
|
||||
}
|
||||
|
||||
public static void addSmeltingRecipe(final ItemStack input, final ItemStack stone, final ItemStack fuel) {
|
||||
final ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(input);
|
||||
if (input == null || input.getItem() == null || result == null) {
|
||||
return;
|
||||
}
|
||||
final Object[] list = new Object[9];
|
||||
list[0] = stone;
|
||||
list[1] = fuel;
|
||||
for (int i = 2; i < 9; ++i) {
|
||||
list[i] = new ItemStack(input.getItem(), 1, input.getItemDamage());
|
||||
}
|
||||
if (result.stackSize * 7 <= result.getItem().getItemStackLimit()) {
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(result.getItem(), result.stackSize * 7, result.getItemDamage()), list);
|
||||
}
|
||||
else {
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(result.getItem(), result.getItem().getItemStackLimit(), result.getItemDamage()), list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
101
src/main/java/com/pahimar/ee3/util/TransmutationHelper.java
Normal file
101
src/main/java/com/pahimar/ee3/util/TransmutationHelper.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
package com.pahimar.ee3.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.pahimar.ee3.handler.EquivalencyHandler;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TransmutationHelper {
|
||||
|
||||
public static ItemStack previousBlockStack;
|
||||
public static ItemStack currentBlockStack;
|
||||
public static ItemStack targetBlockStack;
|
||||
|
||||
public static boolean transmuteInWorld(final World world, final EntityPlayer player, final ItemStack stack, final int x, final int y, final int z, final Block target, final int targetMeta) {
|
||||
world.setBlock(x, y, z, target, targetMeta, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String formatTargetBlockInfo(final ItemStack targetBlock) {
|
||||
if (targetBlock != null) {
|
||||
return TransmutationHelper.targetBlockStack.getUnlocalizedName() + ":" + TransmutationHelper.targetBlockStack.getItemDamage();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void updateTargetBlock(final World world, final int x, final int y, final int z) {
|
||||
final Block currentBlock = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (currentBlock != null) {
|
||||
meta = currentBlock.damageDropped(meta);
|
||||
TransmutationHelper.currentBlockStack = new ItemStack(currentBlock, 1, meta);
|
||||
if (TransmutationHelper.previousBlockStack == null) {
|
||||
TransmutationHelper.previousBlockStack = TransmutationHelper.currentBlockStack;
|
||||
TransmutationHelper.targetBlockStack = getNextBlock(TransmutationHelper.currentBlockStack.getItem(), TransmutationHelper.currentBlockStack.getItemDamage());
|
||||
}
|
||||
else if (!EquivalencyHandler.instance().areEquivalent(TransmutationHelper.previousBlockStack, TransmutationHelper.currentBlockStack)) {
|
||||
TransmutationHelper.previousBlockStack = TransmutationHelper.currentBlockStack;
|
||||
TransmutationHelper.targetBlockStack = getNextBlock(TransmutationHelper.currentBlockStack.getItem(), TransmutationHelper.currentBlockStack.getItemDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getNextBlock(final Item id, final int meta) {
|
||||
final ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(id, meta);
|
||||
final ItemStack nextStack = null;
|
||||
if (list != null) {
|
||||
return getNextBlock(id, meta, id, meta);
|
||||
}
|
||||
return nextStack;
|
||||
}
|
||||
|
||||
private static ItemStack getNextBlock(final Item id, final int meta, final Item origId, final int origMeta) {
|
||||
final ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(id, meta);
|
||||
ItemStack nextStack = null;
|
||||
if (list == null) {
|
||||
return nextStack;
|
||||
}
|
||||
nextStack = EquivalencyHandler.instance().getNextInList(id, meta);
|
||||
nextStack.stackSize = 1;
|
||||
if (nextStack.getItem() == origId && nextStack.getItemDamage() == origMeta) {
|
||||
return nextStack;
|
||||
}
|
||||
if (nextStack.getItem() instanceof ItemBlock) {
|
||||
return nextStack;
|
||||
}
|
||||
return getNextBlock(nextStack.getItem(), nextStack.getItemDamage(), origId, origMeta);
|
||||
}
|
||||
|
||||
public static ItemStack getPreviousBlock(final Item itemID, final int meta) {
|
||||
final ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(itemID, meta);
|
||||
final ItemStack prevStack = null;
|
||||
if (list != null) {
|
||||
return getPreviousBlock(itemID, meta, itemID, meta);
|
||||
}
|
||||
return prevStack;
|
||||
}
|
||||
|
||||
private static ItemStack getPreviousBlock(final Item id, final int meta, final Item origId, final int origMeta) {
|
||||
final ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(id, meta);
|
||||
ItemStack prevStack = null;
|
||||
if (list == null) {
|
||||
return prevStack;
|
||||
}
|
||||
prevStack = EquivalencyHandler.instance().getPrevInList(id, meta);
|
||||
prevStack.stackSize = 1;
|
||||
if (prevStack.getItem() == origId && prevStack.getItemDamage() == origMeta) {
|
||||
return prevStack;
|
||||
}
|
||||
if (prevStack.getItem() instanceof ItemBlock) {
|
||||
return prevStack;
|
||||
}
|
||||
return getPreviousBlock(prevStack.getItem(), prevStack.getItemDamage(), origId, origMeta);
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 404 B |
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 400 B |
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 351 B |
Loading…
Reference in a new issue