mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +00:00
Fix #821 bee house and apiary are invisible
This commit is contained in:
1 parent
eee55cebf7
commit
a188bbd43a
9 files changed
+74
-7
No files matched your search
Executable → Regular
+41
@@ -10,14 +10,55 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.gadgets.TileNaturalistChest;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.PlainInventory;
|
||||
import forestry.core.utils.Utils;
|
||||
|
||||
public class TileApiaristChest extends TileNaturalistChest {
|
||||
|
||||
private boolean checkedForLegacyBlock = false;
|
||||
|
||||
public TileApiaristChest() {
|
||||
super(BeeManager.beeRoot, GuiId.ApiaristChestGUI.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
if (worldObj != null && !checkedForLegacyBlock) {
|
||||
Block block = worldObj.getBlock(xCoord, yCoord, zCoord);
|
||||
if (ForestryBlock.apiculture.isBlockEqual(block)) {
|
||||
migrateFromLegacyBlock();
|
||||
}
|
||||
|
||||
checkedForLegacyBlock = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void migrateFromLegacyBlock() {
|
||||
IInventory inventoryCopy = new PlainInventory(getInternalInventory());
|
||||
|
||||
// clear the inventory so it isn't dropped when the block is replaced
|
||||
for (int i = 0; i < getSizeInventory(); i++) {
|
||||
setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, ForestryBlock.apicultureChest.block(), Defaults.DEFINITION_APIARISTCHEST_META, Defaults.FLAG_BLOCK_SYNCH_AND_UPDATE);
|
||||
|
||||
TileApiaristChest tile = Utils.getTile(worldObj, xCoord, yCoord, zCoord, TileApiaristChest.class);
|
||||
for (int i = 0; i < getSizeInventory(); i++) {
|
||||
ItemStack stack = inventoryCopy.getStackInSlot(i);
|
||||
tile.setInventorySlotContents(i, stack);
|
||||
}
|
||||
tile.markDirty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,9 +58,11 @@ public class Defaults {
|
||||
public static final int DEFINITION_ESCRITOIRE_META = 1;
|
||||
|
||||
public static final int DEFINITION_APIARY_META = 0;
|
||||
public static final int DEFINITION_APIARISTCHEST_META = 1;
|
||||
public static final int DEFINITION_APIARISTCHEST_LEGACY_META = 1;
|
||||
public static final int DEFINITION_BEEHOUSE_META = 2;
|
||||
|
||||
public static final int DEFINITION_APIARISTCHEST_META = 0;
|
||||
|
||||
public static final int DEFINITION_ENGINETIN_META = 0;
|
||||
public static final int DEFINITION_ENGINECOPPER_META = 1;
|
||||
public static final int DEFINITION_ENGINEBRONZE_META = 2;
|
||||
|
||||
@@ -71,6 +71,7 @@ public enum ForestryBlock {
|
||||
farm,
|
||||
core,
|
||||
apiculture,
|
||||
apicultureChest,
|
||||
mail,
|
||||
engine,
|
||||
factoryTESR,
|
||||
|
||||
@@ -44,6 +44,7 @@ public class MachineDefinition {
|
||||
private final String teIdent;
|
||||
private Block block;
|
||||
private final int meta;
|
||||
private boolean legacy;
|
||||
|
||||
public final IBlockRenderer renderer;
|
||||
|
||||
@@ -88,6 +89,11 @@ public class MachineDefinition {
|
||||
public void setBlock(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public MachineDefinition setLegacy() {
|
||||
legacy = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineDefinition setBoundingBox(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
|
||||
this.minX = minX;
|
||||
@@ -137,6 +143,9 @@ public class MachineDefinition {
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
if (legacy) {
|
||||
return;
|
||||
}
|
||||
list.add(new ItemStack(item, 1, meta));
|
||||
}
|
||||
|
||||
@@ -176,6 +185,10 @@ public class MachineDefinition {
|
||||
public void registerIcons(IIconRegister register) {
|
||||
icons = new IIcon[8];
|
||||
|
||||
if (legacy) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
icons[i] = TextureManager.getInstance().registerTex(register, teIdent.replace("forestry.", "").toLowerCase(Locale.ENGLISH) + "." + faceMap[i]);
|
||||
}
|
||||
|
||||
@@ -20,16 +20,18 @@ import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.GuiHandler;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.IPagedInventory;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
|
||||
public abstract class TileNaturalistChest extends TileBase implements IPagedInventory {
|
||||
private static final float lidAngleVariationPerTick = 0.1F;
|
||||
|
||||
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));
|
||||
|
||||
@@ -169,6 +169,7 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
public static HiveRegistry hiveRegistry;
|
||||
|
||||
private static MachineDefinition definitionApiary;
|
||||
private static MachineDefinition definitionChestLegacy;
|
||||
private static MachineDefinition definitionChest;
|
||||
private static MachineDefinition definitionBeehouse;
|
||||
private static MachineDefinition definitionAnalyzer;
|
||||
@@ -211,10 +212,14 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
ForestryBlock.apiculture.registerBlock(new BlockBase(Material.iron, true), ItemForestryBlock.class, "apiculture");
|
||||
ForestryBlock.apiculture.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "apiculture");
|
||||
ForestryBlock.apiculture.block().setCreativeTab(Tabs.tabApiculture);
|
||||
ForestryBlock.apiculture.block().setHarvestLevel("axe", 0);
|
||||
|
||||
ForestryBlock.apicultureChest.registerBlock(new BlockBase(Material.iron, true), ItemForestryBlock.class, "apicultureChest");
|
||||
ForestryBlock.apicultureChest.block().setCreativeTab(Tabs.tabApiculture);
|
||||
ForestryBlock.apicultureChest.block().setHarvestLevel("axe", 0);
|
||||
|
||||
definitionApiary = ((BlockBase) ForestryBlock.apiculture.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_APIARY_META, "forestry.Apiary", TileApiary.class,
|
||||
ShapedRecipeCustom.createShapedRecipe(ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_APIARY_META),
|
||||
"XXX",
|
||||
@@ -225,8 +230,10 @@ 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, new RenderNaturalistChest("apiaristchest"),
|
||||
ShapedRecipeCustom.createShapedRecipe(ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_APIARISTCHEST_META),
|
||||
definitionChestLegacy = ((BlockBase) ForestryBlock.apiculture.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_APIARISTCHEST_LEGACY_META, "forestry.ApiaristChest", TileApiaristChest.class).setLegacy());
|
||||
|
||||
definitionChest = ((BlockBase) ForestryBlock.apicultureChest.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_APIARISTCHEST_META, "forestry.ApiaristChestNew", TileApiaristChest.class, new RenderNaturalistChest("apiaristchest"),
|
||||
ShapedRecipeCustom.createShapedRecipe(ForestryBlock.apicultureChest.getItemStack(1, Defaults.DEFINITION_APIARISTCHEST_META),
|
||||
" # ",
|
||||
"XYX",
|
||||
"XXX",
|
||||
@@ -868,6 +875,7 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
definitionAnalyzer.register();
|
||||
definitionApiary.register();
|
||||
definitionBeehouse.register();
|
||||
definitionChestLegacy.register();
|
||||
definitionChest.register();
|
||||
}
|
||||
|
||||
|
||||
@@ -571,7 +571,7 @@ public class PluginStorage extends ForestryPlugin {
|
||||
'#', Blocks.wool,
|
||||
'X', Items.string,
|
||||
'V', "stickWood",
|
||||
'Y', ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_APIARISTCHEST_META));
|
||||
'Y', ForestryBlock.apicultureChest.getItemStack(1, Defaults.DEFINITION_APIARISTCHEST_META));
|
||||
}
|
||||
|
||||
if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) {
|
||||
|
||||
Reference in new issue
Block a user