port to forestry 4.2

This commit is contained in:
marcin212 committed 2016-10-20 02:56:31 +02:00
1 parent dbc5c1a564
commit f969f63b66
3697 files changed
+78372

No files matched your search

@@ -0,0 +1,135 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.core.block;
import net.minecraft.util.MovingObjectPosition;
import binnie.core.BinnieCore;
import net.minecraft.block.Block;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.List;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import net.minecraft.world.World;
import net.minecraft.block.material.Material;
import net.minecraft.block.BlockContainer;
public class BlockMetadata extends BlockContainer implements IBlockMetadata
{
static int temporyMeta;
public BlockMetadata(final Material material) {
super(material);
}
@Override
public ArrayList<ItemStack> getDrops(final World world, final int x, final int y, final int z, final int blockMeta, final int fortune) {
return getBlockDropped(this, world, x, y, z, blockMeta);
}
@Override
public boolean removedByPlayer(final World world, final EntityPlayer player, final int x, final int y, final int z) {
return breakBlock(this, player, world, x, y, z);
}
@Override
public TileEntity createNewTileEntity(final World var1, final int i) {
return new TileEntityMetadata();
}
@Override
public boolean hasTileEntity(final int meta) {
return true;
}
@Override
public boolean onBlockEventReceived(final World par1World, final int par2, final int par3, final int par4, final int par5, final int par6) {
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
final TileEntity tileentity = par1World.getTileEntity(par2, par3, par4);
return tileentity != null && tileentity.receiveClientEvent(par5, par6);
}
@Override
public IIcon getIcon(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4, final int par5) {
final int metadata = TileEntityMetadata.getTileMetadata(par1IBlockAccess, par2, par3, par4);
return this.getIcon(par5, metadata);
}
@Override
public String getBlockName(final ItemStack par1ItemStack) {
return this.getLocalizedName();
}
@Override
public void getBlockTooltip(final ItemStack par1ItemStack, final List par3List) {
}
@Override
public int getPlacedMeta(final ItemStack item, final World world, final int x, final int y, final int z, final ForgeDirection clickedBlock) {
final int damage = TileEntityMetadata.getItemDamage(item);
return damage;
}
@Override
public int getDroppedMeta(final int tileMeta, final int blockMeta) {
return tileMeta;
}
public static ArrayList<ItemStack> getBlockDropped(final IBlockMetadata block, final World world, final int x, final int y, final int z, final int blockMeta) {
final ArrayList<ItemStack> array = new ArrayList<ItemStack>();
final TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null && !tile.hasDroppedBlock()) {
final int meta = block.getDroppedMeta(world.getBlockMetadata(x, y, z), tile.getTileMetadata());
array.add(TileEntityMetadata.getItemStack((Block) block, meta));
}
return array;
}
public static boolean breakBlock(final IBlockMetadata block, final EntityPlayer player, final World world, final int i, final int j, final int k) {
List<ItemStack> drops = new ArrayList<ItemStack>();
final Block block2 = (Block) block;
final TileEntityMetadata tile = TileEntityMetadata.getTile(world, i, j, k);
if (tile != null && !tile.hasDroppedBlock()) {
final int tileMeta = TileEntityMetadata.getTileMetadata(world, i, j, k);
drops = block2.getDrops(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
}
final boolean hasBeenBroken = world.setBlockToAir(i, j, k);
if (hasBeenBroken && BinnieCore.proxy.isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
for (final ItemStack drop : drops) {
block.dropAsStack(world, i, j, k, drop);
}
tile.dropBlock();
}
return hasBeenBroken;
}
@Override
public void dropAsStack(final World world, final int x, final int y, final int z, final ItemStack drop) {
this.dropBlockAsItem(world, x, y, z, drop);
}
@Override
public void breakBlock(final World par1World, final int par2, final int par3, final int par4, final Block par5, final int par6) {
super.breakBlock(par1World, par2, par3, par4, par5, par6);
par1World.removeTileEntity(par2, par3, par4);
}
public static ItemStack getPickBlock(final World world, final int x, final int y, final int z) {
final List<ItemStack> list = getBlockDropped((IBlockMetadata) world.getBlock(x, y, z), world, x, y, z, world.getBlockMetadata(x, y, z));
return list.isEmpty() ? null : list.get(0);
}
@Override
public ItemStack getPickBlock(final MovingObjectPosition target, final World world, final int x, final int y, final int z) {
return getPickBlock(world, x, y, z);
}
static {
BlockMetadata.temporyMeta = -1;
}
}
@@ -0,0 +1,24 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.core.block;
import java.util.List;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.world.World;
import net.minecraft.item.ItemStack;
import net.minecraft.block.ITileEntityProvider;
public interface IBlockMetadata extends ITileEntityProvider
{
int getPlacedMeta(final ItemStack p0, final World p1, final int p2, final int p3, final int p4, final ForgeDirection p5);
int getDroppedMeta(final int p0, final int p1);
String getBlockName(final ItemStack p0);
void getBlockTooltip(final ItemStack p0, final List p1);
void dropAsStack(final World p0, final int p1, final int p2, final int p3, final ItemStack p4);
}
@@ -0,0 +1,12 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.core.block;
public interface IMultipassBlock
{
int getNumberOfPasses();
int colorMultiplier(final int p0);
}
@@ -0,0 +1,71 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.core.block;
import net.minecraft.util.IIcon;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.world.World;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
public class ItemMetadata extends ItemBlock
{
public ItemMetadata(final Block block) {
super(block);
}
@Override
public int getMetadata(final int par1) {
return 0;
}
@Override
public boolean placeBlockAt(final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ, final int metadata) {
final Block block = this.field_150939_a;
if (!(block instanceof IBlockMetadata)) {
return false;
}
final int placedMeta = ((IBlockMetadata) block).getPlacedMeta(stack, world, x, y, z, ForgeDirection.values()[side]);
if (placedMeta < 0) {
return false;
}
if (!world.setBlock(x, y, z, block, metadata, 3)) {
return false;
}
if (world.getBlock(x, y, z) == block) {
final TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) {
tile.setTileMetadata(placedMeta, false);
}
block.onBlockPlacedBy(world, x, y, z, player, stack);
block.onPostBlockPlaced(world, x, y, z, metadata);
}
return true;
}
@Override
@SideOnly(Side.CLIENT)
public String getItemStackDisplayName(final ItemStack par1ItemStack) {
return ((IBlockMetadata) this.field_150939_a).getBlockName(par1ItemStack);
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(final ItemStack par1ItemStack, final EntityPlayer par2EntityPlayer, final List par3List, final boolean par4) {
((IBlockMetadata) this.field_150939_a).getBlockTooltip(par1ItemStack, par3List);
}
@Override
public IIcon getIconFromDamage(final int par1) {
return this.field_150939_a.getIcon(1, par1);
}
}
@@ -0,0 +1,49 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.core.block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.block.Block;
import org.lwjgl.opengl.GL11;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
public class ItemMetadataRenderer implements IItemRenderer
{
@Override
public boolean handleRenderType(final ItemStack item, final IItemRenderer.ItemRenderType type) {
return type == IItemRenderer.ItemRenderType.INVENTORY || type == IItemRenderer.ItemRenderType.ENTITY || type == IItemRenderer.ItemRenderType.EQUIPPED || type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON;
}
@Override
public boolean shouldUseRenderHelper(final IItemRenderer.ItemRenderType type, final ItemStack item, final IItemRenderer.ItemRendererHelper helper) {
if (type == IItemRenderer.ItemRenderType.INVENTORY) {
return helper == IItemRenderer.ItemRendererHelper.INVENTORY_BLOCK;
}
if (type == IItemRenderer.ItemRenderType.ENTITY) {
return helper == IItemRenderer.ItemRendererHelper.ENTITY_BOBBING || helper == IItemRenderer.ItemRendererHelper.ENTITY_ROTATION;
}
return (type == IItemRenderer.ItemRenderType.EQUIPPED || type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) && helper == IItemRenderer.ItemRendererHelper.EQUIPPED_BLOCK;
}
@Override
public void renderItem(final IItemRenderer.ItemRenderType type, final ItemStack item, final Object... data) {
GL11.glPushMatrix();
final Block block = Block.getBlockFromItem(item.getItem());
if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslated(0.5, 0.5, 0.5);
}
if (type == IItemRenderer.ItemRenderType.INVENTORY && block.getRenderBlockPass() != 0) {
GL11.glAlphaFunc(516, 0.1f);
GL11.glEnable(3042);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
}
GL11.glPushMatrix();
((RenderBlocks) data[0]).renderBlockAsItem(block, TileEntityMetadata.getItemDamage(item), 1.0f);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
@@ -0,0 +1,109 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.core.block;
import binnie.core.BinnieCore;
import net.minecraft.world.IBlockAccess;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.block.Block;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.renderer.Tessellator;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class MultipassBlockRenderer implements ISimpleBlockRenderingHandler
{
public static MultipassBlockRenderer instance;
private static int layer;
public MultipassBlockRenderer() {
MultipassBlockRenderer.instance = this;
}
private void setColour(final Tessellator tess, final int colour) {
final float var6 = (colour >> 16 & 0xFF) / 255.0f;
final float var7 = (colour >> 8 & 0xFF) / 255.0f;
final float var8 = (colour & 0xFF) / 255.0f;
GL11.glColor3f(var6, var7, var8);
}
public static int getLayer() {
return MultipassBlockRenderer.layer;
}
@Override
public void renderInventoryBlock(final Block block, final int meta, final int modelID, final RenderBlocks renderer) {
block.setBlockBoundsForItemRender();
renderer.setRenderBoundsFromBlock(block);
GL11.glTranslatef(-0.5f, -0.5f, -0.5f);
MultipassBlockRenderer.layer = 0;
while (MultipassBlockRenderer.layer < ((IMultipassBlock) block).getNumberOfPasses()) {
this.renderItem(block, renderer, meta);
++MultipassBlockRenderer.layer;
}
MultipassBlockRenderer.layer = 0;
}
@Override
public boolean renderWorldBlock(final IBlockAccess world, final int x, final int y, final int z, final Block block, final int modelId, final RenderBlocks renderer) {
boolean r = true;
MultipassBlockRenderer.layer = 0;
while (MultipassBlockRenderer.layer < ((IMultipassBlock) block).getNumberOfPasses()) {
r = renderer.renderStandardBlock(block, x, y, z);
++MultipassBlockRenderer.layer;
}
MultipassBlockRenderer.layer = 0;
return r;
}
@Override
public boolean shouldRender3DInInventory(final int i) {
return true;
}
@Override
public int getRenderId() {
return BinnieCore.multipassRenderID;
}
public void renderItem(final Block block, final RenderBlocks renderer, final int meta) {
this.setColor(((IMultipassBlock) block).colorMultiplier(meta));
final Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setNormal(0.0f, -1.0f, 0.0f);
renderer.renderFaceYNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 0, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0f, 1.0f, 0.0f);
renderer.renderFaceYPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 1, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0f, 0.0f, -1.0f);
renderer.renderFaceZNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 2, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0f, 0.0f, 1.0f);
renderer.renderFaceZPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 3, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1.0f, 0.0f, 0.0f);
renderer.renderFaceXNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 4, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0f, 0.0f, 0.0f);
renderer.renderFaceXPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 5, meta));
tessellator.draw();
}
public void setColor(final int l) {
final float f = (l >> 16 & 0xFF) / 255.0f;
final float f2 = (l >> 8 & 0xFF) / 255.0f;
final float f3 = (l & 0xFF) / 255.0f;
GL11.glColor3f(f, f2, f3);
}
static {
MultipassBlockRenderer.layer = 0;
}
}
@@ -0,0 +1,81 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.core.block;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.item.ItemBlock;
import org.lwjgl.opengl.GL11;
import net.minecraft.item.ItemStack;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraftforge.client.IItemRenderer;
public class MultipassItemRenderer implements IItemRenderer
{
private void render(final RenderBlocks renderer, final ItemStack item, final float f, final float g, final float h) {
GL11.glTranslatef(f, g, h);
final Block block = ((ItemBlock) item.getItem()).field_150939_a;
GL11.glEnable(3008);
if (block.getRenderBlockPass() != 0) {
GL11.glAlphaFunc(516, 0.1f);
GL11.glEnable(3042);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
}
else {
GL11.glAlphaFunc(516, 0.5f);
GL11.glDisable(3042);
}
MultipassBlockRenderer.instance.renderInventoryBlock(block, TileEntityMetadata.getItemDamage(item), 0, renderer);
if (block.getRenderBlockPass() == 0) {
GL11.glAlphaFunc(516, 0.1f);
}
GL11.glTranslatef(-f, -g, -h);
}
@Override
public boolean handleRenderType(final ItemStack item, final IItemRenderer.ItemRenderType type) {
switch (type) {
case ENTITY: {
return true;
}
case EQUIPPED: {
return true;
}
case INVENTORY: {
return true;
}
case EQUIPPED_FIRST_PERSON: {
return true;
}
default: {
return false;
}
}
}
@Override
public boolean shouldUseRenderHelper(final IItemRenderer.ItemRenderType type, final ItemStack item, final IItemRenderer.ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(final IItemRenderer.ItemRenderType type, final ItemStack item, final Object... data) {
switch (type) {
case ENTITY: {
this.render((RenderBlocks) data[0], item, 0.0f, 0.0f, 0.0f);
break;
}
case EQUIPPED:
case EQUIPPED_FIRST_PERSON: {
this.render((RenderBlocks) data[0], item, 0.5f, 0.5f, 0.5f);
break;
}
case INVENTORY: {
this.render((RenderBlocks) data[0], item, 0.0f, 0.0f, 0.0f);
break;
}
}
}
}
@@ -0,0 +1,110 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.core.block;
import net.minecraft.item.ItemStack;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import binnie.core.network.packet.MessageMetadata;
import binnie.core.BinnieCore;
import net.minecraft.network.Packet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class TileEntityMetadata extends TileEntity
{
private int meta;
private boolean droppedBlock;
public TileEntityMetadata() {
this.droppedBlock = false;
}
@Override
public boolean receiveClientEvent(final int par1, final int par2) {
if (par1 == 42) {
this.meta = par2;
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
return true;
}
@Override
public void readFromNBT(final NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.meta = nbt.getInteger("meta");
}
@Override
public void writeToNBT(final NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("meta", this.meta);
}
@Override
public boolean canUpdate() {
return false;
}
public int getTileMetadata() {
return this.meta;
}
public void setTileMetadata(final int meta, final boolean notify) {
if (this.meta != meta) {
this.meta = meta;
if (notify) {
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
}
}
@Override
public Packet getDescriptionPacket() {
return BinnieCore.instance.getNetworkWrapper().getPacketFrom(new MessageMetadata(this.xCoord, this.yCoord, this.zCoord, this.meta).GetMessage());
}
public static TileEntityMetadata getTile(final IBlockAccess world, final int x, final int y, final int z) {
final TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityMetadata)) {
return null;
}
return (TileEntityMetadata) tile;
}
public static ItemStack getItemStack(final Block block, final int damage) {
final ItemStack item = new ItemStack(block, 1, 0);
setItemDamage(item, damage);
return item;
}
public static void setItemDamage(final ItemStack item, final int i) {
item.setItemDamage((i < 16387) ? i : 16387);
final NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("meta", i);
item.setTagCompound(tag);
}
public static int getItemDamage(final ItemStack item) {
if (item.hasTagCompound() && item.getTagCompound().hasKey("meta")) {
return item.getTagCompound().getInteger("meta");
}
return item.getItemDamage();
}
public static int getTileMetadata(final IBlockAccess world, final int x, final int y, final int z) {
final TileEntityMetadata tile = getTile(world, x, y, z);
return (tile == null) ? 0 : tile.getTileMetadata();
}
public boolean hasDroppedBlock() {
return this.droppedBlock;
}
public void dropBlock() {
this.droppedBlock = true;
}
}