Use ObjectHolder's for IE items and blocks
This commit is contained in:
parent
71716a722e
commit
17598cc9e9
16 changed files with 147 additions and 64 deletions
55
src/main/java/malte0811/industrialWires/IEObjects.java
Normal file
55
src/main/java/malte0811/industrialWires/IEObjects.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* 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;
|
||||
|
||||
import blusunrize.immersiveengineering.ImmersiveEngineering;
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockIEBase;
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsIE;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
public class IEObjects {
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":metal_decoration0")
|
||||
public static BlockIEBase<BlockTypes_MetalDecoration0> blockMetalDecoration0 = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":metal_decoration1")
|
||||
public static BlockIEBase<BlockTypes_MetalDecoration1> blockMetalDecoration1 = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":metal_decoration2")
|
||||
public static BlockIEBase<BlockTypes_MetalDecoration2> blockMetalDecoration2 = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":metal_device0")
|
||||
public static BlockIEBase<BlockTypes_MetalDevice0> blockMetalDevice0 = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":connector")
|
||||
public static BlockIEBase<BlockTypes_Connector> blockConnectors = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":storage")
|
||||
public static BlockIEBase<BlockTypes_MetalsIE> blockStorage = nullNotNull();
|
||||
|
||||
//ITEMS
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":earmuffs")
|
||||
public static Item itemEarmuffs = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":material")
|
||||
public static Item itemMaterial = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":wirecoil")
|
||||
public static Item itemWireCoil = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":tool")
|
||||
public static Item itemTool = nullNotNull();
|
||||
|
||||
|
||||
// Ugly hack to prevent null warnings
|
||||
private static <T> T nullNotNull() {
|
||||
//noinspection ConstantConditions
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -203,6 +203,7 @@ public class IndustrialWires {
|
|||
proxy.preInit();
|
||||
Compat.preInit();
|
||||
MarxOreHandler.preInit();
|
||||
// This has to run before textures are stitched, i.e. in preInit
|
||||
MechMBPart.preInit();
|
||||
}
|
||||
|
||||
|
@ -304,6 +305,7 @@ public class IndustrialWires {
|
|||
Compat.init();
|
||||
MarxOreHandler.init();
|
||||
PanelComponent.init();
|
||||
MechMBPart.init();
|
||||
if (hasIC2) {
|
||||
EUCapability.register();
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
import static blusunrize.immersiveengineering.common.IEContent.blockMetalDecoration0;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0.HEAVY_ENGINEERING;
|
||||
import static malte0811.industrialWires.IEObjects.blockMetalDecoration0;
|
||||
import static malte0811.industrialWires.IndustrialWires.MMB_BREAKING;
|
||||
import static malte0811.industrialWires.mech_mb.EUCapability.ENERGY_IC2;
|
||||
import static malte0811.industrialWires.util.MiscUtils.getOffset;
|
||||
|
|
|
@ -23,7 +23,6 @@ import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
|||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.redstone.IRedstoneConnector;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.redstone.RedstoneWireNetwork;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsIE;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.*;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
|
@ -168,26 +167,26 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
int right = getRight();
|
||||
int up = offset.getY();
|
||||
if (forward==0) {
|
||||
return IEContent.blockMetalDevice0.getDefaultState().withProperty(IEContent.blockMetalDevice0.property, BlockTypes_MetalDevice0.CAPACITOR_HV);
|
||||
return IEObjects.blockMetalDevice0.getDefaultState().withProperty(IEObjects.blockMetalDevice0.property, BlockTypes_MetalDevice0.CAPACITOR_HV);
|
||||
} else if (forward==-1) {
|
||||
return IEContent.blockConnectors.getDefaultState().withProperty(IEContent.blockConnectors.property, BlockTypes_Connector.RELAY_HV)
|
||||
return IEObjects.blockConnectors.getDefaultState().withProperty(IEObjects.blockConnectors.property, BlockTypes_Connector.RELAY_HV)
|
||||
.withProperty(IEProperties.FACING_ALL, facing);
|
||||
} else if (forward==4&&up==0&&right==1) {
|
||||
return IEContent.blockStorage.getDefaultState().withProperty(IEContent.blockStorage.property, BlockTypes_MetalsIE.STEEL);
|
||||
return IEObjects.blockStorage.getDefaultState().withProperty(IEObjects.blockStorage.property, BlockTypes_MetalsIE.STEEL);
|
||||
} else if (forward>0) {
|
||||
if ((right==0&&up==0)||(right==1&&up==stageCount-1)) {
|
||||
return IEContent.blockMetalDecoration1.getDefaultState().withProperty(IEContent.blockMetalDecoration1.property, BlockTypes_MetalDecoration1.STEEL_FENCE);
|
||||
return IEObjects.blockMetalDecoration1.getDefaultState().withProperty(IEObjects.blockMetalDecoration1.property, BlockTypes_MetalDecoration1.STEEL_FENCE);
|
||||
} else {
|
||||
return IEContent.blockMetalDecoration2.getDefaultState().withProperty(IEContent.blockMetalDecoration2.property, BlockTypes_MetalDecoration2.STEEL_WALLMOUNT)
|
||||
return IEObjects.blockMetalDecoration2.getDefaultState().withProperty(IEObjects.blockMetalDecoration2.property, BlockTypes_MetalDecoration2.STEEL_WALLMOUNT)
|
||||
.withProperty(IEProperties.INT_4, 1-right).withProperty(IEProperties.FACING_ALL, facing.getOpposite());
|
||||
}
|
||||
} else if (forward==-2) {
|
||||
return IEContent.blockMetalDecoration0.getDefaultState().withProperty(IEContent.blockMetalDecoration0.property, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING);
|
||||
return IEObjects.blockMetalDecoration0.getDefaultState().withProperty(IEObjects.blockMetalDecoration0.property, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING);
|
||||
} else if (right==0) {
|
||||
return IEContent.blockConnectors.getDefaultState().withProperty(IEContent.blockConnectors.property, BlockTypes_Connector.CONNECTOR_REDSTONE)
|
||||
return IEObjects.blockConnectors.getDefaultState().withProperty(IEObjects.blockConnectors.property, BlockTypes_Connector.CONNECTOR_REDSTONE)
|
||||
.withProperty(IEProperties.FACING_ALL, facing);
|
||||
} else {
|
||||
return IEContent.blockConnectors.getDefaultState().withProperty(IEContent.blockConnectors.property, BlockTypes_Connector.CONNECTOR_HV)
|
||||
return IEObjects.blockConnectors.getDefaultState().withProperty(IEObjects.blockConnectors.property, BlockTypes_Connector.CONNECTOR_HV)
|
||||
.withProperty(IEProperties.FACING_ALL, facing);
|
||||
}
|
||||
}
|
||||
|
@ -353,7 +352,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
if (distSqu<=tinnitusDistSqu && entity instanceof EntityPlayer) {
|
||||
ItemStack helmet = ((EntityPlayer) entity).inventory.armorInventory.get(3);
|
||||
boolean earMuff = helmet.getItem()==IEContent.itemEarmuffs;
|
||||
boolean earMuff = helmet.getItem()==IEObjects.itemEarmuffs;
|
||||
if (!earMuff&&helmet.hasTagCompound()) {
|
||||
earMuff = helmet.getTagCompound().hasKey("IE:Earmuffs");
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ import net.minecraftforge.fml.common.Mod;
|
|||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
|
@ -69,6 +70,7 @@ import java.util.Map;
|
|||
import static malte0811.industrialWires.client.render.TileRenderMechMB.BASE_MODELS;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = IndustrialWires.MODID, value = Side.CLIENT)
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientEventHandler {
|
||||
public static boolean shouldScreenshot = false;
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
package malte0811.industrialWires.client;
|
||||
|
||||
import blusunrize.immersiveengineering.api.Lib;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.items.ItemEarmuffs;
|
||||
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
|
||||
import malte0811.industrialWires.IEObjects;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.ITickableSound;
|
||||
import net.minecraft.client.audio.PositionedSound;
|
||||
|
@ -72,7 +72,7 @@ public class IWTickableSound extends PositionedSound implements ITickableSound {
|
|||
ItemStack earmuffs = mc.player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
||||
if (ItemNBTHelper.hasKey(earmuffs, Lib.NBT_Earmuffs))
|
||||
earmuffs = ItemNBTHelper.getItemStack(earmuffs, Lib.NBT_Earmuffs);
|
||||
if (!earmuffs.isEmpty() && IEContent.itemEarmuffs.equals(earmuffs.getItem()) &&
|
||||
if (!earmuffs.isEmpty() && IEObjects.itemEarmuffs.equals(earmuffs.getItem()) &&
|
||||
!ItemNBTHelper.getBoolean(earmuffs, "IE:Earmuffs:Cat_" + category.getName())) {
|
||||
mod = ItemEarmuffs.getVolumeMod(earmuffs);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
package malte0811.industrialWires.crafting;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.IEObjects;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
|
@ -64,28 +64,28 @@ public final class IC2TRHelper {
|
|||
case "crafting":
|
||||
switch (variant) {
|
||||
case "coil":
|
||||
stacks.add(new ItemStack(IEContent.blockMetalDecoration0));
|
||||
stacks.add(new ItemStack(IEObjects.blockMetalDecoration0));
|
||||
break;
|
||||
case "alloy":
|
||||
return new OreIngredient("plateConstantan");
|
||||
case "electric_motor":
|
||||
stacks.add(new ItemStack(IEContent.itemMaterial, 1, 27));
|
||||
stacks.add(new ItemStack(IEObjects.itemMaterial, 1, 27));
|
||||
break;
|
||||
case "rubber":
|
||||
stacks.add(new ItemStack(IEContent.itemMaterial, 1, 13));
|
||||
stacks.add(new ItemStack(IEObjects.itemMaterial, 1, 13));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "te":
|
||||
if (variant.equals("mv_transformer")) {
|
||||
stacks.add(new ItemStack(IEContent.blockConnectors, 1, 7));
|
||||
stacks.add(new ItemStack(IEObjects.blockConnectors, 1, 7));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stacks.size()==0) {
|
||||
IndustrialWires.logger.info("No ingredient found for "+type+", "+variant);
|
||||
}
|
||||
return Ingredient.fromStacks(stacks.toArray(new ItemStack[stacks.size()]));
|
||||
return Ingredient.fromStacks(stacks.toArray(new ItemStack[0]));
|
||||
}
|
||||
|
||||
public static ItemStack getTRCable(String variant) {
|
||||
|
|
|
@ -22,8 +22,8 @@ import blusunrize.immersiveengineering.api.crafting.IngredientStack;
|
|||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_Connector;
|
||||
import malte0811.industrialWires.IEObjects;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.IWProperties;
|
||||
import malte0811.industrialWires.blocks.hv.BlockHVMultiblocks;
|
||||
|
@ -56,13 +56,13 @@ import java.util.function.Function;
|
|||
import java.util.function.Predicate;
|
||||
|
||||
import static blusunrize.immersiveengineering.api.IEProperties.*;
|
||||
import static blusunrize.immersiveengineering.common.IEContent.*;
|
||||
import static blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsIE.STEEL;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_Connector.*;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0.HEAVY_ENGINEERING;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration1.STEEL_FENCE;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration2.STEEL_WALLMOUNT;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDevice0.CAPACITOR_HV;
|
||||
import static malte0811.industrialWires.IEObjects.*;
|
||||
import static malte0811.industrialWires.blocks.IWProperties.MarxType.*;
|
||||
import static malte0811.industrialWires.blocks.hv.BlockTypes_HVMultiblocks.MARX;
|
||||
import static malte0811.industrialWires.util.MiscUtils.offset;
|
||||
|
@ -99,13 +99,13 @@ public class MultiblockMarx implements IMultiblock {
|
|||
structureStacks[up][1][0] = structureStacks[0][1][1]
|
||||
= new ItemStack(blockMetalDecoration0, 1, HEAVY_ENGINEERING.getMeta());
|
||||
for (int i = 4; i < structureStacks[up].length; i++) {
|
||||
structureStacks[up][i][0] = new ItemStack(IEContent.blockMetalDecoration1, 1, STEEL_FENCE.getMeta());
|
||||
structureStacks[up][i][0] = new ItemStack(IEObjects.blockMetalDecoration1, 1, STEEL_FENCE.getMeta());
|
||||
}
|
||||
structureStacks[up][structureStacks[0].length - 1][1] = new ItemStack(blockStorage, 1, STEEL.getMeta());
|
||||
} else if (up == 4) {
|
||||
structureStacks[up][2][0] = structureStacks[up][2][1] = hvRel0Dummy;
|
||||
for (int i = 4; i < structureStacks[up].length; i++) {
|
||||
structureStacks[up][i][1] = new ItemStack(IEContent.blockMetalDecoration1, 1, STEEL_FENCE.getMeta());
|
||||
structureStacks[up][i][1] = new ItemStack(IEObjects.blockMetalDecoration1, 1, STEEL_FENCE.getMeta());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,9 +168,9 @@ public class MultiblockMarx implements IMultiblock {
|
|||
};
|
||||
BiPredicate<BlockPos, Boolean> wallmount = (local, up) -> {
|
||||
IBlockState b = world.getBlockState(local);
|
||||
if (b.getBlock()==IEContent.blockMetalDecoration2) {
|
||||
if (b.getBlock()==IEObjects.blockMetalDecoration2) {
|
||||
b = b.getActualState(world, local);
|
||||
if (b.getValue(IEContent.blockMetalDecoration2.property)== STEEL_WALLMOUNT) {
|
||||
if (b.getValue(IEObjects.blockMetalDecoration2.property)== STEEL_WALLMOUNT) {
|
||||
int int_4_wanted = up ? 0 : 1;
|
||||
return b.getValue(IEProperties.INT_4)==int_4_wanted;
|
||||
}
|
||||
|
@ -186,10 +186,10 @@ public class MultiblockMarx implements IMultiblock {
|
|||
Function<BlockPos, Byte> hvRelayWith = (local) -> {
|
||||
IBlockState state = world.getBlockState(local);
|
||||
state = state.getActualState(world, local);
|
||||
if (state.getBlock() != IEContent.blockConnectors) {
|
||||
if (state.getBlock() != IEObjects.blockConnectors) {
|
||||
return (byte)-1;
|
||||
}
|
||||
if (state.getValue(IEContent.blockConnectors.property)!= BlockTypes_Connector.RELAY_HV) {
|
||||
if (state.getValue(IEObjects.blockConnectors.property)!= BlockTypes_Connector.RELAY_HV) {
|
||||
return (byte)-1;
|
||||
}
|
||||
if (state.getValue(FACING_ALL)!=facing) {
|
||||
|
@ -214,10 +214,10 @@ public class MultiblockMarx implements IMultiblock {
|
|||
BiPredicate<BlockPos, BlockTypes_Connector> connNoConns = (local, type) -> {
|
||||
IBlockState state = world.getBlockState(local);
|
||||
state = state.getActualState(world, local);
|
||||
if (state.getBlock() != IEContent.blockConnectors) {
|
||||
if (state.getBlock() != IEObjects.blockConnectors) {
|
||||
return false;
|
||||
}
|
||||
if (state.getValue(IEContent.blockConnectors.property)!= type) {
|
||||
if (state.getValue(IEObjects.blockConnectors.property)!= type) {
|
||||
return false;
|
||||
}
|
||||
if (state.getValue(FACING_ALL)!=(facing)) {
|
||||
|
@ -383,6 +383,7 @@ public class MultiblockMarx implements IMultiblock {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean overwriteBlockRender(ItemStack stack, int iterator) {
|
||||
IBlockState here = getBlockstateFromStack(-1, stack);
|
||||
if (stack == hvRel1Dummy) {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package malte0811.industrialWires.mech_mb;
|
||||
|
||||
import blusunrize.immersiveengineering.api.MultiblockHandler;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
|
@ -45,6 +44,8 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -55,9 +56,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static blusunrize.immersiveengineering.common.IEContent.blockMetalDecoration0;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0.HEAVY_ENGINEERING;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0.LIGHT_ENGINEERING;
|
||||
import static malte0811.industrialWires.IEObjects.blockMetalDecoration0;
|
||||
import static malte0811.industrialWires.IndustrialWires.MODID;
|
||||
import static malte0811.industrialWires.blocks.converter.MechanicalMBBlockType.NO_MODEL;
|
||||
import static malte0811.industrialWires.util.NBTKeys.TYPE;
|
||||
|
@ -86,7 +87,6 @@ public abstract class MechMBPart {
|
|||
public List<BakedQuad> getRotatingQuads() {
|
||||
return TileRenderMechMB.BASE_MODELS.get(getRotatingBaseModel())
|
||||
.getQuads(null, null, 123);
|
||||
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract ResourceLocation getRotatingBaseModel();
|
||||
|
@ -169,6 +169,13 @@ public abstract class MechMBPart {
|
|||
}
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
//The old instances don't have block/blockstate references yet
|
||||
for (String key : REGISTRY.keySet()) {
|
||||
cacheNewInstance(key);
|
||||
}
|
||||
}
|
||||
|
||||
public static ResourceLocation getSchematicLocationForPart(Class<? extends MechMBPart> cl) {
|
||||
String name = REGISTRY.inverse().get(cl);
|
||||
return getSchematicLocationForPart(name);
|
||||
|
@ -218,8 +225,8 @@ public abstract class MechMBPart {
|
|||
}
|
||||
|
||||
public static boolean isValidDefaultCenter(IBlockState state) {
|
||||
return state.getBlock()== IEContent.blockMetalDecoration0&&
|
||||
state.getValue(IEContent.blockMetalDecoration0.property)==BlockTypes_MetalDecoration0.HEAVY_ENGINEERING;
|
||||
return state.getBlock()== blockMetalDecoration0&&
|
||||
state.getValue(blockMetalDecoration0.property)==BlockTypes_MetalDecoration0.HEAVY_ENGINEERING;
|
||||
}
|
||||
|
||||
public static boolean isHeavyEngineering(IBlockState state) {
|
||||
|
@ -227,8 +234,8 @@ public abstract class MechMBPart {
|
|||
}
|
||||
|
||||
public static boolean isLightEngineering(IBlockState state) {
|
||||
return state.getBlock()== IEContent.blockMetalDecoration0&&
|
||||
state.getValue(IEContent.blockMetalDecoration0.property)==BlockTypes_MetalDecoration0.LIGHT_ENGINEERING;
|
||||
return state.getBlock()== blockMetalDecoration0&&
|
||||
state.getValue(blockMetalDecoration0.property)==BlockTypes_MetalDecoration0.LIGHT_ENGINEERING;
|
||||
}
|
||||
|
||||
public IBlockState getDefaultShaft() {
|
||||
|
@ -241,6 +248,9 @@ public abstract class MechMBPart {
|
|||
LIGHT_ENGINEERING);
|
||||
}
|
||||
|
||||
protected boolean areBlocksRegistered() {
|
||||
return Loader.instance().getLoaderState().ordinal()>LoaderState.PREINITIALIZATION.ordinal();
|
||||
}
|
||||
|
||||
public void form(LocalSidedWorld w, Consumer<TileEntityMechMB> initializer) {
|
||||
world = w;
|
||||
|
|
|
@ -34,10 +34,12 @@ import static net.minecraft.util.EnumFacing.WEST;
|
|||
|
||||
public class MechPartCommutator4Phase extends MechPartCommutator {
|
||||
{
|
||||
IBlockState lightEng = getLightEngineering();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
original.put(new BlockPos(2*i-1, j-1, 0), lightEng);
|
||||
if (areBlocksRegistered()) {
|
||||
IBlockState lightEng = getLightEngineering();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
original.put(new BlockPos(2 * i - 1, j - 1, 0), lightEng);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,11 @@ import static net.minecraft.util.math.BlockPos.ORIGIN;
|
|||
|
||||
public class MechPartFourCoils extends MechPartSingleCoil {
|
||||
{
|
||||
IBlockState coil = getCoil();
|
||||
original.put(new BlockPos(-1, 0, 0), coil);
|
||||
original.put(new BlockPos(1, 0, 0), coil);
|
||||
if (areBlocksRegistered()) {
|
||||
IBlockState coil = getCoil();
|
||||
original.put(new BlockPos(-1, 0, 0), coil);
|
||||
original.put(new BlockPos(1, 0, 0), coil);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected double getMaxBuffer() {
|
||||
|
|
|
@ -34,10 +34,12 @@ import static net.minecraft.util.EnumFacing.WEST;
|
|||
|
||||
public class MechPartFourElectrodes extends MechPartTwoElectrodes {
|
||||
{
|
||||
IBlockState lightEng = getLightEngineering();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
original.put(new BlockPos(2*i-1, j-1, 0), lightEng);
|
||||
if (areBlocksRegistered()) {
|
||||
IBlockState lightEng = getLightEngineering();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
original.put(new BlockPos(2 * i - 1, j - 1, 0), lightEng);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,9 @@ import static malte0811.industrialWires.blocks.converter.MechanicalMBBlockType.S
|
|||
|
||||
public class MechPartShaft extends MechMBPart {
|
||||
{
|
||||
original.put(BlockPos.ORIGIN, getDefaultShaft());
|
||||
if (areBlocksRegistered()) {
|
||||
original.put(BlockPos.ORIGIN, getDefaultShaft());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void createMEnergy(MechEnergy e) {}
|
||||
|
|
|
@ -27,8 +27,8 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import static blusunrize.immersiveengineering.common.IEContent.blockMetalDecoration0;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0.COIL_LV;
|
||||
import static malte0811.industrialWires.IEObjects.blockMetalDecoration0;
|
||||
import static malte0811.industrialWires.mech_mb.Waveform.Phases.get;
|
||||
import static malte0811.industrialWires.util.NBTKeys.BUFFER_IN;
|
||||
import static malte0811.industrialWires.util.NBTKeys.BUFFER_OUT;
|
||||
|
@ -36,14 +36,16 @@ import static net.minecraft.util.math.BlockPos.ORIGIN;
|
|||
|
||||
public class MechPartSingleCoil extends MechMBPart implements IMBPartElectric {
|
||||
{
|
||||
IBlockState lightEng = getLightEngineering();
|
||||
IBlockState coil = getCoil();
|
||||
for (int y = -1;y<=1;y++) {
|
||||
original.put(new BlockPos(-1, y, 0), lightEng);
|
||||
original.put(new BlockPos(0, y, 0), coil);
|
||||
original.put(new BlockPos(1, y, 0), lightEng);
|
||||
if (areBlocksRegistered()) {
|
||||
IBlockState lightEng = getLightEngineering();
|
||||
IBlockState coil = getCoil();
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
original.put(new BlockPos(-1, y, 0), lightEng);
|
||||
original.put(new BlockPos(0, y, 0), coil);
|
||||
original.put(new BlockPos(1, y, 0), lightEng);
|
||||
}
|
||||
original.put(ORIGIN, getDefaultShaft());
|
||||
}
|
||||
original.put(ORIGIN, getDefaultShaft());
|
||||
}
|
||||
|
||||
private double bufferToMech;
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
package malte0811.industrialWires.mech_mb;
|
||||
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IRedstoneOutput;
|
||||
import blusunrize.immersiveengineering.common.items.ItemIETool;
|
||||
import blusunrize.immersiveengineering.common.util.ChatUtils;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import malte0811.industrialWires.IEObjects;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.converter.MechanicalMBBlockType;
|
||||
import malte0811.industrialWires.util.LocalSidedWorld;
|
||||
|
@ -42,8 +42,8 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import static blusunrize.immersiveengineering.common.IEContent.blockMetalDecoration0;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0.RS_ENGINEERING;
|
||||
import static malte0811.industrialWires.IEObjects.blockMetalDecoration0;
|
||||
import static malte0811.industrialWires.blocks.converter.MechanicalMBBlockType.SPEEDOMETER;
|
||||
import static net.minecraft.util.EnumFacing.Axis.X;
|
||||
import static net.minecraft.util.EnumFacing.AxisDirection.NEGATIVE;
|
||||
|
@ -55,8 +55,10 @@ public class MechPartSpeedometer extends MechMBPart implements IRedstoneOutput {
|
|||
private int currentOutputLog = -1;
|
||||
private double logFactor = 15 / Math.log(speedFor15RS + 1);
|
||||
{
|
||||
original.put(ORIGIN, blockMetalDecoration0
|
||||
.getStateFromMeta(RS_ENGINEERING.getMeta()));
|
||||
if (areBlocksRegistered()) {
|
||||
original.put(ORIGIN, blockMetalDecoration0
|
||||
.getStateFromMeta(RS_ENGINEERING.getMeta()));
|
||||
}
|
||||
}
|
||||
@Nullable
|
||||
private MechEnergy energy = null;
|
||||
|
@ -160,7 +162,7 @@ public class MechPartSpeedometer extends MechMBPart implements IRedstoneOutput {
|
|||
@Override
|
||||
public int interact(@Nonnull EnumFacing side, @Nonnull Vec3i offset, @Nonnull EntityPlayer player, @Nonnull EnumHand hand, @Nonnull ItemStack heldItem) {
|
||||
if (voltMeter.isEmpty()) {
|
||||
voltMeter = new ItemStack(IEContent.itemTool, 1, ItemIETool.VOLTMETER_META);
|
||||
voltMeter = new ItemStack(IEObjects.itemTool, 1, ItemIETool.VOLTMETER_META);
|
||||
}
|
||||
if (Utils.isHammer(heldItem)) {
|
||||
if (!world.isRemote) {
|
||||
|
|
|
@ -28,15 +28,17 @@ import net.minecraft.util.math.BlockPos;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static blusunrize.immersiveengineering.common.IEContent.blockMetalDecoration0;
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0.GENERATOR;
|
||||
import static malte0811.industrialWires.IEObjects.blockMetalDecoration0;
|
||||
import static net.minecraft.util.EnumFacing.UP;
|
||||
import static net.minecraft.util.math.BlockPos.ORIGIN;
|
||||
|
||||
public class MechPartTwoElectrodes extends MechPartEnergyIO {
|
||||
{
|
||||
original.put(ORIGIN, blockMetalDecoration0.getDefaultState().withProperty(
|
||||
blockMetalDecoration0.property, GENERATOR));
|
||||
if (areBlocksRegistered()) {
|
||||
original.put(ORIGIN, blockMetalDecoration0.getDefaultState().withProperty(
|
||||
blockMetalDecoration0.property, GENERATOR));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue