pushing broken code, its fun to look at though

This commit is contained in:
Cricket committed 2015-06-01 14:15:05 -04:00
1 parent 47fcd33c65
commit 49c9a7a1a5
10 files changed
+477

No files matched your search

@@ -573,6 +573,14 @@ public enum Features {
}
},
DECHISEL{
@Override
void addBlocks(){
BlockDeChisel deChisel = new BlockDeChisel();
GameRegistry.registerBlock(deChisel, deChisel.getUnlocalizedName());
}
},
DIAMOND_BLOCK {
@Override
@@ -0,0 +1,25 @@
package com.cricketcraft.chisel.block;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.block.tileentity.TileEntityDeChisel;
import com.cricketcraft.chisel.init.ChiselTabs;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockDeChisel extends BlockContainer {
public BlockDeChisel() {
super(Material.iron);
setCreativeTab(ChiselTabs.tabChisel);
setHardness(2.0F);
setResistance(10.0F);
setBlockName("dechisel");
setBlockTextureName(Chisel.MOD_ID + ":DeChisel");
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityDeChisel();
}
}
@@ -0,0 +1,169 @@
package com.cricketcraft.chisel.block.tileentity;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.carving.Carving;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class TileEntityDeChisel extends TileEntity implements ISidedInventory{
private final int CHISEL = 0, INPUT = 1;
private ItemStack[] inventory = new ItemStack[2];
private String name = "deChisel";
@Override
public void updateEntity(){
if(worldObj.getWorldTime() % 20 == 0){
if(inventory[CHISEL] != null && inventory[INPUT] != null){
ItemStack target = inventory[INPUT];
ItemStack output = new ItemStack(Carving.chisel.getGroupVariations(Block.getBlockFromItem(target.getItem()), target.getItemDamage()).get(0).getBlock(), target.stackSize);
if(worldObj.getTileEntity(xCoord, yCoord - 1, zCoord) instanceof IInventory) {
IInventory inventory = (IInventory) worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
pushToThisInventory(inventory, output);
}
}
}
}
private void pushToThisInventory(IInventory inv, ItemStack output){
for(int slot = 0; slot < inv.getSizeInventory(); slot++){
if(inv.getStackInSlot(slot) == null){
setInventorySlotContents(slot, output);
}
}
}
public ItemStack[] getInventory() {
return inventory;
}
@Override
public int getSizeInventory() {
return inventory.length;
}
@Override
public ItemStack getStackInSlot(int slot) {
return inventory[slot];
}
@Override
public ItemStack decrStackSize(int slot, int size) {
if (inventory[slot] != null) {
ItemStack is;
if (inventory[slot].stackSize <= size) {
is = inventory[slot];
inventory[slot] = null;
return is;
} else {
is = inventory[slot].splitStack(size);
if (inventory[slot].stackSize == 0)
inventory[slot] = null;
return is;
}
} else
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
if (inventory[slot] != null) {
ItemStack is = inventory[slot];
inventory[slot] = null;
return is;
} else
return null;
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
inventory[slot] = stack;
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
stack.stackSize = getInventoryStackLimit();
}
}
@Override
public String getInventoryName(){
return name;
}
@Override
public boolean canUpdate(){
return true;
}
@Override
public void readFromNBT(NBTTagCompound tagCompound){
}
@Override
public void writeToNBT(NBTTagCompound tagCompound){
}
@Override
public boolean canExtractItem(int slot, ItemStack stack, int side){
return (side == 0 && slot == 1) ? true : false;
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
if(side == 0) return new int[] {INPUT};
if(side == 1) return new int[] {CHISEL, INPUT};
return new int[0];
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, int side){
return side == 1 ? true : false;
}
@Override
public void openInventory(){
}
@Override
public void closeInventory(){
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
if(stack == null){
return false;
}
switch (slot){
case INPUT:
return !Carving.chisel.getItemsForChiseling(stack).isEmpty();
case CHISEL:
return stack.getItem() instanceof IChiselItem;
default:
return false;
}
}
@Override
public int getInventoryStackLimit(){
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return true;
}
@Override
public boolean hasCustomInventoryName(){
return false;
}
}
@@ -0,0 +1,79 @@
// Date: 6/1/2015 1:45:59 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
package com.cricketcraft.chisel.client.render.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelDeChisel extends ModelBase
{
//fields
ModelRenderer Shape1;
ModelRenderer Shape2;
ModelRenderer Shape3;
ModelRenderer Shape4;
public ModelDeChisel()
{
textureWidth = 128;
textureHeight = 32;
Shape1 = new ModelRenderer(this, 50, 0);
Shape1.addBox(0F, 0F, 0F, 16, 3, 16);
Shape1.setRotationPoint(-8F, 12F, -8F);
Shape1.setTextureSize(128, 32);
Shape1.mirror = true;
setRotation(Shape1, 0F, 0F, 0F);
Shape2 = new ModelRenderer(this, 0, 0);
Shape2.addBox(0F, 0F, 0F, 12, 3, 12);
Shape2.setRotationPoint(-6F, 15F, -6F);
Shape2.setTextureSize(128, 32);
Shape2.mirror = true;
setRotation(Shape2, 0F, 0F, 0F);
Shape3 = new ModelRenderer(this, 0, 18);
Shape3.addBox(0F, 0F, 0F, 8, 3, 8);
Shape3.setRotationPoint(-4F, 18F, -4F);
Shape3.setTextureSize(128, 32);
Shape3.mirror = true;
setRotation(Shape3, 0F, 0F, 0F);
Shape4 = new ModelRenderer(this, 67, 20);
Shape4.addBox(0F, 0F, 0F, 4, 3, 4);
Shape4.setRotationPoint(-2F, 21F, -2F);
Shape4.setTextureSize(128, 32);
Shape4.mirror = true;
setRotation(Shape4, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
Shape1.render(f5);
Shape2.render(f5);
Shape3.render(f5);
Shape4.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}
@@ -0,0 +1,15 @@
package com.cricketcraft.chisel.client.render.tile;
import com.cricketcraft.chisel.client.render.model.ModelDeChisel;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
public class RenderDeChisel extends TileEntitySpecialRenderer{
private ModelDeChisel deChisel = new ModelDeChisel();
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
deChisel.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
}
}
@@ -11,6 +11,7 @@ import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;
public final class ChiselBlocks {
public static final Block autoChisel = null;
public static final BlockDeChisel deChisel = null;
public static final BlockCarvable antiBlock = null;
public static final BlockCarvable marble = null;
public static final BlockCarvable marble_pillar = null;
@@ -0,0 +1,174 @@
package com.cricketcraft.chisel.inventory;
import com.cricketcraft.chisel.block.tileentity.TileEntityDeChisel;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerDeChisel extends Container{
public EntityPlayer player;
public TileEntityDeChisel deChisel;
public ContainerDeChisel(InventoryPlayer player, TileEntityDeChisel deChisel){
this.player = player.player;
this.deChisel = deChisel;
addSlot(deChisel, 0, 53, 15);
addSlot(deChisel, 1, 103, 15);
bindPlayerInventory(player);
}
private void addSlot(IInventory inv, final int id, int x, int y) {
addSlotToContainer(new Slot(inv, id, x, y) {
@Override
public boolean isItemValid(ItemStack arg0) {
return inventory.isItemValidForSlot(id, arg0);
}
});
}
protected void bindPlayerInventory(InventoryPlayer invPlayer) {
for (int row = 0; row < 3; row++) {
for (int column = 0; column < 9; column++) {
addSlotToContainer(new Slot(invPlayer, column + row * 9 + 9, 8 + column * 18, 84 + row * 18));
}
}
for (int slotNumber = 0; slotNumber < 9; slotNumber++) {
addSlotToContainer(new Slot(invPlayer, slotNumber, 8 + slotNumber * 18, 142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return deChisel.isUseableByPlayer(player);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber) {
ItemStack itemStack = null;
Slot slot = (Slot) this.inventorySlots.get(slotNumber);
if (slot != null && slot.getHasStack()) {
ItemStack itemStack1 = slot.getStack();
itemStack = itemStack1.copy();
// if we are in the auto chisel
if (slotNumber <= 6) {
if (!this.mergeItemStack(itemStack1, 7, 42, false)) {
return null;
}
// otherwise just put it in one of the machine slots
} else if (!this.mergeItemStack(itemStack1, 0, 7, false)) {
return null;
}
if (itemStack1.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
if (itemStack1.stackSize == itemStack.stackSize) {
return null;
}
slot.onPickupFromSlot(player, itemStack1);
}
return itemStack;
}
/**
* Added validation of slot input
*
* @author CrazyPants
*/
@Override
protected boolean mergeItemStack(ItemStack par1ItemStack, int fromIndex, int toIndex, boolean reversOrder) {
boolean result = false;
int checkIndex = fromIndex;
if (reversOrder) {
checkIndex = toIndex - 1;
}
Slot slot;
ItemStack itemstack1;
if (par1ItemStack.isStackable()) {
while (par1ItemStack.stackSize > 0 && (!reversOrder && checkIndex < toIndex || reversOrder && checkIndex >= fromIndex)) {
slot = (Slot) this.inventorySlots.get(checkIndex);
itemstack1 = slot.getStack();
if (itemstack1 != null && itemstack1.getItem() == par1ItemStack.getItem() && (!par1ItemStack.getHasSubtypes() || par1ItemStack.getItemDamage() == itemstack1.getItemDamage())
&& ItemStack.areItemStackTagsEqual(par1ItemStack, itemstack1) && slot.isItemValid(par1ItemStack)) {
int mergedSize = itemstack1.stackSize + par1ItemStack.stackSize;
int maxStackSize = Math.min(par1ItemStack.getMaxStackSize(), slot.getSlotStackLimit());
if (mergedSize <= maxStackSize) {
par1ItemStack.stackSize = 0;
itemstack1.stackSize = mergedSize;
slot.onSlotChanged();
result = true;
} else if (itemstack1.stackSize < maxStackSize) {
par1ItemStack.stackSize -= maxStackSize - itemstack1.stackSize;
itemstack1.stackSize = maxStackSize;
slot.onSlotChanged();
result = true;
}
}
if (reversOrder) {
--checkIndex;
} else {
++checkIndex;
}
}
}
if (par1ItemStack.stackSize > 0) {
if (reversOrder) {
checkIndex = toIndex - 1;
} else {
checkIndex = fromIndex;
}
while (!reversOrder && checkIndex < toIndex || reversOrder && checkIndex >= fromIndex) {
slot = (Slot) this.inventorySlots.get(checkIndex);
itemstack1 = slot.getStack();
if (itemstack1 == null && slot.isItemValid(par1ItemStack)) {
ItemStack in = par1ItemStack.copy();
in.stackSize = Math.min(in.stackSize, slot.getSlotStackLimit());
slot.putStack(in);
slot.onSlotChanged();
if (in.stackSize >= par1ItemStack.stackSize) {
par1ItemStack.stackSize = 0;
} else {
par1ItemStack.stackSize -= in.stackSize;
}
result = true;
break;
}
if (reversOrder) {
--checkIndex;
} else {
++checkIndex;
}
}
}
return result;
}
}
@@ -1,11 +1,13 @@
package com.cricketcraft.chisel.proxy;
import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
import com.cricketcraft.chisel.block.tileentity.TileEntityDeChisel;
import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
import com.cricketcraft.chisel.client.player.PlayerSpecials;
import com.cricketcraft.chisel.client.render.*;
import com.cricketcraft.chisel.client.render.item.ItemChiselRenderer;
import com.cricketcraft.chisel.client.render.tile.RenderAutoChisel;
import com.cricketcraft.chisel.client.render.tile.RenderDeChisel;
import com.cricketcraft.chisel.client.render.tile.RenderPresent;
import com.cricketcraft.chisel.entity.EntityBallOMoss;
import com.cricketcraft.chisel.entity.EntityChiselSnowman;
@@ -44,9 +46,11 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new RendererMultiLayer());
RenderAutoChisel rac = new RenderAutoChisel();
RenderDeChisel deChisel = new RenderDeChisel();
RenderingRegistry.registerBlockHandler(rac);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ChiselBlocks.autoChisel), rac);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAutoChisel.class, rac);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDeChisel.class, deChisel);
RenderPresent rp = new RenderPresent();
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ChiselBlocks.present), rp);
@@ -1,5 +1,6 @@
package com.cricketcraft.chisel.proxy;
import com.cricketcraft.chisel.block.tileentity.TileEntityDeChisel;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
@@ -13,6 +14,7 @@ public class CommonProxy {
public void registerTileEntities() {
GameRegistry.registerTileEntity(TileEntityAutoChisel.class, "autoChisel");
GameRegistry.registerTileEntity(TileEntityPresent.class, "tile.chisel.present");
GameRegistry.registerTileEntity(TileEntityDeChisel.class, "deChisel");
}
public void preInit() {
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB