Commit 97da6383 authored by mrAppleXZ's avatar mrAppleXZ 💾

Items in the Stone Crusher

parent fc333910
......@@ -4,8 +4,11 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
......@@ -149,6 +152,24 @@ public class TESRStoneCrusher extends TESRMultiblock<TileStoneCrusher>
}
}
//item
{
ItemStack stack = te.handler.getStackInSlot(0);
if(!stack.isEmpty())
{
GlStateManager.pushMatrix();
GlStateManager.translate(1.5f, 0.13f, 0.5f);
GlStateManager.scale(0.5f, 0.5f, 0.5f);
if (!(stack.getItem() instanceof ItemBlock))
{
GlStateManager.translate(0, -0.22f, 0);
GlStateManager.rotate(90, 1, 0, 0);
}
Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.FIXED);
GlStateManager.popMatrix();
}
}
GlStateManager.popMatrix();
}
}
......@@ -48,6 +48,7 @@ public class BlockStoneCrusher extends BlockMultiblockPart
{
public BlockPos lever = new BlockPos(2, 0, 0);
public BlockPos handle = new BlockPos(1, 0, 1);
public BlockPos anvil = new BlockPos(0, 0, 0);
public Multiblock()
{
......@@ -71,7 +72,7 @@ public class BlockStoneCrusher extends BlockMultiblockPart
return true;
});
arr.getMap().putAll(CollectionUtils.createMap(BlockPos.class, BlockArrayEntry.class,
new BlockPos(0, 0, 0), new BlockArrayEntry(Blocks.ANVIL, new ItemStack(Blocks.ANVIL)),
anvil, new BlockArrayEntry(Blocks.ANVIL, new ItemStack(Blocks.ANVIL)),
new BlockPos(0, 2, 0), rope,
new BlockPos(1, 2, 0), rope,
new BlockPos(1, 0, 0), rope_cog,
......
package ru.pearx.purmag.common.tiles;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import ru.pearx.libmc.common.ItemStackUtils;
import ru.pearx.libmc.common.nbt.NBTTagCompoundBuilder;
import ru.pearx.libmc.common.structure.multiblock.IMultiblockPart;
import ru.pearx.libmc.common.structure.multiblock.Multiblock;
import ru.pearx.libmc.common.structure.multiblock.events.MultiblockActivatedEvent;
import ru.pearx.libmc.common.tiles.TileMultiblockMaster;
import ru.pearx.libmc.common.structure.multiblock.events.MultiblockBreakEvent;
import ru.pearx.purmag.common.blocks.multiblock.MultiblockRegistry;
import scala.reflect.api.Trees;
import javax.annotation.Nullable;
......@@ -141,10 +139,41 @@ public class TileStoneCrusher extends TilePMMultiblockMaster
}
}
//drop the anvil
if (MultiblockRegistry.STONE_CRUSHER.lever.equals(original))
else if (MultiblockRegistry.STONE_CRUSHER.lever.equals(original))
{
}
//insert the item
else if(MultiblockRegistry.STONE_CRUSHER.anvil.equals(original) && getSpins() > 0)
{
if(evt.getPlayer().isSneaking())
{
if(!handler.getStackInSlot(0).isEmpty())
{
evt.getPlayer().addItemStackToInventory(handler.extractItem(0, 64, false));
return true;
}
}
else
{
ItemStack remainder = handler.insertItem(0, evt.getPlayer().getHeldItem(evt.getHand()), false);
boolean changed = !ItemStack.areItemStacksEqualUsingNBTShareTag(remainder, evt.getPlayer().getHeldItem(evt.getHand()));
if(changed)
{
evt.getPlayer().setHeldItem(evt.getHand(), remainder);
return true;
}
}
}
return false;
}
@Override
public void handleBreak(MultiblockBreakEvent evt, IMultiblockPart part)
{
if(getOriginalPos(part.getPos()).equals(MultiblockRegistry.STONE_CRUSHER.anvil))
{
ItemStackUtils.drop(handler, part.getWorld(), part.getPos());
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment