mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 04:22:32 +00:00
Merge branch 'mc-1.10' of https://github.com/ForestryMC/ForestryMC into mc-1.10
This commit is contained in:
commit
418f00abf2
25 files changed
+244
-257
No files matched your search
+1
-1
Submodule lang updated: 7a992aeb27...237feca912.
@@ -5,15 +5,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.core.ILocatable;
|
||||
|
||||
public interface IClimateControlProvider {
|
||||
public interface IClimateControlProvider extends ILocatable {
|
||||
|
||||
IClimateControl getClimateControl();
|
||||
|
||||
World getWorld();
|
||||
|
||||
BlockPos getCoordinates();
|
||||
|
||||
}
|
||||
@@ -9,13 +9,13 @@ package forestry.api.climate;
|
||||
* A climate source is used to change the climate in a region.
|
||||
*/
|
||||
public interface IClimateSource {
|
||||
|
||||
|
||||
/**
|
||||
* @param tickCount The current tick count.
|
||||
* @param region The climate region, in that the source stands.
|
||||
*/
|
||||
void changeClimate(int tickCount, IClimateRegion region);
|
||||
|
||||
|
||||
/**
|
||||
* @return The ticks that are required for one change.
|
||||
*/
|
||||
|
||||
@@ -5,15 +5,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.core.ILocatable;
|
||||
|
||||
public interface IClimateSourceProvider {
|
||||
public interface IClimateSourceProvider extends ILocatable {
|
||||
|
||||
IClimateSource getClimateSource();
|
||||
|
||||
World getWorld();
|
||||
|
||||
BlockPos getCoordinates();
|
||||
|
||||
}
|
||||
@@ -6,21 +6,19 @@
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ICamouflageHandler{
|
||||
public interface ICamouflageHandler extends ILocatable {
|
||||
|
||||
/**
|
||||
* @return The item of the block that is the camouflage of this handler for the type.
|
||||
*/
|
||||
ItemStack getCamouflageBlock(String type);
|
||||
|
||||
|
||||
/**
|
||||
* @return The default camouflage block item for the type.
|
||||
*/
|
||||
ItemStack getDefaultCamouflageBlock(String type);
|
||||
|
||||
|
||||
/**
|
||||
* @return True if the handler can handle this type of camouflage.
|
||||
*/
|
||||
@@ -30,11 +28,4 @@ public interface ICamouflageHandler{
|
||||
* Set the camouflage block item for the type.
|
||||
*/
|
||||
void setCamouflageBlock(String type, ItemStack camouflageBlock);
|
||||
|
||||
/**
|
||||
* @return The coordinates of the handler as a BlockPos.
|
||||
*/
|
||||
BlockPos getCoordinates();
|
||||
|
||||
World getWorld();
|
||||
}
|
||||
+21
-21
@@ -1,21 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* 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.tiles;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ILocatable {
|
||||
BlockPos getCoordinates();
|
||||
|
||||
/** Must not be named "getWorld" to avoid SpecialSource issue https://github.com/md-5/SpecialSource/issues/12 */
|
||||
World getWorldObj();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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.api.core;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ILocatable {
|
||||
BlockPos getCoordinates();
|
||||
|
||||
/** Must not be named "getWorld" to avoid SpecialSource issue https://github.com/md-5/SpecialSource/issues/12 */
|
||||
World getWorldObj();
|
||||
}
|
||||
@@ -15,6 +15,8 @@ import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.arboriculture.items.ItemBlockWoodDoor;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -23,9 +25,9 @@ import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class CamouflageHandlerArbDoor implements ICamouflageItemHandler {
|
||||
|
||||
@@ -56,22 +58,22 @@ public class CamouflageHandlerArbDoor implements ICamouflageItemHandler {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || !(stack.getItem() instanceof ItemBlockWoodDoor)){
|
||||
return null;
|
||||
}
|
||||
World world = camouflageHandler.getWorld();
|
||||
World world = camouflageHandler.getWorldObj();
|
||||
BlockPos pos = camouflageTile.getCoordinates();
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
IBlockState currentState = blockState.getActualState(world, pos);
|
||||
|
||||
|
||||
ItemBlockWoodDoor itemDoor = (ItemBlockWoodDoor) stack.getItem();
|
||||
|
||||
|
||||
IBlockState doorState = itemDoor.block.getDefaultState()
|
||||
.withProperty(BlockDoor.FACING, currentState.getValue(BlockDoor.FACING))
|
||||
.withProperty(BlockDoor.HINGE, currentState.getValue(BlockDoor.HINGE))
|
||||
.withProperty(BlockDoor.OPEN, currentState.getValue(BlockDoor.OPEN))
|
||||
.withProperty(BlockDoor.POWERED, currentState.getValue(BlockDoor.POWERED))
|
||||
.withProperty(BlockDoor.HALF, currentState.getValue(BlockDoor.HALF));
|
||||
|
||||
|
||||
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
|
||||
|
||||
|
||||
return Pair.of(doorState, modelShapes.getModelForState(doorState));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,18 +10,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.core;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockModelShapes;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -57,7 +58,7 @@ public class CamouflageHandlerDefault implements ICamouflageItemHandler {
|
||||
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
IBlockState state = block.getStateFromMeta(stack.getItemDamage());
|
||||
|
||||
|
||||
return Pair.of(state, modelShapes.getModelForState(state));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.core;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -59,23 +60,23 @@ public class CamouflageHandlerDoor implements ICamouflageItemHandler {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || !(stack.getItem() instanceof ItemDoor)){
|
||||
return null;
|
||||
}
|
||||
World world = camouflageHandler.getWorld();
|
||||
World world = camouflageHandler.getWorldObj();
|
||||
BlockPos pos = camouflageTile.getCoordinates();
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
IBlockState currentState = blockState.getActualState(world, pos);
|
||||
|
||||
|
||||
ItemDoor itemDoor = (ItemDoor) stack.getItem();
|
||||
Block doorBlock = ObfuscationReflectionHelper.getPrivateValue(ItemDoor.class, itemDoor, 0);
|
||||
|
||||
|
||||
IBlockState doorState = doorBlock.getDefaultState()
|
||||
.withProperty(BlockDoor.FACING, currentState.getValue(BlockDoor.FACING))
|
||||
.withProperty(BlockDoor.HINGE, currentState.getValue(BlockDoor.HINGE))
|
||||
.withProperty(BlockDoor.OPEN, currentState.getValue(BlockDoor.OPEN))
|
||||
.withProperty(BlockDoor.POWERED, currentState.getValue(BlockDoor.POWERED))
|
||||
.withProperty(BlockDoor.HALF, currentState.getValue(BlockDoor.HALF));
|
||||
|
||||
|
||||
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
|
||||
|
||||
|
||||
return Pair.of(doorState, modelShapes.getModelForState(doorState));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,17 +16,18 @@ import java.util.Map;
|
||||
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
public class ClimateEventHandler {
|
||||
|
||||
Map<Integer, Integer> serverTicks;
|
||||
|
||||
|
||||
public ClimateEventHandler() {
|
||||
serverTicks = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldTick(TickEvent.WorldTickEvent event) {
|
||||
Integer dim = Integer.valueOf(event.world.provider.getDimension());
|
||||
@@ -44,5 +45,5 @@ public class ClimateEventHandler {
|
||||
serverTicks.put(dim, ticks+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -10,10 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.climate;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -26,17 +22,20 @@ import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.climate.IClimateSourceProvider;
|
||||
import forestry.core.DefaultClimateProvider;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class ClimateManager implements IClimateManager{
|
||||
|
||||
protected Map<Integer, List<IClimateRegion>> regions;
|
||||
|
||||
private final Object regionsMutex;
|
||||
|
||||
|
||||
public ClimateManager() {
|
||||
regions = new HashMap<>();
|
||||
regionsMutex = new Object();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addRegion(IClimateRegion region) {
|
||||
if(region == null){
|
||||
@@ -58,7 +57,7 @@ public class ClimateManager implements IClimateManager{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeRegion(IClimateRegion region) {
|
||||
if(region == null){
|
||||
@@ -75,18 +74,18 @@ public class ClimateManager implements IClimateManager{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeSource(IClimateSourceProvider source) {
|
||||
if(source == null){
|
||||
return;
|
||||
}
|
||||
synchronized (regionsMutex) {
|
||||
Integer dimensionID = Integer.valueOf(source.getWorld().provider.getDimension());
|
||||
Integer dimensionID = Integer.valueOf(source.getWorldObj().provider.getDimension());
|
||||
if(!regions.containsKey(dimensionID)){
|
||||
regions.put(dimensionID, new ArrayList<>());
|
||||
}
|
||||
IClimateRegion region = getRegionForPos(source.getWorld(), source.getCoordinates());
|
||||
IClimateRegion region = getRegionForPos(source.getWorldObj(), source.getCoordinates());
|
||||
if(region != null){
|
||||
if(!region.getSources().contains(source.getClimateSource())){
|
||||
region.removeSource(source.getClimateSource());
|
||||
@@ -94,18 +93,18 @@ public class ClimateManager implements IClimateManager{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addSource(IClimateSourceProvider source) {
|
||||
if(source == null){
|
||||
return;
|
||||
}
|
||||
synchronized (regionsMutex) {
|
||||
Integer dimensionID = Integer.valueOf(source.getWorld().provider.getDimension());
|
||||
Integer dimensionID = Integer.valueOf(source.getWorldObj().provider.getDimension());
|
||||
if(!regions.containsKey(dimensionID)){
|
||||
regions.put(dimensionID, new ArrayList<>());
|
||||
}
|
||||
IClimateRegion region = getRegionForPos(source.getWorld(), source.getCoordinates());
|
||||
IClimateRegion region = getRegionForPos(source.getWorldObj(), source.getCoordinates());
|
||||
if(region != null){
|
||||
if(!region.getSources().contains(source.getClimateSource())){
|
||||
region.addSource(source.getClimateSource());
|
||||
@@ -113,14 +112,14 @@ public class ClimateManager implements IClimateManager{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getTemperature(World world, BlockPos pos) {
|
||||
Biome biome = world.getBiome(pos);
|
||||
IClimateRegion region = getRegionForPos(world, pos);
|
||||
if(region!= null){
|
||||
IClimatePosition position = region.getPositions().get(pos);
|
||||
|
||||
|
||||
if(position != null){
|
||||
return position.getTemperature();
|
||||
}
|
||||
@@ -134,19 +133,19 @@ public class ClimateManager implements IClimateManager{
|
||||
IClimateRegion region = getRegionForPos(world, pos);
|
||||
if(region!= null){
|
||||
IClimatePosition position = region.getPositions().get(pos);
|
||||
|
||||
|
||||
if(position != null){
|
||||
return position.getHumidity();
|
||||
}
|
||||
}
|
||||
return biome.getRainfall();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<IClimateRegion>> getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IClimateRegion getRegionForPos(World world, BlockPos pos){
|
||||
Integer dimensionID = Integer.valueOf(world.provider.getDimension());
|
||||
@@ -163,7 +162,7 @@ public class ClimateManager implements IClimateManager{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IClimateProvider getDefaultClimate(World world, BlockPos pos) {
|
||||
return new DefaultClimateProvider(world, pos);
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import forestry.api.core.ILocatable;
|
||||
|
||||
import forestry.core.tiles.ILocatable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface IGuiHandlerTile extends IGuiHandlerForestry, ILocatable {
|
||||
Object getGui(EntityPlayer player, int data);
|
||||
|
||||
@@ -49,8 +49,7 @@ public class ItemInventoryCamouflageSprayCan extends ItemInventory implements IC
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
public World getWorldObj() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,8 @@ package forestry.core.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.ILocatable;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multiset;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -24,7 +26,7 @@ import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.owner.IOwnerHandler;
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.owner.OwnerHandler;
|
||||
import forestry.core.tiles.ILocatable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -13,6 +13,8 @@ package forestry.core.multiblock;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.core.ILocatable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -22,7 +24,6 @@ import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.multiblock.IMultiblockLogic;
|
||||
import forestry.api.multiblock.MultiblockTileEntityBase;
|
||||
import forestry.core.config.Constants;
|
||||
@@ -31,7 +32,6 @@ import forestry.core.gui.IGuiHandlerTile;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.tiles.IFilterSlotDelegate;
|
||||
import forestry.core.tiles.ILocatable;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
|
||||
public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> extends MultiblockTileEntityBase<T> implements ISidedInventory, IFilterSlotDelegate, ILocatable, IGuiHandlerTile {
|
||||
|
||||
@@ -12,6 +12,8 @@ package forestry.core.network.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.api.core.ILocatable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@@ -21,7 +23,6 @@ import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.ILocatable;
|
||||
|
||||
public class PacketGuiUpdate extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ package forestry.core.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.ILocatable;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
@@ -12,6 +12,9 @@ package forestry.core.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.core.ILocatable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -27,6 +30,7 @@ import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.packets.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.NBTUtilForestry;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -40,6 +44,7 @@ import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class OreDictUtil {
|
||||
public static final String ORE_COPPER = "oreCopper";
|
||||
public static final String ORE_TIN = "oreTin";
|
||||
|
||||
@@ -12,17 +12,14 @@ package forestry.greenhouse;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.items.EnumElectronTube;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.OreDictUtil;
|
||||
|
||||
@@ -73,7 +73,6 @@ import forestry.core.tiles.IActivatable;
|
||||
import forestry.core.utils.CamouflageUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.greenhouse.tiles.TileGreenhouse;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseClimateControl;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseControl;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseDoor;
|
||||
|
||||
@@ -10,14 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
@@ -32,12 +30,15 @@ import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.multiblock.FakeMultiblockController;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class FakeGreenhouseController extends FakeMultiblockController implements IGreenhouseControllerInternal {
|
||||
public static final FakeGreenhouseController instance = new FakeGreenhouseController();
|
||||
|
||||
|
||||
private FakeGreenhouseController() {
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IInventoryAdapter getInternalInventory() {
|
||||
@@ -49,7 +50,7 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
public ITankManager getTankManager() {
|
||||
return FakeTankManager.instance;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EnergyManager getEnergyManager() {
|
||||
return null;
|
||||
@@ -59,7 +60,7 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
public ItemStack getCamouflageBlock(String type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getDefaultCamouflageBlock(String type) {
|
||||
return null;
|
||||
@@ -67,9 +68,9 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
|
||||
@Override
|
||||
public void setCamouflageBlock(String type, ItemStack camouflageBlock) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canHandleType(String type) {
|
||||
return false;
|
||||
@@ -79,7 +80,7 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
public BlockPos getCoordinates() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IGreenhouseLogic> getLogics() {
|
||||
return Collections.emptyList();
|
||||
@@ -88,7 +89,7 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
@Override
|
||||
public void onChange(EnumGreenhouseEventType type, Object event) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
return Collections.emptySet();
|
||||
@@ -98,7 +99,7 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
public String getUnlocalizedType() {
|
||||
return "for.multiblock.greenhouse.type";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IClimateRegion getRegion() {
|
||||
return null;
|
||||
@@ -113,11 +114,6 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWork() {
|
||||
return false;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
@@ -21,16 +20,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
@@ -54,8 +45,8 @@ import forestry.api.multiblock.IGreenhouseComponent.ClimateControl;
|
||||
import forestry.api.multiblock.IGreenhouseComponent.Climatiser;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.climate.ClimateRoom;
|
||||
import forestry.core.climate.ClimatePosition;
|
||||
import forestry.core.climate.ClimateRoom;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
@@ -81,6 +72,18 @@ import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.inventory.InventoryGreenhouse;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseSprinkler;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
public class GreenhouseController extends RectangularMultiblockControllerBase implements IGreenhouseControllerInternal, ILiquidTankTile {
|
||||
|
||||
private final Set<IInternalBlock> internalBlocks = new HashSet<>();
|
||||
@@ -96,26 +99,26 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
private final EnergyManager energyManager;
|
||||
private final InventoryGreenhouse inventory;
|
||||
private final boolean needRenderUpdate = false;
|
||||
|
||||
|
||||
//Camouflage blocks
|
||||
private ItemStack camouflagePlainBlock;
|
||||
private ItemStack camouflageGlassBlock;
|
||||
private ItemStack camouflageDoorBlock;
|
||||
private ClimateRoom region;
|
||||
|
||||
|
||||
public GreenhouseController(World world) {
|
||||
super(world, GreenhouseMultiblockSizeLimits.instance);
|
||||
|
||||
|
||||
this.resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(FluidRegistry.WATER);
|
||||
this.tankManager = new TankManager(this, resourceTank);
|
||||
this.energyManager = new EnergyManager(200, 100000);
|
||||
this.inventory = new InventoryGreenhouse(this);
|
||||
|
||||
|
||||
camouflagePlainBlock = getDefaultCamouflageBlock(CamouflageManager.DEFAULT);
|
||||
camouflageGlassBlock = getDefaultCamouflageBlock(CamouflageManager.GLASS);
|
||||
camouflageDoorBlock = getDefaultCamouflageBlock(CamouflageManager.DOOR);
|
||||
}
|
||||
|
||||
|
||||
/* CLIMATE */
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
@@ -127,7 +130,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(getExactHumidity());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
if(region == null){
|
||||
@@ -154,53 +157,53 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
BlockPos coord = getReferenceCoord();
|
||||
return new BlockPos(coord);
|
||||
}
|
||||
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound data) {
|
||||
data = super.writeToNBT(data);
|
||||
|
||||
|
||||
tankManager.writeToNBT(data);
|
||||
energyManager.writeToNBT(data);
|
||||
inventory.writeToNBT(data);
|
||||
|
||||
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.DEFAULT);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.GLASS);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.DOOR);
|
||||
|
||||
|
||||
for (IGreenhouseLogic logic : getLogics()) {
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
logic.writeToNBT(nbtTag);
|
||||
data.setTag("logic" + logic.getName(), nbtTag);
|
||||
}
|
||||
|
||||
|
||||
if(region != null){
|
||||
data.setTag("Region", region.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
|
||||
|
||||
tankManager.readFromNBT(data);
|
||||
energyManager.readFromNBT(data);
|
||||
inventory.readFromNBT(data);
|
||||
|
||||
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.DEFAULT);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.GLASS);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.DOOR);
|
||||
|
||||
|
||||
if (logics.isEmpty()) {
|
||||
createLogics();
|
||||
}
|
||||
|
||||
|
||||
for (IGreenhouseLogic logic : getLogics()) {
|
||||
logic.readFromNBT(data.getCompoundTag("logic" + logic.getName()));
|
||||
}
|
||||
|
||||
|
||||
if(data.hasKey("Region")){
|
||||
NBTTagCompound nbtTag = data.getCompoundTag("Region");
|
||||
if(region != null){
|
||||
@@ -210,7 +213,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void formatDescriptionPacket(NBTTagCompound data) {
|
||||
writeToNBT(data);
|
||||
@@ -220,12 +223,12 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
public void decodeDescriptionPacket(NBTTagCompound data) {
|
||||
readFromNBT(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onAttachedPartWithMultiblockData(IMultiblockComponent part, NBTTagCompound data) {
|
||||
readFromNBT(data);
|
||||
}
|
||||
|
||||
|
||||
/* GUI DATA */
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
@@ -255,12 +258,12 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
region.readData(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canHandleType(String type) {
|
||||
return type.equals(CamouflageManager.DEFAULT) || type.equals(CamouflageManager.GLASS) || type.equals(CamouflageManager.DOOR);
|
||||
}
|
||||
|
||||
|
||||
/* CAMOUFLAGE */
|
||||
@Override
|
||||
public void setCamouflageBlock(String type, ItemStack camouflageBlock) {
|
||||
@@ -278,7 +281,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, oldCamouflageBlock)){
|
||||
switch (type) {
|
||||
case CamouflageManager.DEFAULT:
|
||||
@@ -297,11 +300,10 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
if (worldObj != null && worldObj.isRemote) {
|
||||
Proxies.net.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.MULTIBLOCK));
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(this, null, this, type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getCamouflageBlock(String type) {
|
||||
switch (type) {
|
||||
@@ -315,7 +317,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getDefaultCamouflageBlock(String type) {
|
||||
switch (type) {
|
||||
@@ -329,7 +331,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* GREENHOUSE */
|
||||
@Override
|
||||
public void onChange(EnumGreenhouseEventType type, Object event) {
|
||||
@@ -337,7 +339,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
logic.onEvent(type, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* GREENHOUSE LOGICS */
|
||||
private void createLogics() {
|
||||
logics.clear();
|
||||
@@ -348,7 +350,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IGreenhouseLogic createLogic(Class<? extends IGreenhouseLogic> logicClass) {
|
||||
try {
|
||||
return logicClass.getConstructor(IGreenhouseController.class).newInstance(this);
|
||||
@@ -358,24 +360,24 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IGreenhouseLogic> getLogics() {
|
||||
return logics;
|
||||
}
|
||||
|
||||
|
||||
/* MANAGERS */
|
||||
@Nonnull
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EnergyManager getEnergyManager() {
|
||||
return energyManager;
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IInventoryAdapter getInternalInventory() {
|
||||
@@ -385,12 +387,12 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
return FakeInventoryAdapter.instance();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* CONTROLLER */
|
||||
@Override
|
||||
protected void onMachineAssembled() {
|
||||
super.onMachineAssembled();
|
||||
|
||||
|
||||
createLogics();
|
||||
if(region != null){
|
||||
Map<BlockPos, IClimatePosition> internalPositions = new HashMap<>();
|
||||
@@ -429,11 +431,11 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onMachineDisassembled() {
|
||||
super.onMachineDisassembled();
|
||||
|
||||
|
||||
internalBlocks.clear();
|
||||
logics.clear();
|
||||
|
||||
@@ -495,36 +497,36 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
if (updateOnInterval(20)) {
|
||||
inventory.drainCan(tankManager);
|
||||
}
|
||||
|
||||
|
||||
for (IGreenhouseLogic logic : logics) {
|
||||
logic.work();
|
||||
}
|
||||
|
||||
|
||||
for (IGreenhouseComponent.Active activeComponent : activeComponents) {
|
||||
activeComponent.updateServer(tickCount);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void isMachineWhole() throws MultiblockValidationException {
|
||||
int minX = getSizeLimits().getMinimumXSize();
|
||||
int minY = getSizeLimits().getMinimumYSize();
|
||||
int minZ = getSizeLimits().getMinimumZSize();
|
||||
|
||||
|
||||
if (connectedParts.size() < getSizeLimits().getMinimumNumberOfBlocksForAssembledMachine()) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.small", minX, minY, minZ));
|
||||
}
|
||||
|
||||
|
||||
BlockPos maximumCoord = getMaximumCoord();
|
||||
BlockPos minimumCoord = getMinimumCoord();
|
||||
|
||||
|
||||
// Quickly check for exceeded dimensions
|
||||
int deltaX = maximumCoord.getX() - minimumCoord.getX() + 1;
|
||||
int deltaY = maximumCoord.getY() - minimumCoord.getY() + 1;
|
||||
int deltaZ = maximumCoord.getZ() - minimumCoord.getZ() + 1;
|
||||
|
||||
|
||||
int maxX = getSizeLimits().getMaximumXSize();
|
||||
int maxY = getSizeLimits().getMaximumYSize();
|
||||
int maxZ = getSizeLimits().getMaximumZSize();
|
||||
@@ -547,14 +549,14 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
if (deltaZ < minZ) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.small.z", minZ));
|
||||
}
|
||||
|
||||
|
||||
// Now we run a simple check on each block within that volume.
|
||||
// Any block deviating = NO DEAL SIR
|
||||
TileEntity te;
|
||||
IMultiblockComponent part;
|
||||
boolean isNextRoof = false;
|
||||
Class<? extends RectangularMultiblockControllerBase> myClass = this.getClass();
|
||||
|
||||
|
||||
for (int y = minimumCoord.getY(); y <= maximumCoord.getY() && !isNextRoof; y++) {
|
||||
for (int x = minimumCoord.getX(); x <= maximumCoord.getX(); x++) {
|
||||
for (int z = minimumCoord.getZ(); z <= maximumCoord.getZ(); z++) {
|
||||
@@ -567,7 +569,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
// This is permitted so that we can incorporate certain non-multiblock parts inside interiors
|
||||
part = null;
|
||||
}
|
||||
|
||||
|
||||
// Validate block type against both part-level and material-level validators.
|
||||
int extremes = 0;
|
||||
int sides = 0;
|
||||
@@ -583,7 +585,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
extremes++;
|
||||
sides++;
|
||||
}
|
||||
|
||||
|
||||
if (x == maximumCoord.getX()) {
|
||||
extremes++;
|
||||
sides++;
|
||||
@@ -592,11 +594,11 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
extremes++;
|
||||
sides++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (extremes >= 1) {
|
||||
// Side
|
||||
|
||||
|
||||
int exteriorLevel = y - minimumCoord.getY();
|
||||
if (part != null) {
|
||||
// Ensure this part should actually be allowed within a cube of this controller's type
|
||||
@@ -619,7 +621,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
isBlockGoodForInterior(this.worldObj, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BlockPos posUp = pos.up(2);
|
||||
TileEntity tileUp = worldObj.getTileEntity(posUp);
|
||||
if (sides >= 1 && !(tileUp instanceof IGreenhouseComponent)) {
|
||||
@@ -632,7 +634,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
}
|
||||
internalBlocks.clear();
|
||||
|
||||
|
||||
if (isNextRoof) {
|
||||
checkInternalBlocks();
|
||||
}
|
||||
@@ -693,25 +695,25 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
internalBlocks.add(blockToCheck);
|
||||
BlockPos posRoot = blockToCheck.getPos();
|
||||
|
||||
|
||||
isBlockGoodForInterior(worldObj, posRoot);
|
||||
for (IInternalBlockFace faceToCheck : blockToCheck.getFaces()) {
|
||||
CheckInternalBlockFaceEvent checkEvent = new CheckInternalBlockFaceEvent(this, blockToCheck, faceToCheck);
|
||||
MinecraftForge.EVENT_BUS.post(checkEvent);
|
||||
|
||||
|
||||
if (!faceToCheck.isTested()) {
|
||||
EnumFacing face = faceToCheck.getFace();
|
||||
BlockPos posFacing = posRoot.offset(face);
|
||||
|
||||
|
||||
BlockPos minPos = getMinimumCoord();
|
||||
BlockPos maxPos = getMaximumCoord();
|
||||
|
||||
|
||||
if (minPos.getX() > posFacing.getX() || minPos.getY() > posFacing.getY() || minPos.getZ() > posFacing.getZ() || maxPos.getX() < posFacing.getX() || maxPos.getY() < posFacing.getY() || maxPos.getZ() < posFacing.getZ()) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.greenhouse.error.space.closed"));
|
||||
}
|
||||
|
||||
|
||||
TileEntity tileFace = worldObj.getTileEntity(posFacing);
|
||||
|
||||
|
||||
if (tileFace instanceof IGreenhouseComponent) {
|
||||
if (((IGreenhouseComponent) tileFace).getMultiblockLogic().getController() != this) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.not.connected.part"));
|
||||
@@ -720,7 +722,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
} else {
|
||||
IInternalBlock internalBlock = createInternalBlock(new InternalBlock(posFacing, face.getOpposite(), blockToCheck));
|
||||
|
||||
|
||||
// Check is the internal block in the list
|
||||
if (internalBlocks.contains(internalBlock)) {
|
||||
faceToCheck.setTested(true);
|
||||
@@ -732,16 +734,16 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
return newBlocksToCheck;
|
||||
}
|
||||
|
||||
|
||||
private IInternalBlock createInternalBlock(IInternalBlock internalBlock) {
|
||||
CreateInternalBlockEvent createEvent = new CreateInternalBlockEvent(this, internalBlock);
|
||||
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(createEvent);
|
||||
|
||||
|
||||
return createEvent.internalBlock;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
return internalBlocks;
|
||||
@@ -762,14 +764,14 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
@Override
|
||||
protected void isGoodForExteriorLevel(IMultiblockComponent part, int level) throws MultiblockValidationException {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void isGoodForInterior(IMultiblockComponent part) throws MultiblockValidationException {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void isBlockGoodForInterior(World world, BlockPos pos) throws MultiblockValidationException {
|
||||
}
|
||||
@@ -778,17 +780,12 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
public IClimateRegion getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clearRegion() {
|
||||
region = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return worldObj;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<IGreenhouseComponent.Listener> getListenerComponents() {
|
||||
return listenerComponents;
|
||||
|
||||
@@ -10,26 +10,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.core.owner.IOwnerHandler;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
@@ -39,7 +26,6 @@ import forestry.api.greenhouse.GreenhouseEvents.CamouflageChangeEvent;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.api.multiblock.MultiblockTileEntityBase;
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
@@ -47,6 +33,8 @@ import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.network.packets.CamouflageSelectionType;
|
||||
import forestry.core.network.packets.PacketCamouflageSelectServer;
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.owner.IOwnerHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
@@ -54,34 +42,48 @@ import forestry.core.utils.PlayerUtil;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.multiblock.MultiblockLogicGreenhouse;
|
||||
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogicGreenhouse> implements IGreenhouseComponent, IStreamableGui, IHintSource, IErrorLogicSource, IOwnedTile, ICamouflageHandler, ICamouflagedTile, IEnergyProvider, IEnergyReceiver {
|
||||
|
||||
EnumFacing outwards;
|
||||
private ItemStack camouflageBlock;
|
||||
|
||||
|
||||
@Nullable
|
||||
private GameProfile owner;
|
||||
|
||||
|
||||
public TileGreenhouseHatch() {
|
||||
super(new MultiblockLogicGreenhouse());
|
||||
outwards = null;
|
||||
camouflageBlock = null;
|
||||
}
|
||||
|
||||
|
||||
public EnumFacing getOutwardsDir() {
|
||||
return outwards;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
|
||||
worldObj.notifyBlockOfStateChange(getPos(), worldObj.getBlockState(pos).getBlock());
|
||||
markDirty();
|
||||
|
||||
|
||||
recalculateOutwardsDirection(minCoord, maxCoord);
|
||||
}
|
||||
|
||||
@@ -96,11 +98,11 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
|
||||
|
||||
if (data.hasKey("CamouflageBlock")) {
|
||||
camouflageBlock = ItemStack.loadItemStackFromNBT(data.getCompoundTag("CamouflageBlock"));
|
||||
}
|
||||
|
||||
|
||||
if (data.hasKey("owner")) {
|
||||
NBTTagCompound ownerNbt = data.getCompoundTag("owner");
|
||||
this.owner = PlayerUtil.readGameProfileFromNBT(ownerNbt);
|
||||
@@ -117,7 +119,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
camouflageBlock.writeToNBT(nbtTag);
|
||||
data.setTag("CamouflageBlock", nbtTag);
|
||||
}
|
||||
|
||||
|
||||
if (this.owner != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
PlayerUtil.writeGameProfile(nbt, owner);
|
||||
@@ -126,7 +128,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
/* IMultiblockComponent */
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -150,22 +152,22 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController(), this, this, type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getCamouflageBlock(String type) {
|
||||
return camouflageBlock;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getDefaultCamouflageBlock(String type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canHandleType(String type) {
|
||||
return type.equals(getCamouflageType());
|
||||
}
|
||||
|
||||
|
||||
/* IStreamableGui */
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
@@ -212,7 +214,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
public IOwnerHandler getOwnerHandler() {
|
||||
return getMultiblockLogic().getController().getOwnerHandler();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCamouflageType() {
|
||||
if (getBlockType() instanceof BlockGreenhouse && ((BlockGreenhouse) getBlockType()).getGreenhouseType() == BlockGreenhouseType.GLASS) {
|
||||
@@ -220,21 +222,21 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
}
|
||||
return CamouflageManager.DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
private IItemHandler getOutwardsInventory() {
|
||||
if (getOutwardsTile() == null) {
|
||||
return null;
|
||||
}
|
||||
return TileUtil.getInventoryFromTile(getOutwardsTile(), outwards.getOpposite());
|
||||
}
|
||||
|
||||
|
||||
private TileEntity getOutwardsTile() {
|
||||
if (outwards == null || worldObj == null || pos == null) {
|
||||
return null;
|
||||
}
|
||||
return worldObj.getTileEntity(getPos().offset(outwards));
|
||||
}
|
||||
|
||||
|
||||
private IEnergyConnection getOutwardEnergyConnection() {
|
||||
TileEntity tile = getOutwardsTile();
|
||||
if (!(tile instanceof IEnergyConnection)) {
|
||||
@@ -242,7 +244,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
}
|
||||
return (IEnergyConnection) tile;
|
||||
}
|
||||
|
||||
|
||||
private IEnergyHandler getOutwardEnergyHandler() {
|
||||
TileEntity tile = getOutwardsTile();
|
||||
if (!(tile instanceof IEnergyHandler)) {
|
||||
@@ -250,7 +252,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
}
|
||||
return (IEnergyHandler) tile;
|
||||
}
|
||||
|
||||
|
||||
private IEnergyReceiver getOutwardEnergyReceiver() {
|
||||
TileEntity tile = getOutwardsTile();
|
||||
if (!(tile instanceof IEnergyReceiver)) {
|
||||
@@ -258,7 +260,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
}
|
||||
return (IEnergyReceiver) tile;
|
||||
}
|
||||
|
||||
|
||||
private IEnergyProvider getOutwardEnergyProvider() {
|
||||
TileEntity tile = getOutwardsTile();
|
||||
if (!(tile instanceof IEnergyProvider)) {
|
||||
@@ -266,7 +268,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
}
|
||||
return (IEnergyProvider) tile;
|
||||
}
|
||||
|
||||
|
||||
public void recalculateOutwardsDirection(BlockPos minCoord, BlockPos maxCoord) {
|
||||
outwards = null;
|
||||
|
||||
@@ -295,12 +297,12 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
outwards = EnumFacing.DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (((BlockGreenhouse) getBlockType()).getGreenhouseType() != BlockGreenhouseType.HATCH_OUTPUT && outwards != null) {
|
||||
outwards = outwards.getOpposite();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nonnull EnumFacing facing) {
|
||||
@@ -311,7 +313,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nonnull EnumFacing facing) {
|
||||
if(getOutwardsTile() != null){
|
||||
@@ -366,6 +368,11 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
}
|
||||
return provider.extractEnergy(from, maxExtract, simulate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public World getWorldObj() {
|
||||
return worldObj;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
apiary=accesspipe;nopowerrequired;beebiomes;beebreeding;beejubilance;beeflowers;flowerjungle;flowernether;apiaristsuit;honeyfood;
|
||||
apiary=nopowerrequired;beebiomes;beebreeding;beejubilance;beeflowers;flowerjungle;flowernether;apiaristsuit;honeyfood;
|
||||
bee.house=nopowerrequired;beebiomes;beebreeding;beejubilance;beeflowers;flowerjungle;flowernether;apiaristsuit;honeyfood;
|
||||
beealyzer=beebiomes;beebreeding;beejubilance;beeflowers;flowerjungle;flowernether;
|
||||
escritoire=beebiomes;beebreeding;beejubilance;beeflowers;
|
||||
farm=farmland;gearbox;valve;fertilizer;hatch;circuitboard;manualfarms;farmgui;
|
||||
flutterlyzer=
|
||||
generator=accesscontrol;accessrules;accesspipe;energyunit;pipette;generatorfuels;
|
||||
generator=energyunit;pipette;generatorfuels;
|
||||
habitat.locator=habitatlocatoruse;
|
||||
moistener=nopowerrequired;accesscontrol;accessrules;accesspipe;pipette;moistenerproducts;
|
||||
naturalist.chest=accesscontrol;accessrules;accesspipe;
|
||||
moistener=nopowerrequired;pipette;moistenerproducts;
|
||||
naturalist.chest=
|
||||
raintank=powerraintank;
|
||||
soldering.iron=circuitboard;
|
||||
treealyzer=
|
||||
@@ -18,7 +18,7 @@ mailbox=postage;
|
||||
philatelist=postage;
|
||||
trade.station=postage;
|
||||
|
||||
powered.machine=powerrequired;accesscontrol;accessrules;accesspipe;
|
||||
powered.machine=
|
||||
analyzer=pipette;flowerjungle;flowernether;apiaristsuit;honeyfood;
|
||||
bottler=pipette;
|
||||
carpenter=pipette;crating;
|
||||
@@ -28,7 +28,7 @@ fermenter=pipette;shortmead;
|
||||
squeezer=pipette;
|
||||
still=pipette;
|
||||
|
||||
engine=accesscontrol;accessrules;accesspipe;energyunit;energybuffer;
|
||||
engine=energyunit;energybuffer;
|
||||
engine.bronze=pipette;enginebronzefuels;enginebronzeheatloss;enginebronzeoutput;enginebronzewaste
|
||||
engine.copper=forcedcooldown;cooldownloss;enginecopperfuels;usesofash;enginecopperwaste;manualpeat;peatharvest
|
||||
engine.tin=forcedcooldown;cooldownloss;enginetinbatteries;enginetinchoke;
|
||||
Reference in new issue
Block a user