fixed a weird edgecase (probably in forge or vanilla) causing a lot of log spam, closes #1

moved all wire-related classes into a seperate sub-package, in preparation for energy conversion blocks
removed a warning from ClientProxy. IndustrialWires does not generate any warnings when compiling now!
This commit is contained in:
malte0811 2016-12-08 17:52:34 +01:00
parent ba2bec5d95
commit 24ea23c2b1
11 changed files with 77 additions and 37 deletions

View file

@ -30,16 +30,10 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft {
version = "12.18.1.2092"
//"1.9.4-12.17.0.1976"
version = "12.18.3.2185"
runDir = "run"
replace '${version}', project.version
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not allways work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20160701"
//"snapshot_20160518" 1.9
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
@ -50,10 +44,15 @@ repositories {
name 'ic2'
url 'http://maven.ic2.player.to/'
}
maven {
name 'jared maven'
url 'http://blamejared.com/maven'
}
}
dependencies {
deobfCompile "net.industrial-craft:industrialcraft-2:2.6.+:dev"
deobfCompile "net.industrial-craft:industrialcraft-2:2.6.+"
deobfCompile "blusunrize:ImmersiveEngineering:0.10-+:deobf"
}
jar {

View file

@ -25,12 +25,12 @@ import blusunrize.immersiveengineering.api.tool.AssemblerHandler.RecipeQuery;
import blusunrize.immersiveengineering.common.IEContent;
import blusunrize.immersiveengineering.common.blocks.stone.BlockTypes_StoneDecoration;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.blocks.BlockIC2Connector;
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorCopper;
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorGlass;
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorGold;
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorHV;
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorTin;
import malte0811.industrialWires.blocks.wire.BlockIC2Connector;
import malte0811.industrialWires.blocks.wire.TileEntityIC2ConnectorCopper;
import malte0811.industrialWires.blocks.wire.TileEntityIC2ConnectorGlass;
import malte0811.industrialWires.blocks.wire.TileEntityIC2ConnectorGold;
import malte0811.industrialWires.blocks.wire.TileEntityIC2ConnectorHV;
import malte0811.industrialWires.blocks.wire.TileEntityIC2ConnectorTin;
import malte0811.industrialWires.crafting.RecipeCoilLength;
import malte0811.industrialWires.items.ItemIC2Coil;
import malte0811.industrialWires.wires.IC2Wiretype;

View file

@ -0,0 +1,5 @@
package malte0811.industrialWires.blocks;
public interface IMetaEnum {
Object[] getValues();
}

View file

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package malte0811.industrialWires.blocks;
package malte0811.industrialWires.blocks.wire;
import java.util.Arrays;
@ -24,6 +24,7 @@ import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConne
import blusunrize.immersiveengineering.common.blocks.BlockIETileProvider;
import blusunrize.immersiveengineering.common.blocks.ItemBlockIEBase;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.IMetaEnum;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
@ -40,7 +41,7 @@ import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
public class BlockIC2Connector extends BlockIETileProvider<BlockTypes_IC2_Connector> {
public class BlockIC2Connector extends BlockIETileProvider<BlockTypes_IC2_Connector> implements IMetaEnum {
public BlockIC2Connector() {
super("ic2Connector", Material.IRON, PropertyEnum.create("type", BlockTypes_IC2_Connector.class), ItemBlockIEBase.class, IEProperties.FACING_ALL);
@ -137,4 +138,8 @@ public class BlockIC2Connector extends BlockIETileProvider<BlockTypes_IC2_Connec
public boolean isVisuallyOpaque() {
return false;
}
@Override
public Object[] getValues() {
return enumValues;
}
}

View file

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package malte0811.industrialWires.blocks;
package malte0811.industrialWires.blocks.wire;
import blusunrize.immersiveengineering.common.blocks.BlockIEBase.IBlockEnum;

View file

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package malte0811.industrialWires.blocks;
package malte0811.industrialWires.blocks.wire;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import malte0811.industrialWires.wires.IC2Wiretype;

View file

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package malte0811.industrialWires.blocks;
package malte0811.industrialWires.blocks.wire;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import malte0811.industrialWires.wires.IC2Wiretype;

View file

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package malte0811.industrialWires.blocks;
package malte0811.industrialWires.blocks.wire;
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;

View file

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package malte0811.industrialWires.blocks;
package malte0811.industrialWires.blocks.wire;
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;

View file

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package malte0811.industrialWires.blocks;
package malte0811.industrialWires.blocks.wire;
import java.util.HashMap;
import java.util.HashSet;
@ -35,7 +35,6 @@ import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConne
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IBlockBounds;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
import blusunrize.immersiveengineering.common.util.Utils;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergyAcceptor;
@ -44,7 +43,6 @@ import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import malte0811.industrialWires.IIC2Connector;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
@ -135,15 +133,15 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
@Override
public void invalidate() {
super.invalidate();
if (!worldObj.isRemote)
if (!worldObj.isRemote&&!first)
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
first = true;
super.invalidate();
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
if (!worldObj.isRemote)
if (!worldObj.isRemote&&!first)
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
first = true;
}
@ -293,8 +291,36 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
return new float[]{0,0,0,1,1,1};
}
/*
* regarding equals+hashCode
* TE's are considered equal if they have the same pos+dimension id
* This is necessary to work around a weird bug causing a lot of log spam (100GB and above are well possible).
* For further information see #1 (https://github.com/malte0811/IndustrialWires/issues/1)
*/
@Override
public int hashCode() {
return pos.hashCode();
int ret = worldObj.provider.getDimension();
ret = 31*ret+pos.hashCode();
return ret;
}
@Override
public boolean equals(Object obj) {
if (obj==this) {
return true;
}
if (!(obj instanceof TileEntityIC2ConnectorTin)) {
return false;
}
if (obj.getClass()!=getClass()) {
return false;
}
TileEntityIC2ConnectorTin te = (TileEntityIC2ConnectorTin) obj;
if (!te.pos.equals(pos)) {
return false;
}
if (te.worldObj.provider.getDimension()!=worldObj.provider.getDimension()) {
return false;
}
return true;
}
}

View file

@ -30,7 +30,9 @@ import blusunrize.lib.manual.ManualPages.PositionedItemStack;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.CommonProxy;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.IMetaEnum;
import malte0811.industrialWires.items.ItemIC2Coil;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
@ -39,7 +41,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.registry.GameData;
public class ClientProxy extends CommonProxy {
@Override
@ -84,20 +85,24 @@ public class ClientProxy extends CommonProxy {
ModelLoader.setCustomModelResourceLocation(IndustrialWires.coil, meta, new ModelResourceLocation(loc, "inventory"));
}
Item blockItem = Item.getItemFromBlock(IndustrialWires.ic2conn);
final ResourceLocation loc = GameData.getBlockRegistry().getNameForObject(IndustrialWires.ic2conn);
final ResourceLocation loc = IndustrialWires.ic2conn.getRegistryName();
ModelLoader.setCustomMeshDefinition(blockItem, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return new ModelResourceLocation(loc, "inventory");
}
});
for(int meta = 0; meta < IndustrialWires.ic2conn.getMetaEnums().length; meta++) {
String location = loc.toString();
String prop = "inventory,type=" + IndustrialWires.ic2conn.getMetaEnums()[meta].toString().toLowerCase(Locale.US);
try {
ModelLoader.setCustomModelResourceLocation(blockItem, meta, new ModelResourceLocation(location, prop));
} catch(NullPointerException npe) {
throw new RuntimeException(IndustrialWires.ic2conn + " lacks an item!", npe);
Block[] blocks = {IndustrialWires.ic2conn};
for (Block b:blocks) {
Object[] v = ((IMetaEnum)b).getValues();
for(int meta = 0; meta < v.length; meta++) {
String location = loc.toString();
String prop = "inventory,type=" + v[meta].toString().toLowerCase(Locale.US);
try {
ModelLoader.setCustomModelResourceLocation(blockItem, meta, new ModelResourceLocation(location, prop));
} catch(NullPointerException npe) {
throw new RuntimeException(b + " lacks an item!", npe);
}
}
}
// OBJLoader.INSTANCE.addDomain(IndustrialWires.MODID);