Fix #806 Chests now render akin to the vanilla chests
No files matched your search
@@ -20,4 +20,5 @@
|
||||
!/build.gradle
|
||||
!/build.xml
|
||||
!/gradlew
|
||||
!/gradlew.bat
|
||||
!/gradlew.bat
|
||||
.DS_Store
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -101,6 +102,25 @@ public class BlockBase extends BlockForestry {
|
||||
return definitions.get(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
MachineDefinition definition = definitions.get(world.getBlockMetadata(x, y, z));
|
||||
if (definition == null) {
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
return definition.getBoundingBox(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
MachineDefinition definition = definitions.get(world.getBlockMetadata(x, y, z));
|
||||
if (definition == null) {
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
return definition.getBoundingBox(x, y, z);
|
||||
}
|
||||
|
||||
/* CREATIVE INVENTORY */
|
||||
@SuppressWarnings("rawtypes")
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -35,7 +36,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.core.interfaces.IBlockRenderer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.render.TileRendererIndex;
|
||||
|
||||
public class MachineDefinition {
|
||||
|
||||
@@ -46,6 +46,8 @@ public class MachineDefinition {
|
||||
private final int meta;
|
||||
|
||||
public final IBlockRenderer renderer;
|
||||
|
||||
private float minX, minY, minZ, maxX, maxY, maxZ;
|
||||
|
||||
/* CRAFTING */
|
||||
public IRecipe[] recipes;
|
||||
@@ -67,6 +69,12 @@ public class MachineDefinition {
|
||||
faceMap[i] = 0;
|
||||
}
|
||||
|
||||
minX = 0;
|
||||
minY = 0;
|
||||
minZ = 0;
|
||||
maxX = 1;
|
||||
maxY = 1;
|
||||
maxZ = 1;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
@@ -80,6 +88,16 @@ public class MachineDefinition {
|
||||
public void setBlock(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public MachineDefinition setBoundingBox(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.maxZ = maxZ;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
registerTileEntity();
|
||||
@@ -97,6 +115,10 @@ public class MachineDefinition {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AxisAlignedBB getBoundingBox(int x, int y, int z) {
|
||||
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the tile entity with MC.
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -19,9 +21,15 @@ import forestry.core.GuiHandler;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.IPagedInventory;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
|
||||
public abstract class TileNaturalistChest extends TileBase implements IPagedInventory {
|
||||
private final int guiID;
|
||||
public float lidAngle;
|
||||
public float prevLidAngle;
|
||||
private int numPlayersUsing;
|
||||
private static float lidAngleVariationPerTick = 0.1F;
|
||||
|
||||
public TileNaturalistChest(ISpeciesRoot speciesRoot, int guiId) {
|
||||
setInternalInventory(new NaturalistInventoryAdapter(this, speciesRoot));
|
||||
@@ -29,6 +37,44 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve
|
||||
this.guiID = guiId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateClientSide() {
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
prevLidAngle = lidAngle;
|
||||
|
||||
if (numPlayersUsing > 0 && lidAngle == 0.0F) {
|
||||
playLidSound("random.chestopen");
|
||||
}
|
||||
|
||||
if (numPlayersUsing == 0 && lidAngle > 0.0F || numPlayersUsing > 0 && lidAngle < 1.0F) {
|
||||
float oldAngle = lidAngle;
|
||||
|
||||
if (numPlayersUsing > 0) {
|
||||
lidAngle += lidAngleVariationPerTick;
|
||||
} else {
|
||||
lidAngle -= lidAngleVariationPerTick;
|
||||
}
|
||||
|
||||
lidAngle = Math.max(Math.min(lidAngle, 1), 0);
|
||||
|
||||
if (lidAngle < 0.5F && oldAngle >= 0.5F) {
|
||||
playLidSound("random.chestclosed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void playLidSound(String sound) {
|
||||
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, sound, 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGui(EntityPlayer player) {
|
||||
player.openGui(ForestryAPI.instance, guiID, player.worldObj, xCoord, yCoord, zCoord);
|
||||
@@ -39,6 +85,18 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve
|
||||
player.openGui(ForestryAPI.instance, GuiHandler.encodeGuiData(guiID, page), player.worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeInt(numPlayersUsing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
numPlayersUsing = data.readInt();
|
||||
}
|
||||
|
||||
private static class NaturalistInventoryAdapter extends TileInventoryAdapter<TileNaturalistChest> {
|
||||
private final ISpeciesRoot speciesRoot;
|
||||
|
||||
@@ -56,5 +114,20 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
tile.numPlayersUsing++;
|
||||
tile.setNeedsNetworkUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
tile.numPlayersUsing--;
|
||||
if (tile.numPlayersUsing < 0) {
|
||||
tile.numPlayersUsing = 0;
|
||||
}
|
||||
tile.setNeedsNetworkUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ public class ContainerNaturalistInventory extends ContainerTile<TileNaturalistCh
|
||||
|
||||
public ContainerNaturalistInventory(InventoryPlayer player, TileNaturalistChest tile, int page) {
|
||||
super(tile, player, 18, 120);
|
||||
tile.openInventory();
|
||||
|
||||
// Inventory
|
||||
for (int x = 0; x < 5; x++) {
|
||||
@@ -38,4 +39,9 @@ public class ContainerNaturalistInventory extends ContainerTile<TileNaturalistCh
|
||||
@Override
|
||||
public void setSelection(PacketGuiSelect packet) {
|
||||
}
|
||||
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
tile.closeInventory();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.render;
|
||||
|
||||
import net.minecraft.client.model.ModelChest;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gadgets.TileNaturalistChest;
|
||||
import forestry.core.interfaces.IBlockRenderer;
|
||||
import forestry.core.utils.ForestryResource;
|
||||
|
||||
public class RenderNaturalistChest extends TileEntitySpecialRenderer implements IBlockRenderer {
|
||||
|
||||
private final ModelChest chestModel = new ModelChest();
|
||||
private final ResourceLocation texture;
|
||||
|
||||
public RenderNaturalistChest(String textureName) {
|
||||
texture = new ForestryResource(Defaults.TEXTURE_PATH_BLOCKS + "/" + textureName + ".png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryRender(double x, double y, double z) {
|
||||
render(ForgeDirection.EAST, 0, 0, x, y, z, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick) {
|
||||
TileNaturalistChest chest = (TileNaturalistChest) tileentity;
|
||||
render(chest.getOrientation(), chest.prevLidAngle, chest.lidAngle, x, y, z, partialTick);
|
||||
}
|
||||
|
||||
public void render(ForgeDirection orientation, float prevLidAngle, float lidAngle, double x, double y, double z, float partialTick) {
|
||||
GL11.glPushMatrix();
|
||||
bindTexture(texture);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
|
||||
GL11.glScalef(1.0F, -1.0F, -1.0F);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
|
||||
int rotation;
|
||||
switch (orientation) {
|
||||
case EAST:
|
||||
rotation = -90;
|
||||
break;
|
||||
case NORTH:
|
||||
rotation = 180;
|
||||
break;
|
||||
case WEST:
|
||||
rotation = 90;
|
||||
break;
|
||||
default:
|
||||
case SOUTH:
|
||||
rotation = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
|
||||
float angle = prevLidAngle + (lidAngle - prevLidAngle) * partialTick;
|
||||
angle = 1.0F - angle;
|
||||
angle = 1.0F - angle * angle * angle;
|
||||
chestModel.chestLid.rotateAngleX = -(angle * (float) Math.PI / 2.0F);
|
||||
chestModel.renderAll();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -148,6 +148,7 @@ import forestry.core.items.ItemScoop;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.EntitySnowFX;
|
||||
import forestry.core.render.RenderNaturalistChest;
|
||||
import forestry.core.utils.ShapedRecipeCustom;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.StringUtil;
|
||||
@@ -175,7 +176,7 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
private final Map<String, String[]> defaultPlantableFlowers = new HashMap<String, String[]>();
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SuppressWarnings({"unchecked"})
|
||||
protected void setupAPI() {
|
||||
super.setupAPI();
|
||||
|
||||
@@ -208,7 +209,7 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
ForestryBlock.apiculture.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "apiculture");
|
||||
ForestryBlock.apiculture.registerBlock(new BlockBase(Material.iron, true), ItemForestryBlock.class, "apiculture");
|
||||
ForestryBlock.apiculture.block().setCreativeTab(Tabs.tabApiculture);
|
||||
ForestryBlock.apiculture.block().setHarvestLevel("axe", 0);
|
||||
|
||||
@@ -222,7 +223,7 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
'C', ForestryItem.impregnatedCasing))
|
||||
.setFaces(0, 1, 2, 2, 4, 4, 0, 7));
|
||||
|
||||
definitionChest = ((BlockBase) ForestryBlock.apiculture.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_APIARISTCHEST_META, "forestry.ApiaristChest", TileApiaristChest.class,
|
||||
definitionChest = ((BlockBase) ForestryBlock.apiculture.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_APIARISTCHEST_META, "forestry.ApiaristChest", TileApiaristChest.class, new RenderNaturalistChest("apiaristchest"),
|
||||
ShapedRecipeCustom.createShapedRecipe(ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_APIARISTCHEST_META),
|
||||
" # ",
|
||||
"XYX",
|
||||
@@ -230,7 +231,7 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
'#', "blockGlass",
|
||||
'X', "beeComb",
|
||||
'Y', "chestWood"))
|
||||
.setFaces(0, 1, 2, 3, 4, 4));
|
||||
.setBoundingBox(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F));
|
||||
|
||||
definitionBeehouse = ((BlockBase) ForestryBlock.apiculture.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_BEEHOUSE_META, "forestry.Beehouse", TileBeehouse.class,
|
||||
ShapedRecipeCustom.createShapedRecipe(ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_BEEHOUSE_META),
|
||||
|
||||
@@ -92,6 +92,7 @@ import forestry.core.items.ItemForestryBlock;
|
||||
import forestry.core.items.ItemFruit.EnumFruit;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.RenderNaturalistChest;
|
||||
import forestry.core.utils.RecipeUtil;
|
||||
import forestry.core.utils.ShapedRecipeCustom;
|
||||
import forestry.core.utils.ShapelessRecipeCustom;
|
||||
@@ -183,11 +184,11 @@ public class PluginArboriculture extends ForestryPlugin {
|
||||
ForestryBlock.pods.registerBlock(new BlockFruitPod(), ItemForestryBlock.class, "pods");
|
||||
|
||||
// Machines
|
||||
ForestryBlock.arboriculture.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "arboriculture");
|
||||
ForestryBlock.arboriculture.registerBlock(new BlockBase(Material.iron, true), ItemForestryBlock.class, "arboriculture");
|
||||
ForestryBlock.arboriculture.block().setCreativeTab(Tabs.tabArboriculture);
|
||||
|
||||
definitionChest = ((BlockBase) ForestryBlock.arboriculture.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_ARBCHEST_META,
|
||||
"forestry.ArbChest", TileArboristChest.class,
|
||||
"forestry.ArbChest", TileArboristChest.class, new RenderNaturalistChest("arbchest"),
|
||||
ShapedRecipeCustom.createShapedRecipe(ForestryBlock.arboriculture.getItemStack(1, Defaults.DEFINITION_ARBCHEST_META),
|
||||
" # ",
|
||||
"XYX",
|
||||
@@ -195,7 +196,7 @@ public class PluginArboriculture extends ForestryPlugin {
|
||||
'#', "blockGlass",
|
||||
'X', "treeSapling",
|
||||
'Y', "chestWood"))
|
||||
.setFaces(0, 1, 2, 3, 4, 4, 0, 7));
|
||||
.setBoundingBox(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F));
|
||||
|
||||
// Init rendering
|
||||
proxy.initializeRendering();
|
||||
|
||||
@@ -15,8 +15,6 @@ import java.util.EnumSet;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
@@ -46,6 +44,7 @@ import forestry.core.genetics.Branch;
|
||||
import forestry.core.genetics.alleles.Allele;
|
||||
import forestry.core.items.ItemForestryBlock;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.RenderNaturalistChest;
|
||||
import forestry.core.utils.ShapedRecipeCustom;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.lepidopterology.ButterflySpawner;
|
||||
@@ -85,7 +84,7 @@ public class PluginLepidopterology extends ForestryPlugin {
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
ForestryBlock.lepidopterology.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "lepidopterology");
|
||||
ForestryBlock.lepidopterology.registerBlock(new BlockBase(Material.iron, true), ItemForestryBlock.class, "lepidopterology");
|
||||
ForestryBlock.lepidopterology.block().setCreativeTab(Tabs.tabLepidopterology);
|
||||
|
||||
createAlleles();
|
||||
@@ -125,7 +124,7 @@ public class PluginLepidopterology extends ForestryPlugin {
|
||||
registerTemplates();
|
||||
|
||||
BlockBase lepidopterology = ((BlockBase) ForestryBlock.lepidopterology.block());
|
||||
MachineDefinition definitionChest = lepidopterology.addDefinition((new MachineDefinition(Defaults.DEFINITION_LEPICHEST_META, "forestry.LepiChest", TileLepidopteristChest.class,
|
||||
MachineDefinition definitionChest = lepidopterology.addDefinition(new MachineDefinition(Defaults.DEFINITION_LEPICHEST_META, "forestry.LepiChest", TileLepidopteristChest.class, new RenderNaturalistChest("lepichest"),
|
||||
ShapedRecipeCustom.createShapedRecipe(
|
||||
ForestryBlock.lepidopterology.getItemStack(1, Defaults.DEFINITION_LEPICHEST_META),
|
||||
" # ",
|
||||
@@ -134,7 +133,7 @@ public class PluginLepidopterology extends ForestryPlugin {
|
||||
'#', "blockGlass",
|
||||
'X', ForestryItem.butterflyGE.getItemStack(1, Defaults.WILDCARD),
|
||||
'Y', "chestWood"))
|
||||
.setFaces(0, 1, 2, 3, 4, 4, 0, 7)));
|
||||
.setBoundingBox(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F));
|
||||
definitionChest.register();
|
||||
|
||||
((ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees")).registerLeafTickHandler(new ButterflySpawner());
|
||||
|
||||
|
Before Width: | Height: | Size: 275 B |
|
Before Width: | Height: | Size: 239 B |
|
Before Width: | Height: | Size: 300 B |
|
Before Width: | Height: | Size: 239 B |
|
After Width: | Height: | Size: 733 B |
|
Before Width: | Height: | Size: 376 B |
|
Before Width: | Height: | Size: 240 B |
|
Before Width: | Height: | Size: 300 B |
|
Before Width: | Height: | Size: 240 B |
|
Before Width: | Height: | Size: 374 B |
|
After Width: | Height: | Size: 840 B |
|
Before Width: | Height: | Size: 303 B |
|
Before Width: | Height: | Size: 240 B |
|
Before Width: | Height: | Size: 300 B |
|
Before Width: | Height: | Size: 240 B |
|
Before Width: | Height: | Size: 302 B |
|
After Width: | Height: | Size: 765 B |