Code cleanup (#5468)

* remove direct guava predicates from BlockStateMachine

* cleanup blockstatebasic

* fix a large number of e.printStacktrace calls, narrow ComputerIntegration exception signature

* fix simple todos, remove invalid todos, unify some duplicate rendering code

* use a generic method to get around unchecked warning

* remove some redundant uses of hasCapability

* experimental OptionalCapability class. not in use yet

* nullable checks/annotations & remove duplicate field controlType in factory TE

* Inline various redundant variables

* Remove unused list

* Cleanup BlockStateGenerator

* Replace string constants with pointers to the proper mod id constant

* As 9.7.5 breaks backwards compat API wise for the DynamicNetwork this is as good a time as any to remove this deprecated method

* Use two argument constructor instead of appending a ':' inbetween

* Convert other BlockState type classes to using suppliers for tile entity creation
This commit is contained in:
Richard Freimer authored and GitHub committed 2019-05-13 11:43:42 -04:00
1 parent 40620ec23b
commit 80b07bc4b3
115 files changed
+583 -633

No files matched your search

+2
View File
@@ -114,6 +114,8 @@ minecraft {
}
dependencies {
compileOnly "org.jetbrains:annotations:${jb_annotations}"
deobfCompile "MCMultiPart2:MCMultiPart:${mcmp_version}"
compileOnly "mezz.jei:jei_${minecraft_version}:${jei_version}:api"
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
+1
View File
@@ -16,3 +16,4 @@ crafttweaker_version=4.1.15.527
computercraft_version=1.80pr1
top_version=1.12-1.4.23-16
ae2_version=rv6-stable-6
jb_annotations=17.0.0
@@ -2,7 +2,6 @@ package mekanism.api.transmitters;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -22,7 +21,6 @@ import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.Event;
import org.apache.commons.lang3.tuple.Pair;
public abstract class DynamicNetwork<ACCEPTOR, NETWORK extends DynamicNetwork<ACCEPTOR, NETWORK, BUFFER>, BUFFER> implements IClientTicker, INetworkDataHandler {
@@ -280,14 +278,6 @@ public abstract class DynamicNetwork<ACCEPTOR, NETWORK extends DynamicNetwork<AC
return world;
}
/**
* @deprecated No longer used or implemented. To be removed
*/
@Deprecated
public Set<Pair<Coord4D, ACCEPTOR>> getAcceptors(Object data) {
return Collections.emptySet();
}
public void tick() {
onUpdate();
}
+12 -12
View File
@@ -407,7 +407,7 @@ public class ClientProxy extends CommonProxy {
}
private ModelResourceLocation getInventoryMRL(String type) {
return new ModelResourceLocation("mekanism:" + type, "inventory");
return new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, type), "inventory");
}
@Override
@@ -428,8 +428,8 @@ public class ClientProxy extends CommonProxy {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.ObsidianTNT), 0, getInventoryMRL("ObsidianTNT"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.SaltBlock), 0, getInventoryMRL("SaltBlock"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.CardboardBox), 0, new ModelResourceLocation("mekanism:CardboardBox", "storage=false"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.CardboardBox), 1, new ModelResourceLocation("mekanism:CardboardBox", "storage=true"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.CardboardBox), 0, new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "CardboardBox"), "storage=false"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.CardboardBox), 1, new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "CardboardBox"), "storage=true"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.EnergyCube), 0, getInventoryMRL("EnergyCube"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock), 4, getInventoryMRL("digital_miner"));
@@ -567,21 +567,21 @@ public class ClientProxy extends CommonProxy {
}
for (EnumColor color : EnumColor.DYES) {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.PlasticBlock), color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=plastic"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.SlickPlasticBlock), color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=slick"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.GlowPlasticBlock), color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=glow"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.ReinforcedPlasticBlock), color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=reinforced"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.RoadPlasticBlock), color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=road"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.PlasticBlock), color.getMetaValue(), new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "plastic_block"), "type=plastic"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.SlickPlasticBlock), color.getMetaValue(), new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "plastic_block"), "type=slick"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.GlowPlasticBlock), color.getMetaValue(), new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "plastic_block"), "type=glow"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.ReinforcedPlasticBlock), color.getMetaValue(), new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "plastic_block"), "type=reinforced"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.RoadPlasticBlock), color.getMetaValue(), new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "plastic_block"), "type=road"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.PlasticFence), color.getMetaValue(), getInventoryMRL("PlasticFence"));
}
for (EnumOreType ore : EnumOreType.values()) {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.OreBlock), ore.ordinal(), new ModelResourceLocation("mekanism:OreBlock", "type=" + ore.getName()));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.OreBlock), ore.ordinal(), new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "OreBlock"), "type=" + ore.getName()));
}
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.GasTank), stack -> {
GasTankTier tier = GasTankTier.values()[((ItemBlockGasTank) stack.getItem()).getBaseTier(stack).ordinal()];
ResourceLocation baseLocation = new ResourceLocation("mekanism", "GasTank");
ResourceLocation baseLocation = new ResourceLocation(Mekanism.MODID, "GasTank");
return new ModelResourceLocation(baseLocation, "facing=north,tier=" + tier);
});
@@ -659,11 +659,11 @@ public class ClientProxy extends CommonProxy {
return ItemCraftingFormula.MODEL;
});
OBJLoader.INSTANCE.addDomain("mekanism");
OBJLoader.INSTANCE.addDomain(Mekanism.MODID);
}
public void registerItemRender(Item item) {
MekanismRenderer.registerItemRender("mekanism", item);
MekanismRenderer.registerItemRender(Mekanism.MODID, item);
}
private String getProperties(List<String> entries) {
@@ -1,9 +1,7 @@
package mekanism.client.render;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mekanism.api.EnumColor;
import mekanism.api.gas.Gas;
@@ -17,7 +15,10 @@ import mekanism.client.render.tileentity.RenderFluidTank;
import mekanism.client.render.tileentity.RenderThermalEvaporationController;
import mekanism.client.render.transmitter.RenderLogisticalTransporter;
import mekanism.client.render.transmitter.RenderMechanicalPipe;
import mekanism.common.Mekanism;
import mekanism.common.base.IMetaItem;
import mekanism.common.base.ISideConfiguration;
import mekanism.common.tile.prefab.TileEntityBasicBlock;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
@@ -34,6 +35,7 @@ import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.TextureStitchEvent;
@@ -56,7 +58,7 @@ public class MekanismRenderer {
public static float GAS_RENDER_BASE = 0.2F;
public static Map<TransmissionType, TextureAtlasSprite> overlays = new HashMap<>();
public static int[] directionMap = new int[]{3, 0, 1, 2};
public static RenderConfigurableMachine machineRenderer = new RenderConfigurableMachine();
private static RenderConfigurableMachine machineRenderer = new RenderConfigurableMachine();
public static TextureAtlasSprite missingIcon;
private static float lightmapLastX;
private static float lightmapLastY;
@@ -68,20 +70,22 @@ public class MekanismRenderer {
MinecraftForge.EVENT_BUS.register(new MekanismRenderer());
}
@SuppressWarnings("unchecked")
public static <S extends TileEntity & ISideConfiguration> RenderConfigurableMachine<S> machineRenderer() {
return machineRenderer;
}
public static void registerItemRender(String domain, Item item) {
if (item instanceof IMetaItem) {
IMetaItem metaItem = (IMetaItem) item;
List<ModelResourceLocation> variants = new ArrayList<>();
for (int i = 0; i < metaItem.getVariants(); i++) {
if (metaItem.getTexture(i) == null) {
continue;
}
ModelResourceLocation loc = new ModelResourceLocation(domain + ":" + metaItem.getTexture(i),
"inventory");
ModelResourceLocation loc = new ModelResourceLocation(new ResourceLocation(domain, metaItem.getTexture(i)), "inventory");
ModelLoader.setCustomModelResourceLocation(item, i, loc);
variants.add(loc);
ModelBakery.registerItemVariants(item, new ResourceLocation(domain + ":" + metaItem.getTexture(i)));
ModelBakery.registerItemVariants(item, new ResourceLocation(domain, metaItem.getTexture(i)));
}
return;
@@ -325,21 +329,38 @@ public class MekanismRenderer {
return TextureMap.LOCATION_BLOCKS_TEXTURE;
}
public static void glRotateForFacing(TileEntityBasicBlock tileEntity) {
switch (tileEntity.facing) /*TODO: switch the enum*/ {
case NORTH:
GlStateManager.rotate(0, 0.0F, 1.0F, 0.0F);
break;
case SOUTH:
GlStateManager.rotate(180, 0.0F, 1.0F, 0.0F);
break;
case WEST:
GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F);
break;
case EAST:
GlStateManager.rotate(270, 0.0F, 1.0F, 0.0F);
break;
}
}
@SubscribeEvent
public void onStitch(TextureStitchEvent.Pre event) {
for (EnumColor color : EnumColor.values()) {
colors[color.ordinal()] = event.getMap().registerSprite(new ResourceLocation("mekanism:blocks/overlay/overlay_" + color.unlocalizedName));
colors[color.ordinal()] = event.getMap().registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/overlay/overlay_" + color.unlocalizedName));
}
for (TransmissionType type : TransmissionType.values()) {
overlays.put(type, event.getMap().registerSprite(new ResourceLocation("mekanism:blocks/overlay/" + type.getTransmission() + "Overlay")));
overlays.put(type, event.getMap().registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/overlay/" + type.getTransmission() + "Overlay")));
}
energyIcon = event.getMap().registerSprite(new ResourceLocation("mekanism:blocks/liquid/LiquidEnergy"));
heatIcon = event.getMap().registerSprite(new ResourceLocation("mekanism:blocks/liquid/LiquidHeat"));
laserIcon = event.getMap().registerSprite(new ResourceLocation("mekanism:blocks/Laser"));
energyIcon = event.getMap().registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/liquid/LiquidEnergy"));
heatIcon = event.getMap().registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/liquid/LiquidHeat"));
laserIcon = event.getMap().registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/Laser"));
event.getMap().registerSprite(new ResourceLocation("mekanism:blocks/liquid/LiquidHeavyWater"));
event.getMap().registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/liquid/LiquidHeavyWater"));
TransmitterModel.registerIcons(event.getMap());
@@ -518,8 +518,6 @@ public class RenderResizableCuboid {
/**
* A way to automatically generate the different positions given the same arguments.
*
* @param rotation TODO
*/
private List<RenderInfo> getRenderInfos(float[] uv, double sizeU, double sizeV, double textureSizeU, double textureSizeV, double textureOffsetU, double textureOffsetV) {
List<RenderInfo> infos = new ArrayList<>();
@@ -117,7 +117,6 @@ public class RenderTickHandler {
}
// Traverse a copy of jetpack state and do animations
// TODO: This means we're making a full copy of the state per render....might need to revisit
for (UUID uuid : Mekanism.playerState.getActiveJetpacks()) {
EntityPlayer p = mc.world.getPlayerEntityByUUID(uuid);
@@ -157,7 +156,6 @@ public class RenderTickHandler {
}
// Traverse a copy of gasmask state and do animations
// TODO: This means we're making a full copy of the state per render....might need to revisit
if (world.getWorldTime() % 4 == 0) {
for (UUID uuid : Mekanism.playerState.getActiveGasmasks()) {
EntityPlayer p = mc.world.getPlayerEntityByUUID(uuid);
@@ -179,7 +177,6 @@ public class RenderTickHandler {
}
// Traverse a copy of flamethrower state and do animations
// TODO: This means we're making a full copy of the state per render....might need to revisit
if (world.getWorldTime() % 4 == 0) {
for (EntityPlayer p : world.playerEntities) {
if (!Mekanism.playerState.isFlamethrowerOn(p) && !p.isSwingInProgress) {
@@ -2,6 +2,7 @@ package mekanism.client.render.entity;
import javax.annotation.Nonnull;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.Mekanism;
import mekanism.common.entity.EntityFlame;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
@@ -78,6 +79,6 @@ public class RenderFlame extends Render<EntityFlame> {
@Override
protected ResourceLocation getEntityTexture(@Nonnull EntityFlame entity) {
return new ResourceLocation("mekanism:render/Flame.png");
return new ResourceLocation(Mekanism.MODID, "render/Flame.png");
}
}
@@ -63,7 +63,7 @@ public abstract class MekanismItemStackRenderer extends TileEntityItemStackRende
GlStateManager.enableLight(1);
GlStateManager.enableColorMaterial();
GlStateManager.colorMaterial(1032, 5634);
GlStateManager.enableCull();//TODO: This line was not in generators does it matter
GlStateManager.enableCull();
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.popMatrix();
@@ -42,7 +42,7 @@ public class MekanismOBJLoader implements ICustomModelLoader {
IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
for (String s : OBJ_RENDERS) {
ModelResourceLocation model = new ModelResourceLocation("mekanism:" + s, "inventory");
ModelResourceLocation model = new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, s), "inventory");
IBakedModel bakedModel = modelRegistry.getObject(model);
modelRegistry.putObject(model, createBakedObjItemModel(bakedModel, "mekanism:models/block/" + s + ".obj.mek",
new OBJState(Lists.newArrayList(OBJModel.Group.ALL), true), DefaultVertexFormats.ITEM));
@@ -73,7 +73,7 @@ public class MekanismOBJLoader implements ICustomModelLoader {
builder.put("missingno", missing);
return new GlowPanelModel(existingModel, objModel, state, format, builder.build(), new HashMap<>());
} catch (Exception e) {
e.printStackTrace();
Mekanism.logger.error("Failed to load OBJ", e);
}
return null;
}
@@ -15,6 +15,7 @@ import java.util.Set;
import javax.annotation.Nonnull;
import javax.vecmath.Matrix4f;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.Mekanism;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
@@ -104,8 +105,8 @@ public abstract class OBJBakedModelBase extends OBJBakedModel {
f_textures.setAccessible(true);
}
return (ImmutableMap<String, TextureAtlasSprite>) f_textures.get(model);
} catch (Exception e) {
e.printStackTrace();
} catch (ReflectiveOperationException | ClassCastException e) {
Mekanism.logger.error("Could not get private field textures", e);
}
return null;
}
@@ -206,8 +207,8 @@ public abstract class OBJBakedModelBase extends OBJBakedModel {
m_updateStateVisibilityMap.setAccessible(true);
}
m_updateStateVisibilityMap.invoke(this, state);
} catch (Exception e) {
e.printStackTrace();
} catch (ReflectiveOperationException | ClassCastException e) {
Mekanism.logger.error("Could not get private field updateStateVisibilityMap", e);
}
}
@@ -12,6 +12,7 @@ import java.util.Set;
import javax.annotation.Nonnull;
import javax.vecmath.Matrix4f;
import javax.vecmath.Vector3f;
import mekanism.common.Mekanism;
import mekanism.common.block.property.PropertyColor;
import mekanism.common.block.property.PropertyConnection;
import mekanism.common.config.MekanismConfig;
@@ -83,15 +84,15 @@ public class TransmitterModel extends OBJBakedModelBase {
}
public static void registerIcons(TextureMap map) {
transporter_center[0] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterGlass"));
transporter_center_color[0] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterGlassColored"));
transporter_side[0] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterVerticalGlass"));
transporter_side_color[0] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterVerticalGlassColored"));
transporter_center[0] = map.registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/models/multipart/LogisticalTransporterGlass"));
transporter_center_color[0] = map.registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/models/multipart/LogisticalTransporterGlassColored"));
transporter_side[0] = map.registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/models/multipart/LogisticalTransporterVerticalGlass"));
transporter_side_color[0] = map.registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/models/multipart/LogisticalTransporterVerticalGlassColored"));
transporter_center[1] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterGlass"));
transporter_center_color[1] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterGlassColored"));
transporter_side[1] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterVerticalGlass"));
transporter_side_color[1] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterVerticalGlassColored"));
transporter_center[1] = map.registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/models/multipart/opaque/LogisticalTransporterGlass"));
transporter_center_color[1] = map.registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/models/multipart/opaque/LogisticalTransporterGlassColored"));
transporter_side[1] = map.registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/models/multipart/opaque/LogisticalTransporterVerticalGlass"));
transporter_side_color[1] = map.registerSprite(new ResourceLocation(Mekanism.MODID, "blocks/models/multipart/opaque/LogisticalTransporterVerticalGlassColored"));
}
public static void clearCache() {
@@ -15,7 +15,7 @@ public class TieredParticleDigging extends ParticleDigging {
@Nullable
private final EnumColor color;
public TieredParticleDigging(World world, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, IBlockState state, EnumColor color) {
public TieredParticleDigging(World world, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, IBlockState state, @Nullable EnumColor color) {
super(world, xCoord, yCoord, zCoord, xSpeed, ySpeed, zSpeed, state);
this.color = color;
}
@@ -21,25 +21,12 @@ public class RenderChemicalCrystallizer extends TileEntitySpecialRenderer<TileEn
GlStateManager.translate((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalCrystallizer.png"));
switch (tileEntity.facing.ordinal()) /*TODO: switch the enum*/ {
case 2:
GlStateManager.rotate(0, 0.0F, 1.0F, 0.0F);
break;
case 3:
GlStateManager.rotate(180, 0.0F, 1.0F, 0.0F);
break;
case 4:
GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F);
break;
case 5:
GlStateManager.rotate(270, 0.0F, 1.0F, 0.0F);
break;
}
MekanismRenderer.glRotateForFacing(tileEntity);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F);
GlStateManager.popMatrix();
MekanismRenderer.machineRenderer.render(tileEntity, x, y, z, partialTick, destroyStage, alpha);
MekanismRenderer.machineRenderer().render(tileEntity, x, y, z, partialTick, destroyStage, alpha);
}
}
@@ -1,6 +1,7 @@
package mekanism.client.render.tileentity;
import mekanism.client.model.ModelChemicalDissolutionChamber;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.tile.TileEntityChemicalDissolutionChamber;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@@ -20,20 +21,7 @@ public class RenderChemicalDissolutionChamber extends TileEntitySpecialRenderer<
GlStateManager.translate((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalDissolutionChamber.png"));
switch (tileEntity.facing.ordinal()) /*TODO: switch the enum*/ {
case 2:
GlStateManager.rotate(0, 0.0F, 1.0F, 0.0F);
break;
case 3:
GlStateManager.rotate(180, 0.0F, 1.0F, 0.0F);
break;
case 4:
GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F);
break;
case 5:
GlStateManager.rotate(270, 0.0F, 1.0F, 0.0F);
break;
}
MekanismRenderer.glRotateForFacing(tileEntity);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F);
@@ -106,6 +106,6 @@ public class RenderEnergyCube extends TileEntitySpecialRenderer<TileEntityEnergy
GlStateManager.popMatrix();
}
MekanismRenderer.machineRenderer.render(tileEntity, x, y, z, partialTick, destroyStage, alpha);
MekanismRenderer.machineRenderer().render(tileEntity, x, y, z, partialTick, destroyStage, alpha);
}
}
@@ -11,6 +11,6 @@ public class RenderGasTank extends TileEntitySpecialRenderer<TileEntityGasTank>
@Override
public void render(TileEntityGasTank tileEntity, double x, double y, double z, float partialTick, int destroyStage, float alpha) {
MekanismRenderer.machineRenderer.render(tileEntity, x, y, z, partialTick, destroyStage, alpha);
MekanismRenderer.machineRenderer().render(tileEntity, x, y, z, partialTick, destroyStage, alpha);
}
}
@@ -22,25 +22,12 @@ public class RenderQuantumEntangloporter extends TileEntitySpecialRenderer<TileE
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "QuantumEntangloporter.png"));
switch (tileEntity.facing.ordinal()) {
case 2:
GlStateManager.rotate(0, 0.0F, 1.0F, 0.0F);
break;
case 3:
GlStateManager.rotate(180, 0.0F, 1.0F, 0.0F);
break;
case 4:
GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F);
break;
case 5:
GlStateManager.rotate(270, 0.0F, 1.0F, 0.0F);
break;
}
MekanismRenderer.glRotateForFacing(tileEntity);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F, rendererDispatcher.renderEngine, false);
GlStateManager.popMatrix();
MekanismRenderer.machineRenderer.render(tileEntity, x, y, z, partialTick, destroyStage, alpha);
MekanismRenderer.machineRenderer().render(tileEntity, x, y, z, partialTick, destroyStage, alpha);
}
}
@@ -1,6 +1,7 @@
package mekanism.client.render.tileentity;
import mekanism.client.model.ModelResistiveHeater;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.tile.TileEntityResistiveHeater;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@@ -20,20 +21,7 @@ public class RenderResistiveHeater extends TileEntitySpecialRenderer<TileEntityR
GlStateManager.translate((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater.png"));
switch (tileEntity.facing.ordinal()) {
case 2:
GlStateManager.rotate(0, 0.0F, 1.0F, 0.0F);
break;
case 3:
GlStateManager.rotate(180, 0.0F, 1.0F, 0.0F);
break;
case 4:
GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F);
break;
case 5:
GlStateManager.rotate(270, 0.0F, 1.0F, 0.0F);
break;
}
MekanismRenderer.glRotateForFacing(tileEntity);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F, tileEntity.isActive, rendererDispatcher.renderEngine, true);
@@ -1,6 +1,7 @@
package mekanism.client.render.tileentity;
import mekanism.client.model.ModelRotaryCondensentrator;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.tile.TileEntityRotaryCondensentrator;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@@ -21,20 +22,7 @@ public class RenderRotaryCondensentrator extends TileEntitySpecialRenderer<TileE
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RotaryCondensentrator.png"));
switch (tileEntity.facing.ordinal()) {
case 2:
GlStateManager.rotate(0, 0.0F, 1.0F, 0.0F);
break;
case 3:
GlStateManager.rotate(180, 0.0F, 1.0F, 0.0F);
break;
case 4:
GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F);
break;
case 5:
GlStateManager.rotate(270, 0.0F, 1.0F, 0.0F);
break;
}
MekanismRenderer.glRotateForFacing(tileEntity);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F);
@@ -1,6 +1,7 @@
package mekanism.client.render.tileentity;
import mekanism.client.model.ModelSecurityDesk;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.tile.TileEntitySecurityDesk;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@@ -21,20 +22,7 @@ public class RenderSecurityDesk extends TileEntitySpecialRenderer<TileEntitySecu
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SecurityDesk.png"));
switch (tileEntity.facing.ordinal()) /*TODO: switch the enum*/ {
case 2:
GlStateManager.rotate(0, 0.0F, 1.0F, 0.0F);
break;
case 3:
GlStateManager.rotate(180, 0.0F, 1.0F, 0.0F);
break;
case 4:
GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F);
break;
case 5:
GlStateManager.rotate(270, 0.0F, 1.0F, 0.0F);
break;
}
MekanismRenderer.glRotateForFacing(tileEntity);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F, rendererDispatcher.renderEngine);
@@ -1,6 +1,7 @@
package mekanism.client.render.tileentity;
import mekanism.client.model.ModelSeismicVibrator;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.tile.TileEntitySeismicVibrator;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@@ -21,20 +22,7 @@ public class RenderSeismicVibrator extends TileEntitySpecialRenderer<TileEntityS
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SeismicVibrator.png"));
switch (tileEntity.facing.ordinal()) /*TODO: switch the enum*/ {
case 2:
GlStateManager.rotate(0, 0.0F, 1.0F, 0.0F);
break;
case 3:
GlStateManager.rotate(180, 0.0F, 1.0F, 0.0F);
break;
case 4:
GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F);
break;
case 5:
GlStateManager.rotate(270, 0.0F, 1.0F, 0.0F);
break;
}
MekanismRenderer.glRotateForFacing(tileEntity);
float actualRate = (float) Math.sin((tileEntity.clientPiston + (tileEntity.isActive ? partialTick : 0)) / 5F);
@@ -1,6 +1,7 @@
package mekanism.client.render.tileentity;
import mekanism.client.model.ModelSolarNeutronActivator;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.tile.TileEntitySolarNeutronActivator;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@@ -21,20 +22,7 @@ public class RenderSolarNeutronActivator extends TileEntitySpecialRenderer<TileE
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarNeutronActivator.png"));
switch (tileEntity.facing.ordinal()) {
case 2:
GlStateManager.rotate(0, 0.0F, 1.0F, 0.0F);
break;
case 3:
GlStateManager.rotate(180, 0.0F, 1.0F, 0.0F);
break;
case 4:
GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F);
break;
case 5:
GlStateManager.rotate(270, 0.0F, 1.0F, 0.0F);
break;
}
MekanismRenderer.glRotateForFacing(tileEntity);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
@@ -39,10 +39,10 @@ public abstract class RenderTransmitterBase<T extends TileEntityTransmitter> ext
if (contentsModel == null) {
try {
contentsModel = (OBJModel) OBJLoader.INSTANCE.loadModel(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"));
contentsMap = buildModelMap(contentsModel);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
contentsMap = buildModelMap(contentsModel);
}
}
@@ -1,6 +1,7 @@
package mekanism.client.sound;
import mekanism.client.ClientTickHandler;
import mekanism.common.Mekanism;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
@@ -9,9 +10,9 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class FlamethrowerSound extends PlayerSound {
private static ResourceLocation IDLE_SOUND = new ResourceLocation("mekanism", "item.flamethrower.idle");
private static ResourceLocation ON_SOUND = new ResourceLocation("mekanism", "item.flamethrower.active");
private static ResourceLocation OFF_SOUND = new ResourceLocation("mekanism", "item.flamethrower.active");
private static ResourceLocation IDLE_SOUND = new ResourceLocation(Mekanism.MODID, "item.flamethrower.idle");
private static ResourceLocation ON_SOUND = new ResourceLocation(Mekanism.MODID, "item.flamethrower.active");
private static ResourceLocation OFF_SOUND = new ResourceLocation(Mekanism.MODID, "item.flamethrower.active");
private boolean inUse;
@@ -1,6 +1,7 @@
package mekanism.client.sound;
import mekanism.client.ClientTickHandler;
import mekanism.common.Mekanism;
import mekanism.common.item.ItemGasMask;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
@@ -10,7 +11,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GasMaskSound extends PlayerSound {
private static final ResourceLocation SOUND = new ResourceLocation("mekanism", "item.gasMask");
private static final ResourceLocation SOUND = new ResourceLocation(Mekanism.MODID, "item.gasMask");
public GasMaskSound(EntityPlayer player) {
super(player, SOUND);
@@ -1,6 +1,7 @@
package mekanism.client.sound;
import mekanism.client.ClientTickHandler;
import mekanism.common.Mekanism;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
@@ -9,7 +10,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class JetpackSound extends PlayerSound {
private static final ResourceLocation SOUND = new ResourceLocation("mekanism", "item.jetpack");
private static final ResourceLocation SOUND = new ResourceLocation(Mekanism.MODID, "item.jetpack");
public JetpackSound(EntityPlayer player) {
super(player, SOUND);
@@ -6,6 +6,7 @@ import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import mekanism.common.Mekanism;
import mekanism.common.Upgrade;
import mekanism.common.base.IUpgradeTile;
import mekanism.common.config.MekanismConfig;
@@ -85,11 +86,15 @@ public class SoundHandler {
if (s == null || !Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(s)) {
// No sound playing, start one up - we assume that tile sounds will play until explicitly stopped
s = new PositionedSoundRecord(soundLoc, SoundCategory.BLOCKS, (float) (volume * MekanismConfig.current().client.baseSoundVolume.val()), 1.0f,
true, 0, ISound.AttenuationType.LINEAR, pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f);
// Force the underlying sound to get initialized
// TODO: Understand what this is doing exactly
s.createAccessor(Minecraft.getMinecraft().getSoundHandler());
true, 0, ISound.AttenuationType.LINEAR, pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f) {
@Override
public float getVolume() {
if (this.sound == null) {
this.createAccessor(Minecraft.getMinecraft().getSoundHandler());
}
return super.getVolume();
}
};
// Start the sound
playSound(s);
@@ -123,7 +128,7 @@ public class SoundHandler {
// Ignore any sound event outside this mod namespace
ResourceLocation soundLoc = event.getSound().getSoundLocation();
if (!soundLoc.getNamespace().equals("mekanism")) {
if (!soundLoc.getNamespace().equals(Mekanism.MODID)) {
return;
}
@@ -26,6 +26,7 @@ public final class BoxBlacklistParser {
}
}
@SuppressWarnings("ResultOfMethodCallIgnored")
private static void generateFiles() throws IOException {
mekanismDir.mkdirs();
if (!boxBlacklistFile.exists()) {
@@ -1,5 +1,6 @@
package mekanism.common;
import javax.annotation.Nonnull;
import mekanism.api.infuse.InfuseObject;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.api.infuse.InfuseType;
@@ -21,6 +22,15 @@ public class InfuseStorage implements ISustainedData {
amount = infuseAmount;
}
/**
* Replace this instance's properties with that from another
* @param other the instance to copy from
*/
public void copyFrom(@Nonnull InfuseStorage other) {
this.type = other.getType();
this.amount = other.getAmount();
}
public boolean contains(InfuseStorage storage) {
return type == storage.type && amount >= storage.amount;
}
+8 -8
View File
@@ -785,13 +785,13 @@ public class Mekanism {
Mekanism.proxy.preInit();
//Register infuses
InfuseRegistry.registerInfuseType(new InfuseType("CARBON", new ResourceLocation("mekanism:blocks/infuse/Carbon")).setTranslationKey("carbon"));
InfuseRegistry.registerInfuseType(new InfuseType("TIN", new ResourceLocation("mekanism:blocks/infuse/Tin")).setTranslationKey("tin"));
InfuseRegistry.registerInfuseType(new InfuseType("DIAMOND", new ResourceLocation("mekanism:blocks/infuse/Diamond")).setTranslationKey("diamond"));
InfuseRegistry.registerInfuseType(new InfuseType("REDSTONE", new ResourceLocation("mekanism:blocks/infuse/Redstone")).setTranslationKey("redstone"));
InfuseRegistry.registerInfuseType(new InfuseType("FUNGI", new ResourceLocation("mekanism:blocks/infuse/Fungi")).setTranslationKey("fungi"));
InfuseRegistry.registerInfuseType(new InfuseType("BIO", new ResourceLocation("mekanism:blocks/infuse/Bio")).setTranslationKey("bio"));
InfuseRegistry.registerInfuseType(new InfuseType("OBSIDIAN", new ResourceLocation("mekanism:blocks/infuse/Obsidian")).setTranslationKey("obsidian"));
InfuseRegistry.registerInfuseType(new InfuseType("CARBON", new ResourceLocation(Mekanism.MODID, "blocks/infuse/Carbon")).setTranslationKey("carbon"));
InfuseRegistry.registerInfuseType(new InfuseType("TIN", new ResourceLocation(Mekanism.MODID, "blocks/infuse/Tin")).setTranslationKey("tin"));
InfuseRegistry.registerInfuseType(new InfuseType("DIAMOND", new ResourceLocation(Mekanism.MODID, "blocks/infuse/Diamond")).setTranslationKey("diamond"));
InfuseRegistry.registerInfuseType(new InfuseType("REDSTONE", new ResourceLocation(Mekanism.MODID, "blocks/infuse/Redstone")).setTranslationKey("redstone"));
InfuseRegistry.registerInfuseType(new InfuseType("FUNGI", new ResourceLocation(Mekanism.MODID, "blocks/infuse/Fungi")).setTranslationKey("fungi"));
InfuseRegistry.registerInfuseType(new InfuseType("BIO", new ResourceLocation(Mekanism.MODID, "blocks/infuse/Bio")).setTranslationKey("bio"));
InfuseRegistry.registerInfuseType(new InfuseType("OBSIDIAN", new ResourceLocation(Mekanism.MODID, "blocks/infuse/Obsidian")).setTranslationKey("obsidian"));
Capabilities.registerCapabilities();
@@ -1005,7 +1005,7 @@ public class Mekanism {
@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equals("mekanism")) {
if (event.getModID().equals(Mekanism.MODID)) {
proxy.loadConfiguration();
proxy.onConfigSync(false);
}
@@ -19,10 +19,10 @@ public class MekanismFluids {
public static final Gas SulfuricAcid = new Gas("sulfuricacid", 0x82802B);
public static final Gas HydrogenChloride = new Gas("hydrogenchloride", 0xA8F1E9);
public static final Fluid HeavyWater = new Fluid("heavywater", new ResourceLocation("mekanism:blocks/liquid/LiquidHeavyWater"),
new ResourceLocation("mekanism:blocks/liquid/LiquidHeavyWater"));
public static final Fluid Steam = new Fluid("steam", new ResourceLocation("mekanism:blocks/liquid/LiquidSteam"),
new ResourceLocation("mekanism:blocks/liquid/LiquidSteam")).setGaseous(true);
public static final Fluid HeavyWater = new Fluid("heavywater", new ResourceLocation(Mekanism.MODID, "blocks/liquid/LiquidHeavyWater"),
new ResourceLocation(Mekanism.MODID, "blocks/liquid/LiquidHeavyWater"));
public static final Fluid Steam = new Fluid("steam", new ResourceLocation(Mekanism.MODID, "blocks/liquid/LiquidSteam"),
new ResourceLocation(Mekanism.MODID, "blocks/liquid/LiquidSteam")).setGaseous(true);
//Internal gases
public static final Gas LiquidOsmium = new Gas("liquidosmium", 0x52bdca);
@@ -97,48 +97,44 @@ public class PacketHandler {
* @param output - the output stream to write to
*/
public static void encode(Object[] dataValues, ByteBuf output) {
try {
for (Object data : dataValues) {
if (data instanceof Byte) {
output.writeByte((Byte) data);
} else if (data instanceof Integer) {
output.writeInt((Integer) data);
} else if (data instanceof Short) {
output.writeShort((Short) data);
} else if (data instanceof Long) {
output.writeLong((Long) data);
} else if (data instanceof Boolean) {
output.writeBoolean((Boolean) data);
} else if (data instanceof Double) {
output.writeDouble((Double) data);
} else if (data instanceof Float) {
output.writeFloat((Float) data);
} else if (data instanceof String) {
writeString(output, (String) data);
} else if (data instanceof EnumFacing) {
output.writeInt(((EnumFacing) data).ordinal());
} else if (data instanceof ItemStack) {
writeStack(output, (ItemStack) data);
} else if (data instanceof NBTTagCompound) {
writeNBT(output, (NBTTagCompound) data);
} else if (data instanceof int[]) {
for (int i : (int[]) data) {
output.writeInt(i);
}
} else if (data instanceof byte[]) {
for (byte b : (byte[]) data) {
output.writeByte(b);
}
} else if (data instanceof ArrayList) {
encode(((ArrayList<?>) data).toArray(), output);
} else if (data instanceof NonNullList) {
encode(((NonNullList) data).toArray(), output);
} else {
throw new RuntimeException("Un-encodable data passed to encode(): " + data + ", full data: " + Arrays.toString(dataValues));
for (Object data : dataValues) {
if (data instanceof Byte) {
output.writeByte((Byte) data);
} else if (data instanceof Integer) {
output.writeInt((Integer) data);
} else if (data instanceof Short) {
output.writeShort((Short) data);
} else if (data instanceof Long) {
output.writeLong((Long) data);
} else if (data instanceof Boolean) {
output.writeBoolean((Boolean) data);
} else if (data instanceof Double) {
output.writeDouble((Double) data);
} else if (data instanceof Float) {
output.writeFloat((Float) data);
} else if (data instanceof String) {
writeString(output, (String) data);
} else if (data instanceof EnumFacing) {
output.writeInt(((EnumFacing) data).ordinal());
} else if (data instanceof ItemStack) {
writeStack(output, (ItemStack) data);
} else if (data instanceof NBTTagCompound) {
writeNBT(output, (NBTTagCompound) data);
} else if (data instanceof int[]) {
for (int i : (int[]) data) {
output.writeInt(i);
}
} else if (data instanceof byte[]) {
for (byte b : (byte[]) data) {
output.writeByte(b);
}
} else if (data instanceof ArrayList) {
encode(((ArrayList<?>) data).toArray(), output);
} else if (data instanceof NonNullList) {
encode(((NonNullList) data).toArray(), output);
} else {
throw new RuntimeException("Un-encodable data passed to encode(): " + data + ", full data: " + Arrays.toString(dataValues));
}
} catch (Exception e) {
Mekanism.logger.error("Error while encoding packet data.", e);
}
}
@@ -7,6 +7,7 @@ import javax.annotation.Nullable;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.common.InfuseStorage;
import mekanism.common.Mekanism;
import mekanism.common.block.states.BlockStateMachine.MachineType;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
@@ -92,7 +93,7 @@ public interface IFactory {
RecipeType(String s, String s1, MachineType t, MachineFuelType ft, boolean b1, Recipe r) {
name = s;
sound = new SoundEvent(new ResourceLocation("mekanism", "tile.machine." + s1));
sound = new SoundEvent(new ResourceLocation(Mekanism.MODID, "tile.machine." + s1));
type = t;
fuelType = ft;
fuelSpeed = b1;
@@ -1,5 +1,6 @@
package mekanism.common.block;
import java.util.Objects;
import java.util.UUID;
import javax.annotation.Nonnull;
import mekanism.api.Coord4D;
@@ -517,7 +518,7 @@ public abstract class BlockBasic extends BlockTileDrops {
@Override
public boolean hasTileEntity(IBlockState state) {
BasicBlockType type = BasicBlockType.get(state);
return type != null && type.tileEntityClass != null;
return type != null && type.tileEntitySupplier != null;
}
@Override
@@ -525,13 +526,14 @@ public abstract class BlockBasic extends BlockTileDrops {
if (BasicBlockType.get(state) == null) {
return null;
}
return BasicBlockType.get(state).create();
return Objects.requireNonNull(BasicBlockType.get(state)).create();
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
if (world.getTileEntity(pos) instanceof TileEntityBasicBlock) {
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos);
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityBasicBlock) {
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) te;
int side = MathHelper.floor((placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int height = Math.round(placer.rotationPitch);
int change = 3;
@@ -573,13 +575,12 @@ public abstract class BlockBasic extends BlockTileDrops {
world.checkLightFor(EnumSkyBlock.BLOCK, pos);
world.checkLightFor(EnumSkyBlock.SKY, pos);
if (!world.isRemote && world.getTileEntity(pos) != null) {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof IMultiblock) {
((IMultiblock<?>) tileEntity).doUpdate();
if (!world.isRemote && te != null) {
if (te instanceof IMultiblock) {
((IMultiblock<?>) te).doUpdate();
}
if (tileEntity instanceof IStructuralMultiblock) {
((IStructuralMultiblock) tileEntity).doUpdate();
if (te instanceof IStructuralMultiblock) {
((IStructuralMultiblock) te).doUpdate();
}
}
}
@@ -232,9 +232,8 @@ public class BlockEnergyCube extends BlockMekanismContainer {
securityItem.setOwnerUUID(itemStack, ((ISecurityTile) tileEntity).getSecurity().getOwnerUUID());
securityItem.setSecurity(itemStack, ((ISecurityTile) tileEntity).getSecurity().getMode());
}
ISideConfiguration config = tileEntity;
config.getConfig().write(ItemDataUtils.getDataMap(itemStack));
config.getEjector().write(ItemDataUtils.getDataMap(itemStack));
((ISideConfiguration) tileEntity).getConfig().write(ItemDataUtils.getDataMap(itemStack));
((ISideConfiguration) tileEntity).getEjector().write(ItemDataUtils.getDataMap(itemStack));
}
ITierItem tierItem = (ITierItem) itemStack.getItem();
@@ -207,9 +207,8 @@ public class BlockGasTank extends BlockMekanismContainer {
securityItem.setOwnerUUID(itemStack, ((ISecurityTile) tileEntity).getSecurity().getOwnerUUID());
securityItem.setSecurity(itemStack, ((ISecurityTile) tileEntity).getSecurity().getMode());
}
ISideConfiguration config = tileEntity;
config.getConfig().write(ItemDataUtils.getDataMap(itemStack));
config.getEjector().write(ItemDataUtils.getDataMap(itemStack));
((ISideConfiguration) tileEntity).getConfig().write(ItemDataUtils.getDataMap(itemStack));
((ISideConfiguration) tileEntity).getEjector().write(ItemDataUtils.getDataMap(itemStack));
}
ITierItem tierItem = (ITierItem) itemStack.getItem();
tierItem.setBaseTier(itemStack, tileEntity.tier.getBaseTier());
@@ -63,7 +63,7 @@ public class BlockPlasticFence extends BlockFence {
properties += "north=" + state.getValue(NORTH) + ",";
properties += "south=" + state.getValue(SOUTH) + ",";
properties += "west=" + state.getValue(WEST);
ResourceLocation baseLocation = new ResourceLocation("mekanism", "PlasticFence");
ResourceLocation baseLocation = new ResourceLocation(Mekanism.MODID, "PlasticFence");
return new ModelResourceLocation(baseLocation, properties);
}
}
@@ -1,8 +1,9 @@
package mekanism.common.block.states;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import java.util.Locale;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import mekanism.common.Mekanism;
@@ -59,7 +60,7 @@ public class BlockStateBasic extends ExtendedBlockState {
public PropertyEnum<BasicBlockType> getProperty() {
if (predicatedProperty == null) {
predicatedProperty = PropertyEnum.create("type", BasicBlockType.class, new BasicBlockPredicate(this));
predicatedProperty = PropertyEnum.create("type", BasicBlockType.class, it->Objects.requireNonNull(it).blockType==this);
}
return predicatedProperty;
}
@@ -71,70 +72,62 @@ public class BlockStateBasic extends ExtendedBlockState {
case BASIC_BLOCK_2:
return MekanismBlocks.BasicBlock2;
default:
return null;
throw new IllegalStateException();
}
}
}
public enum BasicBlockType implements IStringSerializable {
OSMIUM_BLOCK(BasicBlock.BASIC_BLOCK_1, 0, "OsmiumBlock", null, false, Predicates.alwaysFalse(), false, false, true),
BRONZE_BLOCK(BasicBlock.BASIC_BLOCK_1, 1, "BronzeBlock", null, false, Predicates.alwaysFalse(), false, false, true),
REFINED_OBSIDIAN(BasicBlock.BASIC_BLOCK_1, 2, "RefinedObsidian", null, false, Predicates.alwaysFalse(), false, false, true),
COAL_BLOCK(BasicBlock.BASIC_BLOCK_1, 3, "CharcoalBlock", null, false, Predicates.alwaysFalse(), false, false, false),
REFINED_GLOWSTONE(BasicBlock.BASIC_BLOCK_1, 4, "RefinedGlowstone", null, false, Predicates.alwaysFalse(), false, false, true),
STEEL_BLOCK(BasicBlock.BASIC_BLOCK_1, 5, "SteelBlock", null, false, Predicates.alwaysFalse(), false, false, true),
BIN(BasicBlock.BASIC_BLOCK_1, 6, "Bin", TileEntityBin.class, true, Plane.HORIZONTAL, true, true, false, true),
TELEPORTER_FRAME(BasicBlock.BASIC_BLOCK_1, 7, "TeleporterFrame", null, true, Predicates.alwaysFalse(), false, false, false),
STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, "SteelCasing", null, true, Predicates.alwaysFalse(), false, false, false),
DYNAMIC_TANK(BasicBlock.BASIC_BLOCK_1, 9, "DynamicTank", TileEntityDynamicTank.class, true, Predicates.alwaysFalse(), false, false, false),
STRUCTURAL_GLASS(BasicBlock.BASIC_BLOCK_1, 10, "StructuralGlass", TileEntityStructuralGlass.class, true, Predicates.alwaysFalse(), false, false, false),
DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve.class, true, Predicates.alwaysFalse(), false, false, false),
COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, "CopperBlock", null, false, Predicates.alwaysFalse(), false, false, true),
TIN_BLOCK(BasicBlock.BASIC_BLOCK_1, 13, "TinBlock", null, false, Predicates.alwaysFalse(), false, false, true),
THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", TileEntityThermalEvaporationController.class, true, Plane.HORIZONTAL, true, false, false),
THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", TileEntityThermalEvaporationValve.class, true, Predicates.alwaysFalse(), false, false, false),
THERMAL_EVAPORATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, "ThermalEvaporationBlock", TileEntityThermalEvaporationBlock.class, true, Predicates.alwaysFalse(), false, false, false),
INDUCTION_CASING(BasicBlock.BASIC_BLOCK_2, 1, "InductionCasing", TileEntityInductionCasing.class, true, Predicates.alwaysFalse(), false, false, false),
INDUCTION_PORT(BasicBlock.BASIC_BLOCK_2, 2, "InductionPort", TileEntityInductionPort.class, true, Predicates.alwaysFalse(), true, false, false),
INDUCTION_CELL(BasicBlock.BASIC_BLOCK_2, 3, "InductionCell", TileEntityInductionCell.class, true, Predicates.alwaysFalse(), false, true, false),
INDUCTION_PROVIDER(BasicBlock.BASIC_BLOCK_2, 4, "InductionProvider", TileEntityInductionProvider.class, true, Predicates.alwaysFalse(), false, true, false),
SUPERHEATING_ELEMENT(BasicBlock.BASIC_BLOCK_2, 5, "SuperheatingElement", TileEntitySuperheatingElement.class, true, Predicates.alwaysFalse(), false, false, false),
PRESSURE_DISPERSER(BasicBlock.BASIC_BLOCK_2, 6, "PressureDisperser", TileEntityPressureDisperser.class, true, Predicates.alwaysFalse(), false, false, false),
BOILER_CASING(BasicBlock.BASIC_BLOCK_2, 7, "BoilerCasing", TileEntityBoilerCasing.class, true, Predicates.alwaysFalse(), false, false, false),
BOILER_VALVE(BasicBlock.BASIC_BLOCK_2, 8, "BoilerValve", TileEntityBoilerValve.class, true, Predicates.alwaysFalse(), false, false, false),
SECURITY_DESK(BasicBlock.BASIC_BLOCK_2, 9, "SecurityDesk", TileEntitySecurityDesk.class, true, Plane.HORIZONTAL, false, false, false);
OSMIUM_BLOCK(BasicBlock.BASIC_BLOCK_1, 0, "OsmiumBlock", null, false, BlockStateUtils.NO_ROTATION, false, false, true),
BRONZE_BLOCK(BasicBlock.BASIC_BLOCK_1, 1, "BronzeBlock", null, false, BlockStateUtils.NO_ROTATION, false, false, true),
REFINED_OBSIDIAN(BasicBlock.BASIC_BLOCK_1, 2, "RefinedObsidian", null, false, BlockStateUtils.NO_ROTATION, false, false, true),
COAL_BLOCK(BasicBlock.BASIC_BLOCK_1, 3, "CharcoalBlock", null, false, BlockStateUtils.NO_ROTATION, false, false, false),
REFINED_GLOWSTONE(BasicBlock.BASIC_BLOCK_1, 4, "RefinedGlowstone", null, false, BlockStateUtils.NO_ROTATION, false, false, true),
STEEL_BLOCK(BasicBlock.BASIC_BLOCK_1, 5, "SteelBlock", null, false, BlockStateUtils.NO_ROTATION, false, false, true),
BIN(BasicBlock.BASIC_BLOCK_1, 6, "Bin", TileEntityBin::new, true, Plane.HORIZONTAL, true, true, false, true),
TELEPORTER_FRAME(BasicBlock.BASIC_BLOCK_1, 7, "TeleporterFrame", null, true, BlockStateUtils.NO_ROTATION, false, false, false),
STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, "SteelCasing", null, true, BlockStateUtils.NO_ROTATION, false, false, false),
DYNAMIC_TANK(BasicBlock.BASIC_BLOCK_1, 9, "DynamicTank", TileEntityDynamicTank::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
STRUCTURAL_GLASS(BasicBlock.BASIC_BLOCK_1, 10, "StructuralGlass", TileEntityStructuralGlass::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, "CopperBlock", null, false, BlockStateUtils.NO_ROTATION, false, false, true),
TIN_BLOCK(BasicBlock.BASIC_BLOCK_1, 13, "TinBlock", null, false, BlockStateUtils.NO_ROTATION, false, false, true),
THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", TileEntityThermalEvaporationController::new, true, Plane.HORIZONTAL, true, false, false),
THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", TileEntityThermalEvaporationValve::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
THERMAL_EVAPORATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, "ThermalEvaporationBlock", TileEntityThermalEvaporationBlock::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
INDUCTION_CASING(BasicBlock.BASIC_BLOCK_2, 1, "InductionCasing", TileEntityInductionCasing::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
INDUCTION_PORT(BasicBlock.BASIC_BLOCK_2, 2, "InductionPort", TileEntityInductionPort::new, true, BlockStateUtils.NO_ROTATION, true, false, false),
INDUCTION_CELL(BasicBlock.BASIC_BLOCK_2, 3, "InductionCell", TileEntityInductionCell::new, true, BlockStateUtils.NO_ROTATION, false, true, false),
INDUCTION_PROVIDER(BasicBlock.BASIC_BLOCK_2, 4, "InductionProvider", TileEntityInductionProvider::new, true, BlockStateUtils.NO_ROTATION, false, true, false),
SUPERHEATING_ELEMENT(BasicBlock.BASIC_BLOCK_2, 5, "SuperheatingElement", TileEntitySuperheatingElement::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
PRESSURE_DISPERSER(BasicBlock.BASIC_BLOCK_2, 6, "PressureDisperser", TileEntityPressureDisperser::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
BOILER_CASING(BasicBlock.BASIC_BLOCK_2, 7, "BoilerCasing", TileEntityBoilerCasing::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
BOILER_VALVE(BasicBlock.BASIC_BLOCK_2, 8, "BoilerValve", TileEntityBoilerValve::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
SECURITY_DESK(BasicBlock.BASIC_BLOCK_2, 9, "SecurityDesk", TileEntitySecurityDesk::new, true, Plane.HORIZONTAL, false, false, false);
@Nonnull
public BasicBlock blockType;
public int meta;
public String name;
public Class<? extends TileEntity> tileEntityClass;
public boolean isElectric;
public Supplier<TileEntity> tileEntitySupplier;
public boolean hasDescription;
public Predicate<EnumFacing> facingPredicate;
public boolean activable;
public boolean tiers;
public boolean isBeaconBase;
public boolean hasRedstoneOutput = false;
public boolean hasRedstoneOutput;
BasicBlockType(BasicBlock block, int metadata, String s, Class<? extends TileEntity> tileClass, boolean hasDesc, Predicate<EnumFacing> facingAllowed,
BasicBlockType(@Nonnull BasicBlock block, int metadata, String s, Supplier<TileEntity> tileClass, boolean hasDesc, Predicate<EnumFacing> facingAllowed,
boolean activeState, boolean t, boolean beaconBase) {
blockType = block;
meta = metadata;
name = s;
tileEntityClass = tileClass;
hasDescription = hasDesc;
facingPredicate = facingAllowed;
activable = activeState;
tiers = t;
isBeaconBase = beaconBase;
this(block, metadata, s, tileClass, hasDesc, facingAllowed, activeState, t, beaconBase, false);
}
BasicBlockType(BasicBlock block, int metadata, String s, Class<? extends TileEntity> tileClass, boolean hasDesc, Predicate<EnumFacing> facingAllowed,
BasicBlockType(@Nonnull BasicBlock block, int metadata, String s, Supplier<TileEntity> tileClass, boolean hasDesc, Predicate<EnumFacing> facingAllowed,
boolean activeState, boolean t, boolean beaconBase, boolean hasRedstoneOutput) {
blockType = block;
meta = metadata;
name = s;
tileEntityClass = tileClass;
tileEntitySupplier = tileClass;
hasDescription = hasDesc;
facingPredicate = facingAllowed;
activable = activeState;
@@ -183,12 +176,7 @@ public class BlockStateBasic extends ExtendedBlockState {
}
public TileEntity create() {
try {
return tileEntityClass.newInstance();
} catch (Exception e) {
Mekanism.logger.error("Unable to indirectly create tile entity.", e);
return null;
}
return this.tileEntitySupplier != null ? this.tileEntitySupplier.get() : null;
}
@Override
@@ -205,11 +193,11 @@ public class BlockStateBasic extends ExtendedBlockState {
}
public boolean canRotateTo(EnumFacing side) {
return facingPredicate.apply(side);
return facingPredicate.test(side);
}
public boolean hasRotations() {
return !facingPredicate.equals(Predicates.alwaysFalse());
return !facingPredicate.equals(BlockStateUtils.NO_ROTATION);
}
public boolean hasActiveTexture() {
@@ -217,20 +205,6 @@ public class BlockStateBasic extends ExtendedBlockState {
}
}
public static class BasicBlockPredicate implements Predicate<BasicBlockType> {
public BasicBlock basicBlock;
public BasicBlockPredicate(BasicBlock type) {
basicBlock = type;
}
@Override
public boolean apply(BasicBlockType input) {
return input.blockType == basicBlock;
}
}
public static class BasicBlockStateMapper extends StateMapperBase {
@Nonnull
@@ -274,7 +248,7 @@ public class BlockStateBasic extends ExtendedBlockState {
if (builder.length() == 0) {
builder.append("normal");
}
ResourceLocation baseLocation = new ResourceLocation("mekanism", nameOverride != null ? nameOverride : type.getName());
ResourceLocation baseLocation = new ResourceLocation(Mekanism.MODID, nameOverride != null ? nameOverride : type.getName());
return new ModelResourceLocation(baseLocation, builder.toString());
}
}
@@ -1,6 +1,7 @@
package mekanism.common.block.states;
import javax.annotation.Nonnull;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockCardboardBox;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
@@ -23,7 +24,7 @@ public class BlockStateCardboardBox extends BlockStateContainer {
@Override
protected ModelResourceLocation getModelResourceLocation(@Nonnull IBlockState state) {
String property = "storage=" + state.getValue(storageProperty);
ResourceLocation baseLocation = new ResourceLocation("mekanism", "CardboardBox");
ResourceLocation baseLocation = new ResourceLocation(Mekanism.MODID, "CardboardBox");
return new ModelResourceLocation(baseLocation, property);
}
}
@@ -1,11 +1,11 @@
package mekanism.common.block.states;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.function.Predicate;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks;
@@ -90,7 +90,7 @@ public class BlockStateMachine extends ExtendedBlockState {
public PropertyEnum<MachineType> getProperty() {
if (machineTypeProperty == null) {
machineTypeProperty = PropertyEnum.create("type", MachineType.class, new MachineBlockPredicate(this));
machineTypeProperty = PropertyEnum.create("type", MachineType.class, input-> input != null && input.typeBlock == this && input.isValidMachine());
}
return machineTypeProperty;
}
@@ -110,51 +110,51 @@ public class BlockStateMachine extends ExtendedBlockState {
}
public enum MachineType implements IStringSerializable, IBlockType {
ENRICHMENT_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 0, "EnrichmentChamber", 3, TileEntityEnrichmentChamber.class, true, false, true, Plane.HORIZONTAL, true),
OSMIUM_COMPRESSOR(MachineBlock.MACHINE_BLOCK_1, 1, "OsmiumCompressor", 4, TileEntityOsmiumCompressor.class, true, false, true, Plane.HORIZONTAL, true),
COMBINER(MachineBlock.MACHINE_BLOCK_1, 2, "Combiner", 5, TileEntityCombiner.class, true, false, true, Plane.HORIZONTAL, true),
CRUSHER(MachineBlock.MACHINE_BLOCK_1, 3, "Crusher", 6, TileEntityCrusher.class, true, false, true, Plane.HORIZONTAL, true),
DIGITAL_MINER(MachineBlock.MACHINE_BLOCK_1, 4, "DigitalMiner", 2, TileEntityDigitalMiner.class, true, true, true, Plane.HORIZONTAL, true),
BASIC_FACTORY(MachineBlock.MACHINE_BLOCK_1, 5, "Factory", 11, TileEntityFactory.class, true, false, true, Plane.HORIZONTAL, true, FactoryTier.BASIC),
ADVANCED_FACTORY(MachineBlock.MACHINE_BLOCK_1, 6, "Factory", 11, TileEntityAdvancedFactory.class, true, false, true, Plane.HORIZONTAL, true, FactoryTier.ADVANCED),
ELITE_FACTORY(MachineBlock.MACHINE_BLOCK_1, 7, "Factory", 11, TileEntityEliteFactory.class, true, false, true, Plane.HORIZONTAL, true, FactoryTier.ELITE),
METALLURGIC_INFUSER(MachineBlock.MACHINE_BLOCK_1, 8, "MetallurgicInfuser", 12, TileEntityMetallurgicInfuser.class, true, true, true, Plane.HORIZONTAL, false),
PURIFICATION_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 9, "PurificationChamber", 15, TileEntityPurificationChamber.class, true, false, true, Plane.HORIZONTAL, true),
ENERGIZED_SMELTER(MachineBlock.MACHINE_BLOCK_1, 10, "EnergizedSmelter", 16, TileEntityEnergizedSmelter.class, true, false, true, Plane.HORIZONTAL, true),
TELEPORTER(MachineBlock.MACHINE_BLOCK_1, 11, "Teleporter", 13, TileEntityTeleporter.class, true, false, false, Predicates.alwaysFalse(), false),
ELECTRIC_PUMP(MachineBlock.MACHINE_BLOCK_1, 12, "ElectricPump", 17, TileEntityElectricPump.class, true, true, false, Plane.HORIZONTAL, false),
PERSONAL_CHEST(MachineBlock.MACHINE_BLOCK_1, 13, "PersonalChest", -1, TileEntityPersonalChest.class, true, true, false, Plane.HORIZONTAL, false),
CHARGEPAD(MachineBlock.MACHINE_BLOCK_1, 14, "Chargepad", -1, TileEntityChargepad.class, true, true, false, Plane.HORIZONTAL, false),
LOGISTICAL_SORTER(MachineBlock.MACHINE_BLOCK_1, 15, "LogisticalSorter", 59, TileEntityLogisticalSorter.class, false, true, false, Predicates.alwaysTrue(), true),
ROTARY_CONDENSENTRATOR(MachineBlock.MACHINE_BLOCK_2, 0, "RotaryCondensentrator", 7, TileEntityRotaryCondensentrator.class, true, true, false, Plane.HORIZONTAL, false),
CHEMICAL_OXIDIZER(MachineBlock.MACHINE_BLOCK_2, 1, "ChemicalOxidizer", 29, TileEntityChemicalOxidizer.class, true, true, true, Plane.HORIZONTAL, true),
CHEMICAL_INFUSER(MachineBlock.MACHINE_BLOCK_2, 2, "ChemicalInfuser", 30, TileEntityChemicalInfuser.class, true, true, false, Plane.HORIZONTAL, true),
CHEMICAL_INJECTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 3, "ChemicalInjectionChamber", 31, TileEntityChemicalInjectionChamber.class, true, false, true, Plane.HORIZONTAL, true),
ELECTROLYTIC_SEPARATOR(MachineBlock.MACHINE_BLOCK_2, 4, "ElectrolyticSeparator", 32, TileEntityElectrolyticSeparator.class, true, true, false, Plane.HORIZONTAL, true),
PRECISION_SAWMILL(MachineBlock.MACHINE_BLOCK_2, 5, "PrecisionSawmill", 34, TileEntityPrecisionSawmill.class, true, false, true, Plane.HORIZONTAL, true),
CHEMICAL_DISSOLUTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 6, "ChemicalDissolutionChamber", 35, TileEntityChemicalDissolutionChamber.class, true, true, true, Plane.HORIZONTAL, true),
CHEMICAL_WASHER(MachineBlock.MACHINE_BLOCK_2, 7, "ChemicalWasher", 36, TileEntityChemicalWasher.class, true, true, false, Plane.HORIZONTAL, true),
CHEMICAL_CRYSTALLIZER(MachineBlock.MACHINE_BLOCK_2, 8, "ChemicalCrystallizer", 37, TileEntityChemicalCrystallizer.class, true, true, true, Plane.HORIZONTAL, true),
SEISMIC_VIBRATOR(MachineBlock.MACHINE_BLOCK_2, 9, "SeismicVibrator", 39, TileEntitySeismicVibrator.class, true, true, false, Plane.HORIZONTAL, true),
PRESSURIZED_REACTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 10, "PressurizedReactionChamber", 40, TileEntityPRC.class, true, true, false, Plane.HORIZONTAL, true),
FLUID_TANK(MachineBlock.MACHINE_BLOCK_2, 11, "FluidTank", 41, TileEntityFluidTank.class, false, true, false, Predicates.alwaysFalse(), true),
FLUIDIC_PLENISHER(MachineBlock.MACHINE_BLOCK_2, 12, "FluidicPlenisher", 42, TileEntityFluidicPlenisher.class, true, true, false, Plane.HORIZONTAL, true),
LASER(MachineBlock.MACHINE_BLOCK_2, 13, "Laser", -1, TileEntityLaser.class, true, true, false, Predicates.alwaysTrue(), false),
LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, TileEntityLaserAmplifier.class, false, true, false, Predicates.alwaysTrue(), true),
LASER_TRACTOR_BEAM(MachineBlock.MACHINE_BLOCK_2, 15, "LaserTractorBeam", 45, TileEntityLaserTractorBeam.class, false, true, false, Predicates.alwaysTrue(), true),
QUANTUM_ENTANGLOPORTER(MachineBlock.MACHINE_BLOCK_3, 0, "QuantumEntangloporter", 46, TileEntityQuantumEntangloporter.class, true, false, false, Predicates.alwaysTrue(), false),
SOLAR_NEUTRON_ACTIVATOR(MachineBlock.MACHINE_BLOCK_3, 1, "SolarNeutronActivator", 47, TileEntitySolarNeutronActivator.class, false, true, false, Plane.HORIZONTAL, true),
AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 48, TileEntityAmbientAccumulator.class, true, false, false, Predicates.alwaysFalse(), true),
OREDICTIONIFICATOR(MachineBlock.MACHINE_BLOCK_3, 3, "Oredictionificator", 52, TileEntityOredictionificator.class, false, false, false, Plane.HORIZONTAL, true),
RESISTIVE_HEATER(MachineBlock.MACHINE_BLOCK_3, 4, "ResistiveHeater", 53, TileEntityResistiveHeater.class, true, false, false, Plane.HORIZONTAL, true),
FORMULAIC_ASSEMBLICATOR(MachineBlock.MACHINE_BLOCK_3, 5, "FormulaicAssemblicator", 56, TileEntityFormulaicAssemblicator.class, true, false, true, Plane.HORIZONTAL, true),
FUELWOOD_HEATER(MachineBlock.MACHINE_BLOCK_3, 6, "FuelwoodHeater", 58, TileEntityFuelwoodHeater.class, false, false, false, Plane.HORIZONTAL, true);
ENRICHMENT_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 0, "EnrichmentChamber", 3, TileEntityEnrichmentChamber::new, true, false, true, Plane.HORIZONTAL, true),
OSMIUM_COMPRESSOR(MachineBlock.MACHINE_BLOCK_1, 1, "OsmiumCompressor", 4, TileEntityOsmiumCompressor::new, true, false, true, Plane.HORIZONTAL, true),
COMBINER(MachineBlock.MACHINE_BLOCK_1, 2, "Combiner", 5, TileEntityCombiner::new, true, false, true, Plane.HORIZONTAL, true),
CRUSHER(MachineBlock.MACHINE_BLOCK_1, 3, "Crusher", 6, TileEntityCrusher::new, true, false, true, Plane.HORIZONTAL, true),
DIGITAL_MINER(MachineBlock.MACHINE_BLOCK_1, 4, "DigitalMiner", 2, TileEntityDigitalMiner::new, true, true, true, Plane.HORIZONTAL, true),
BASIC_FACTORY(MachineBlock.MACHINE_BLOCK_1, 5, "Factory", 11, TileEntityFactory::new, true, false, true, Plane.HORIZONTAL, true, FactoryTier.BASIC),
ADVANCED_FACTORY(MachineBlock.MACHINE_BLOCK_1, 6, "Factory", 11, TileEntityAdvancedFactory::new, true, false, true, Plane.HORIZONTAL, true, FactoryTier.ADVANCED),
ELITE_FACTORY(MachineBlock.MACHINE_BLOCK_1, 7, "Factory", 11, TileEntityEliteFactory::new, true, false, true, Plane.HORIZONTAL, true, FactoryTier.ELITE),
METALLURGIC_INFUSER(MachineBlock.MACHINE_BLOCK_1, 8, "MetallurgicInfuser", 12, TileEntityMetallurgicInfuser::new, true, true, true, Plane.HORIZONTAL, false),
PURIFICATION_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 9, "PurificationChamber", 15, TileEntityPurificationChamber::new, true, false, true, Plane.HORIZONTAL, true),
ENERGIZED_SMELTER(MachineBlock.MACHINE_BLOCK_1, 10, "EnergizedSmelter", 16, TileEntityEnergizedSmelter::new, true, false, true, Plane.HORIZONTAL, true),
TELEPORTER(MachineBlock.MACHINE_BLOCK_1, 11, "Teleporter", 13, TileEntityTeleporter::new, true, false, false, BlockStateUtils.NO_ROTATION, false),
ELECTRIC_PUMP(MachineBlock.MACHINE_BLOCK_1, 12, "ElectricPump", 17, TileEntityElectricPump::new, true, true, false, Plane.HORIZONTAL, false),
PERSONAL_CHEST(MachineBlock.MACHINE_BLOCK_1, 13, "PersonalChest", -1, TileEntityPersonalChest::new, true, true, false, Plane.HORIZONTAL, false),
CHARGEPAD(MachineBlock.MACHINE_BLOCK_1, 14, "Chargepad", -1, TileEntityChargepad::new, true, true, false, Plane.HORIZONTAL, false),
LOGISTICAL_SORTER(MachineBlock.MACHINE_BLOCK_1, 15, "LogisticalSorter", 59, TileEntityLogisticalSorter::new, false, true, false, BlockStateUtils.ALL_FACINGS, true),
ROTARY_CONDENSENTRATOR(MachineBlock.MACHINE_BLOCK_2, 0, "RotaryCondensentrator", 7, TileEntityRotaryCondensentrator::new, true, true, false, Plane.HORIZONTAL, false),
CHEMICAL_OXIDIZER(MachineBlock.MACHINE_BLOCK_2, 1, "ChemicalOxidizer", 29, TileEntityChemicalOxidizer::new, true, true, true, Plane.HORIZONTAL, true),
CHEMICAL_INFUSER(MachineBlock.MACHINE_BLOCK_2, 2, "ChemicalInfuser", 30, TileEntityChemicalInfuser::new, true, true, false, Plane.HORIZONTAL, true),
CHEMICAL_INJECTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 3, "ChemicalInjectionChamber", 31, TileEntityChemicalInjectionChamber::new, true, false, true, Plane.HORIZONTAL, true),
ELECTROLYTIC_SEPARATOR(MachineBlock.MACHINE_BLOCK_2, 4, "ElectrolyticSeparator", 32, TileEntityElectrolyticSeparator::new, true, true, false, Plane.HORIZONTAL, true),
PRECISION_SAWMILL(MachineBlock.MACHINE_BLOCK_2, 5, "PrecisionSawmill", 34, TileEntityPrecisionSawmill::new, true, false, true, Plane.HORIZONTAL, true),
CHEMICAL_DISSOLUTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 6, "ChemicalDissolutionChamber", 35, TileEntityChemicalDissolutionChamber::new, true, true, true, Plane.HORIZONTAL, true),
CHEMICAL_WASHER(MachineBlock.MACHINE_BLOCK_2, 7, "ChemicalWasher", 36, TileEntityChemicalWasher::new, true, true, false, Plane.HORIZONTAL, true),
CHEMICAL_CRYSTALLIZER(MachineBlock.MACHINE_BLOCK_2, 8, "ChemicalCrystallizer", 37, TileEntityChemicalCrystallizer::new, true, true, true, Plane.HORIZONTAL, true),
SEISMIC_VIBRATOR(MachineBlock.MACHINE_BLOCK_2, 9, "SeismicVibrator", 39, TileEntitySeismicVibrator::new, true, true, false, Plane.HORIZONTAL, true),
PRESSURIZED_REACTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 10, "PressurizedReactionChamber", 40, TileEntityPRC::new, true, true, false, Plane.HORIZONTAL, true),
FLUID_TANK(MachineBlock.MACHINE_BLOCK_2, 11, "FluidTank", 41, TileEntityFluidTank::new, false, true, false, BlockStateUtils.NO_ROTATION, true),
FLUIDIC_PLENISHER(MachineBlock.MACHINE_BLOCK_2, 12, "FluidicPlenisher", 42, TileEntityFluidicPlenisher::new, true, true, false, Plane.HORIZONTAL, true),
LASER(MachineBlock.MACHINE_BLOCK_2, 13, "Laser", -1, TileEntityLaser::new, true, true, false, BlockStateUtils.ALL_FACINGS, false),
LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, TileEntityLaserAmplifier::new, false, true, false, BlockStateUtils.ALL_FACINGS, true),
LASER_TRACTOR_BEAM(MachineBlock.MACHINE_BLOCK_2, 15, "LaserTractorBeam", 45, TileEntityLaserTractorBeam::new, false, true, false, BlockStateUtils.ALL_FACINGS, true),
QUANTUM_ENTANGLOPORTER(MachineBlock.MACHINE_BLOCK_3, 0, "QuantumEntangloporter", 46, TileEntityQuantumEntangloporter::new, true, false, false, BlockStateUtils.ALL_FACINGS, false),
SOLAR_NEUTRON_ACTIVATOR(MachineBlock.MACHINE_BLOCK_3, 1, "SolarNeutronActivator", 47, TileEntitySolarNeutronActivator::new, false, true, false, Plane.HORIZONTAL, true),
AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 48, TileEntityAmbientAccumulator::new, true, false, false, BlockStateUtils.NO_ROTATION, true),
OREDICTIONIFICATOR(MachineBlock.MACHINE_BLOCK_3, 3, "Oredictionificator", 52, TileEntityOredictionificator::new, false, false, false, Plane.HORIZONTAL, true),
RESISTIVE_HEATER(MachineBlock.MACHINE_BLOCK_3, 4, "ResistiveHeater", 53, TileEntityResistiveHeater::new, true, false, false, Plane.HORIZONTAL, true),
FORMULAIC_ASSEMBLICATOR(MachineBlock.MACHINE_BLOCK_3, 5, "FormulaicAssemblicator", 56, TileEntityFormulaicAssemblicator::new, true, false, true, Plane.HORIZONTAL, true),
FUELWOOD_HEATER(MachineBlock.MACHINE_BLOCK_3, 6, "FuelwoodHeater", 58, TileEntityFuelwoodHeater::new, false, false, false, Plane.HORIZONTAL, true);
public MachineBlock typeBlock;
public int meta;
public String blockName;
public int guiId;
public Class<? extends TileEntity> tileEntityClass;
public Supplier<TileEntity> tileEntitySupplier;
public boolean isElectric;
public boolean hasModel;
public boolean supportsUpgrades;
@@ -162,18 +162,18 @@ public class BlockStateMachine extends ExtendedBlockState {
public boolean activable;
public FactoryTier factoryTier;
MachineType(MachineBlock block, int i, String s, int j, Class<? extends TileEntity> tileClass, boolean electric, boolean model, boolean upgrades,
MachineType(MachineBlock block, int i, String s, int j, Supplier<TileEntity> tileClass, boolean electric, boolean model, boolean upgrades,
Predicate<EnumFacing> predicate, boolean hasActiveTexture) {
this(block, i, s, j, tileClass, electric, model, upgrades, predicate, hasActiveTexture, null);
}
MachineType(MachineBlock block, int i, String s, int j, Class<? extends TileEntity> tileClass, boolean electric, boolean model, boolean upgrades,
MachineType(MachineBlock block, int i, String s, int j, Supplier<TileEntity> tileClass, boolean electric, boolean model, boolean upgrades,
Predicate<EnumFacing> predicate, boolean hasActiveTexture, FactoryTier factoryTier) {
typeBlock = block;
meta = i;
blockName = s;
guiId = j;
tileEntityClass = tileClass;
tileEntitySupplier = tileClass;
isElectric = electric;
hasModel = model;
supportsUpgrades = upgrades;
@@ -228,12 +228,7 @@ public class BlockStateMachine extends ExtendedBlockState {
}
public TileEntity create() {
try {
return tileEntityClass.newInstance();
} catch (Exception e) {
Mekanism.logger.error("Unable to indirectly create tile entity.", e);
return null;
}
return this.tileEntitySupplier != null ? this.tileEntitySupplier.get() : null;
}
public double getUsage() {
@@ -391,11 +386,11 @@ public class BlockStateMachine extends ExtendedBlockState {
}
public boolean canRotateTo(EnumFacing side) {
return facingPredicate.apply(side);
return facingPredicate.test(side);
}
public boolean hasRotations() {
return !facingPredicate.equals(Predicates.alwaysFalse());
return !facingPredicate.equals(BlockStateUtils.NO_ROTATION);
}
public boolean hasActiveTexture() {
@@ -407,20 +402,6 @@ public class BlockStateMachine extends ExtendedBlockState {
}
}
public static class MachineBlockPredicate implements Predicate<MachineType> {
public MachineBlock machineBlock;
public MachineBlockPredicate(MachineBlock type) {
machineBlock = type;
}
@Override
public boolean apply(MachineType input) {
return input.typeBlock == machineBlock && input.isValidMachine();
}
}
public static class MachineBlockStateMapper extends StateMapperBase {
@Nonnull
@@ -458,7 +439,7 @@ public class BlockStateMachine extends ExtendedBlockState {
if (builder.length() == 0) {
builder.append("normal");
}
ResourceLocation baseLocation = new ResourceLocation("mekanism", nameOverride != null ? nameOverride : type.getName());
ResourceLocation baseLocation = new ResourceLocation(Mekanism.MODID, nameOverride != null ? nameOverride : type.getName());
return new ModelResourceLocation(baseLocation, builder.toString());
}
}
@@ -2,6 +2,7 @@ package mekanism.common.block.states;
import java.util.Locale;
import javax.annotation.Nonnull;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockPlastic;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
@@ -40,7 +41,7 @@ public class BlockStatePlastic extends BlockStateContainer {
protected ModelResourceLocation getModelResourceLocation(@Nonnull IBlockState state) {
PlasticBlockType type = ((BlockPlastic) state.getBlock()).type;
String property = "type=" + type.getName();
ResourceLocation baseLocation = new ResourceLocation("mekanism", "plastic_block");
ResourceLocation baseLocation = new ResourceLocation(Mekanism.MODID, "plastic_block");
return new ModelResourceLocation(baseLocation, property);
}
}
@@ -3,6 +3,7 @@ package mekanism.common.block.states;
import java.util.Locale;
import javax.annotation.Nonnull;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockTransmitter;
import mekanism.common.block.property.PropertyColor;
import mekanism.common.block.property.PropertyConnection;
@@ -111,7 +112,7 @@ public class BlockStateTransmitter extends ExtendedBlockState {
if (builder.length() == 0) {
builder.append("normal");
}
ResourceLocation baseLocation = new ResourceLocation("mekanism", nameOverride != null ? nameOverride : type.getName());
ResourceLocation baseLocation = new ResourceLocation(Mekanism.MODID, nameOverride != null ? nameOverride : type.getName());
return new ModelResourceLocation(baseLocation, builder.toString());
}
}
@@ -0,0 +1,12 @@
package mekanism.common.block.states;
import java.util.function.Predicate;
import net.minecraft.util.EnumFacing;
/**
* Created by Thiakil on 18/04/2019.
*/
public class BlockStateUtils {
public static final Predicate<EnumFacing> ALL_FACINGS = enumFacing -> true;
public static final Predicate<EnumFacing> NO_ROTATION = enumFacing -> false;
}
@@ -22,8 +22,8 @@ public class CapabilityWrapperManager<IMPL, WRAPPER> {
WRAPPER wrapper = wrapperClass.getConstructor(typeClass, EnumFacing.class).newInstance(impl, facing);
wrappers.put(facing, wrapper);
}
} catch (Exception e) {
e.printStackTrace();
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
return wrappers.get(facing);
@@ -12,7 +12,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.IItemHandler;
/**
* An InvStack attaches to an inventory and tracks a specific homogenous item in a variable amount of slots. An InvStack can either track the entirety of these slots or
* An InvStack attaches to an inventory and tracks a specific homogeneous item in a variable amount of slots. An InvStack can either track the entirety of these slots or
* portions of their contents. Utility methods in this class allow for the strategic removal of clustered items from inventories.
*
* @author aidancbrady
@@ -11,6 +11,7 @@ import java.util.UUID;
import javax.annotation.Nonnull;
import mekanism.api.Coord4D;
import mekanism.api.TileNetworkList;
import mekanism.common.Mekanism;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
@@ -202,8 +203,8 @@ public class FrequencyManager {
freq.read(dataStream);
ret.add(freq);
}
} catch (Exception e) {
e.printStackTrace();
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
return ret;
}
@@ -237,7 +238,7 @@ public class FrequencyManager {
@Override
public void readFromNBT(@Nonnull NBTTagCompound nbtTags) {
try {
String frequencyClass = nbtTags.getString("frequencyClass");
String frequencyClass = nbtTags.getString("frequencyClass");//todo fix this using a classname from nbt!
if (nbtTags.hasKey("ownerUUID")) {
loadedOwner = UUID.fromString(nbtTags.getString("ownerUUID"));
}
@@ -249,8 +250,8 @@ public class FrequencyManager {
Frequency freq = (Frequency) c.newInstance(compound);
loadedFrequencies.add(freq);
}
} catch (Exception e) {
e.printStackTrace();
} catch (ReflectiveOperationException e) {
Mekanism.logger.error("Couldn't load frequency data", e);
}
}
@@ -75,7 +75,7 @@ public class WailaDataProvider implements IWailaDataProvider {
} else if (tile instanceof TileEntityBoundingBlock) {
TileEntityBoundingBlock bound = (TileEntityBoundingBlock) tile;
Coord4D coord = new Coord4D(bound.getPos(), tile.getWorld());
//TODO: Switch to IItemHandler though there is no good way to get the name of an IItemHandler
//TODO: Switch to a smarter way to get the main tile's name - i.e. block name
if (bound.receivedCoords && coord.getTileEntity(tile.getWorld()) instanceof IInventory) {
currenttip.set(0, EnumColor.WHITE + ((IInventory) coord.getTileEntity(tile.getWorld())).getName());
}
@@ -45,9 +45,6 @@ public class CCPeripheral implements IPeripheral {
return computerTile.invoke(method, arguments);
} catch (NoSuchMethodException e) {
return new Object[]{"Unknown command."};
} catch (Exception e) {
e.printStackTrace();
return new Object[]{"Error."};
}
}
@@ -9,5 +9,5 @@ public interface IComputerIntegration extends IInventory {
String[] getMethods();
Object[] invoke(int method, Object[] args) throws Exception;
Object[] invoke(int method, Object[] args) throws NoSuchMethodException;
}
@@ -22,6 +22,7 @@ import mcmultipart.api.ref.MCMPCapabilities;
import mcmultipart.api.slot.EnumCenterSlot;
import mcmultipart.api.world.IMultipartBlockAccess;
import mcmultipart.multipart.MultipartRegistry;
import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks;
import mekanism.common.block.BlockTransmitter;
import mekanism.common.block.states.BlockStateMachine.MachineType;
@@ -145,7 +146,7 @@ public class MultipartMekanism implements IMCMPAddon {
}
private void register(AttachCapabilitiesEvent<TileEntity> e, String id) {
e.addCapability(new ResourceLocation("mekanism:" + id), new ICapabilityProvider() {
e.addCapability(new ResourceLocation(Mekanism.MODID, id), new ICapabilityProvider() {
private MultipartTile tile;
@Override
@@ -11,7 +11,6 @@ public abstract class ContainerMekanism<TILE extends TileEntityContainerBlock> e
protected TILE tileEntity;
//TODO: Change InventoryPlayer to IInventory?
protected ContainerMekanism(TILE tile, InventoryPlayer inventory) {
this.tileEntity = tile;
if (shouldAddSlots()) {
@@ -121,18 +121,16 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
if (tileEntity.tier == EnergyCubeTier.CREATIVE) {
tileEntity.configComponent.fillConfig(TransmissionType.ENERGY, tileEntity.getEnergy() > 0 ? 2 : 1);
}
ISecurityTile security = tileEntity;
security.getSecurity().setOwnerUUID(getOwnerUUID(stack));
((ISecurityTile) tileEntity).getSecurity().setOwnerUUID(getOwnerUUID(stack));
if (hasSecurity(stack)) {
security.getSecurity().setMode(getSecurity(stack));
((ISecurityTile) tileEntity).getSecurity().setMode(getSecurity(stack));
}
if (getOwnerUUID(stack) == null) {
security.getSecurity().setOwnerUUID(player.getUniqueID());
((ISecurityTile) tileEntity).getSecurity().setOwnerUUID(player.getUniqueID());
}
ISideConfiguration config = tileEntity;
if (ItemDataUtils.hasData(stack, "sideDataStored")) {
config.getConfig().read(ItemDataUtils.getDataMap(stack));
config.getEjector().read(ItemDataUtils.getDataMap(stack));
((ISideConfiguration) tileEntity).getConfig().read(ItemDataUtils.getDataMap(stack));
((ISideConfiguration) tileEntity).getEjector().read(ItemDataUtils.getDataMap(stack));
}
((ISustainedInventory) tileEntity).setInventory(getInventory(stack));
if (!world.isRemote) {
@@ -88,20 +88,18 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
tileEntity.tier = GasTankTier.values()[getBaseTier(stack).ordinal()];
tileEntity.gasTank.setMaxGas(tileEntity.tier.getStorage());
tileEntity.gasTank.setGas(getGas(stack));
ISecurityTile security = tileEntity;
security.getSecurity().setOwnerUUID(getOwnerUUID(stack));
((ISecurityTile) tileEntity).getSecurity().setOwnerUUID(getOwnerUUID(stack));
if (hasSecurity(stack)) {
security.getSecurity().setMode(getSecurity(stack));
((ISecurityTile) tileEntity).getSecurity().setMode(getSecurity(stack));
}
if (getOwnerUUID(stack) == null) {
security.getSecurity().setOwnerUUID(player.getUniqueID());
((ISecurityTile) tileEntity).getSecurity().setOwnerUUID(player.getUniqueID());
}
ISideConfiguration config = tileEntity;
if (ItemDataUtils.hasData(stack, "sideDataStored")) {
config.getConfig().read(ItemDataUtils.getDataMap(stack));
config.getEjector().read(ItemDataUtils.getDataMap(stack));
((ISideConfiguration) tileEntity).getConfig().read(ItemDataUtils.getDataMap(stack));
((ISideConfiguration) tileEntity).getEjector().read(ItemDataUtils.getDataMap(stack));
}
((ISustainedInventory) tileEntity).setInventory(getInventory(stack));
@@ -133,9 +133,7 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool
} else if (getState(stack) == ConfiguratorMode.EMPTY) { //Empty
if (tile instanceof TileEntityContainerBlock) {
if (SecurityUtils.canAccess(player, tile)) {
//TODO: Switch this to an IItemHandler
// It isn't a simple switch to IItemHandlerModifiable as then it makes the empty mode only work
// when it is done on a side configured to work as an IItemHandler.
//TODO: Switch this to items being handled by TECB, energy handled here (via lambdas?)
IInventory inv = (IInventory) tile;
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack slotStack = inv.getStackInSlot(i);
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import mekanism.api.EnumColor;
import mekanism.common.Mekanism;
import mekanism.common.util.InventoryUtils;
import mekanism.common.util.ItemDataUtils;
import mekanism.common.util.LangUtils;
@@ -18,15 +19,16 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemCraftingFormula extends ItemMekanism {
public static ModelResourceLocation MODEL = new ModelResourceLocation("mekanism:CraftingFormula", "inventory");
public static ModelResourceLocation INVALID_MODEL = new ModelResourceLocation("mekanism:CraftingFormulaInvalid", "inventory");
public static ModelResourceLocation ENCODED_MODEL = new ModelResourceLocation("mekanism:CraftingFormulaEncoded", "inventory");
public static ModelResourceLocation MODEL = new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "CraftingFormula"), "inventory");
public static ModelResourceLocation INVALID_MODEL = new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "CraftingFormulaInvalid"), "inventory");
public static ModelResourceLocation ENCODED_MODEL = new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "CraftingFormulaEncoded"), "inventory");
@Override
@SideOnly(Side.CLIENT)
@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import mekanism.api.EnumColor;
import mekanism.common.Mekanism;
import mekanism.common.base.IItemNetwork;
import mekanism.common.config.MekanismConfig;
import mekanism.common.util.ItemDataUtils;
@@ -17,6 +18,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
@@ -24,7 +26,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemWalkieTalkie extends ItemMekanism implements IItemNetwork {
public static ModelResourceLocation OFF_MODEL = new ModelResourceLocation("mekanism:WalkieTalkie", "inventory");
public static ModelResourceLocation OFF_MODEL = new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "WalkieTalkie"), "inventory");
public static Map<Integer, ModelResourceLocation> CHANNEL_MODELS = new HashMap<>();
@@ -34,7 +36,7 @@ public class ItemWalkieTalkie extends ItemMekanism implements IItemNetwork {
}
public static ModelResourceLocation getModel(int channel) {
CHANNEL_MODELS.computeIfAbsent(channel, c -> new ModelResourceLocation("mekanism:WalkieTalkie_ch" + c, "inventory"));
CHANNEL_MODELS.computeIfAbsent(channel, c -> new ModelResourceLocation(new ResourceLocation(Mekanism.MODID, "WalkieTalkie_ch" + c), "inventory"));
return CHANNEL_MODELS.get(channel);
}
@@ -40,7 +40,6 @@ public class PacketDigitalMinerGui implements IMessageHandler<DigitalMinerGuiMes
PacketHandler.handlePacket(() -> {
if (!player.world.isRemote) {
World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.coord4D.dimensionId);
if (message.coord4D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) {
DigitalMinerGuiMessage.openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP) player, message.coord4D, message.index);
}
@@ -55,7 +54,7 @@ public class PacketDigitalMinerGui implements IMessageHandler<DigitalMinerGuiMes
}
player.openContainer.windowId = message.windowId;
} catch (Exception e) {
e.printStackTrace();
Mekanism.logger.error("FIXME: Packet handling error", e);
}
}
}, player);
@@ -2,6 +2,7 @@ package mekanism.common.network;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.common.Mekanism;
import mekanism.common.PacketHandler;
import mekanism.common.base.ITankManager;
import mekanism.common.base.ITankManager.DropperHandler;
@@ -26,7 +27,7 @@ public class PacketDropperUse implements IMessageHandler<DropperUseMessage, IMes
DropperHandler.useDropper(player, tank, message.mouseButton);
}
} catch (Exception e) {
e.printStackTrace();
Mekanism.logger.error("FIXME: Packet handling error", e);
}
}
}, player);
@@ -24,6 +24,7 @@ public class PacketFlamethrowerData implements IMessageHandler<FlamethrowerDataM
Mekanism.playerState.setFlamethrowerState(message.uuid, message.value, false);
// If we got this packet on the server, resend out to all clients in same dimension
// TODO: Why is this a dimensional thing?!
// because we dont send a packet when a player starts tracking another player (net.minecraftforge.event.entity.player.PlayerEvent.StartTracking)
if (!player.world.isRemote) {
Mekanism.packetHandler.sendToDimension(message, player.world.provider.getDimension());
}
@@ -2,6 +2,7 @@ package mekanism.common.network;
import io.netty.buffer.ByteBuf;
import java.util.List;
import mekanism.common.Mekanism;
import mekanism.common.PacketHandler;
import mekanism.common.base.IItemNetwork;
import mekanism.common.network.PacketItemStack.ItemStackMessage;
@@ -29,7 +30,7 @@ public class PacketItemStack implements IMessageHandler<ItemStackMessage, IMessa
try {
network.handlePacketData(stack, message.storedBuffer);
} catch (Exception e) {
e.printStackTrace();
Mekanism.logger.error("FIXME: Packet handling error", e);
}
message.storedBuffer.release();
}
@@ -28,6 +28,7 @@ public class PacketJetpackData implements IMessageHandler<JetpackDataMessage, IM
// If we got this packet on the server, propagate it out to all players in the same
// dimension
// TODO: Why is this a dimensional thing?!
// because we dont send a packet when a player starts tracking another player (net.minecraftforge.event.entity.player.PlayerEvent.StartTracking)
if (!player.world.isRemote) {
Mekanism.packetHandler.sendToDimension(message, player.world.provider.getDimension());
}
@@ -36,7 +36,6 @@ public class PacketLogisticalSorterGui implements IMessageHandler<LogisticalSort
PacketHandler.handlePacket(() -> {
if (!player.world.isRemote) {
World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.coord4D.dimensionId);
if (message.coord4D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter) {
LogisticalSorterGuiMessage.openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP) player, message.coord4D, message.index);
}
@@ -51,7 +50,7 @@ public class PacketLogisticalSorterGui implements IMessageHandler<LogisticalSort
}
player.openContainer.windowId = message.windowId;
} catch (Exception e) {
e.printStackTrace();
Mekanism.logger.error("FIXME: Packet handling error", e);
}
}
}, player);
@@ -34,7 +34,6 @@ public class PacketOredictionificatorGui implements IMessageHandler<Oredictionif
PacketHandler.handlePacket(() -> {
if (!player.world.isRemote) {
World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.coord4D.dimensionId);
if (message.coord4D.getTileEntity(worldServer) instanceof TileEntityOredictionificator) {
OredictionificatorGuiMessage.openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP) player, message.coord4D, message.index);
}
@@ -49,7 +48,7 @@ public class PacketOredictionificatorGui implements IMessageHandler<Oredictionif
}
player.openContainer.windowId = message.windowId;
} catch (Exception e) {
e.printStackTrace();
Mekanism.logger.error("FIXME: Packet handling error", e);
}
}
}, player);
@@ -26,6 +26,7 @@ public class PacketScubaTankData implements IMessageHandler<ScubaTankDataMessage
Mekanism.playerState.setGasmaskState(message.uuid, message.value, false);
// If we got this on the server, relay out to all players in the same dimension
// TODO: Why is this a dimensional thing?!
// because we dont send a packet when a player starts tracking another player (net.minecraftforge.event.entity.player.PlayerEvent.StartTracking)
if (!player.world.isRemote) {
Mekanism.packetHandler.sendToDimension(message, player.world.provider.getDimension());
}
@@ -2,6 +2,7 @@ package mekanism.common.network;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.common.Mekanism;
import mekanism.api.TileNetworkList;
import mekanism.common.PacketHandler;
import mekanism.common.base.ITileNetwork;
@@ -32,7 +33,7 @@ public class PacketTileEntity implements IMessageHandler<TileEntityMessage, IMes
try {
network.handlePacketData(message.storedBuffer);
} catch (Exception e) {
e.printStackTrace();
Mekanism.logger.error("FIXME: Packet handling error", e);
}
message.storedBuffer.release();
}
@@ -630,8 +630,7 @@ public final class RecipeHandler {
values = ImmutableList.copyOf(values);
}
//TODO: Replace this with Recipe being Iterable
public static List<Recipe> values() {
public static Iterable<Recipe> values() {
return values;
}
@@ -79,7 +79,7 @@ public class ShapedMekanismRecipe extends ShapedOreRecipe {
return null;
}
}
return new ShapedMekanismRecipe(null, result, ret); //TODO Find out correct value for group
return new ShapedMekanismRecipe(null, result, ret);
}
// Copy of net.minecraftforge.oredict.ShapedOreRecipe
@@ -67,7 +67,7 @@ public class ShapelessMekanismRecipe extends ShapelessOreRecipe {
return null;
}
}
return new ShapelessMekanismRecipe(null, result, ret); //TODO Find out correct value for group
return new ShapelessMekanismRecipe(null, result, ret);
}
// Copy of net.minecraftforge.oredict.ShapelessOreRecipe
@@ -358,7 +358,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
IAdvancedBoundingBlock inv = getInv();
if (inv == null) {
return new Object[]{};
@@ -121,7 +121,7 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
if (method == 0) {
return new Object[]{structure != null};
} else {
@@ -136,7 +136,7 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{getEnergy()};
@@ -917,7 +917,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
}
@Override
public Object[] invoke(int method, Object[] arguments) {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
if (method == 0) {
if (arguments.length != 1 || !(arguments[0] instanceof Double)) {
return new Object[]{"Invalid parameters."};
@@ -455,7 +455,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
if (method == 0) {
reset();
return new Object[]{"Pump calculation reset."};
@@ -308,7 +308,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{electricityStored};
@@ -176,7 +176,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{getEnergy()};
@@ -2,6 +2,7 @@ package mekanism.common.tile;
import io.netty.buffer.ByteBuf;
import java.util.Arrays;
import java.util.Objects;
import javax.annotation.Nonnull;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
@@ -93,22 +94,22 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
/**
* How much secondary energy each operation consumes per tick
*/
public double secondaryEnergyPerTick = 0;
public int secondaryEnergyThisTick;
private double secondaryEnergyPerTick = 0;
private int secondaryEnergyThisTick;
/**
* How long it takes this factory to switch recipe types.
*/
public int RECIPE_TICKS_REQUIRED = 40;
private static int RECIPE_TICKS_REQUIRED = 40;
/**
* How many recipe ticks have progressed.
*/
public int recipeTicks;
private int recipeTicks;
/**
* The amount of infuse this machine has stored.
*/
public InfuseStorage infuseStored = new InfuseStorage();
public final InfuseStorage infuseStored = new InfuseStorage();
public GasTank gasTank;
public final GasTank gasTank;
public boolean sorting;
@@ -116,16 +117,12 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
public double lastUsage;
/**
* This machine's current RedstoneControl type.
*/
public RedstoneControl controlType = RedstoneControl.DISABLED;
public TileComponentEjector ejectorComponent;
public TileComponentConfig configComponent;
/**
* This machine's recipe type.
*/
@Nonnull
private RecipeType recipeType = RecipeType.SMELTING;
public TileEntityFactory() {
@@ -172,7 +169,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
world.setBlockToAir(getPos());
world.setBlockState(getPos(), MekanismBlocks.MachineBlock.getStateFromMeta(5 + tier.ordinal() + 1), 3);
TileEntityFactory factory = (TileEntityFactory) world.getTileEntity(getPos());
TileEntityFactory factory = Objects.requireNonNull((TileEntityFactory) world.getTileEntity(getPos()));
//Basic
factory.facing = facing;
@@ -193,7 +190,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
factory.prevEnergy = prevEnergy;
factory.gasTank.setGas(gasTank.getGas());
factory.sorting = sorting;
factory.controlType = controlType;
factory.setControlType(getControlType());
factory.upgradeComponent.readFrom(upgradeComponent);
factory.ejectorComponent.readFrom(ejectorComponent);
factory.configComponent.readFrom(configComponent);
@@ -201,7 +198,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
factory.setRecipeType(recipeType);
factory.upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades());
factory.securityComponent.readFrom(securityComponent);
factory.infuseStored = infuseStored;
factory.infuseStored.copyFrom(infuseStored);
for (int i = 0; i < tier.processes + 5; i++) {
factory.inventory.set(i, inventory.get(i));
@@ -316,12 +313,13 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
}
}
@Nonnull
public RecipeType getRecipeType() {
return recipeType;
}
public void setRecipeType(RecipeType type) {
recipeType = type;
public void setRecipeType(@Nonnull RecipeType type) {
recipeType = Objects.requireNonNull(type);
BASE_MAX_ENERGY = maxEnergy = tier.processes * Math.max(0.5D * recipeType.getEnergyStorage(), recipeType.getEnergyUsage());
BASE_ENERGY_PER_TICK = energyPerTick = recipeType.getEnergyUsage();
upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades());
@@ -812,7 +810,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{electricityStored};
@@ -396,7 +396,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
if (method == 0) {
activeNodes.clear();
usedNodes.clear();
@@ -343,7 +343,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{gasTank.getMaxGas()};
@@ -174,7 +174,7 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
if (structure == null) {
return new Object[]{"Unformed."};
}
@@ -301,7 +301,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{getEnergy()};
@@ -512,7 +512,7 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement
}
@Override
public Object[] invoke(int method, Object[] arguments) {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
if (arguments.length > 0) {
if (method == 0) {
if (!(arguments[0] instanceof String)) {
@@ -1,6 +1,7 @@
package mekanism.common.tile;
import io.netty.buffer.ByteBuf;
import java.util.Objects;
import javax.annotation.Nonnull;
import mekanism.api.EnumColor;
import mekanism.api.IConfigCardAccess;
@@ -39,6 +40,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import org.jetbrains.annotations.Contract;
public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine implements IComputerIntegration, ISideConfiguration, IConfigCardAccess, ITierUpgradeable,
ISustainedData {
@@ -123,7 +125,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
world.setBlockToAir(getPos());
world.setBlockState(getPos(), MekanismBlocks.MachineBlock.getStateFromMeta(5), 3);
TileEntityFactory factory = (TileEntityFactory) world.getTileEntity(getPos());
TileEntityFactory factory = Objects.requireNonNull((TileEntityFactory) world.getTileEntity(getPos()));
RecipeType type = RecipeType.INFUSING;
//Basic
@@ -140,7 +142,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
//Machine
factory.progress[0] = operatingTicks;
factory.setActive(isActive);
factory.controlType = controlType;
factory.setControlType(getControlType());
factory.prevEnergy = prevEnergy;
factory.upgradeComponent.readFrom(upgradeComponent);
factory.upgradeComponent.setUpgradeSlot(0);
@@ -156,7 +158,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
}
//Infuser
factory.infuseStored = infuseStored;
factory.infuseStored.copyFrom(infuseStored);
factory.inventory.set(5, inventory.get(2));
factory.inventory.set(1, inventory.get(4));
@@ -185,7 +187,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
if (slotID == 3) {
return false;
} else if (slotID == 1) {
return InfuseRegistry.getObject(itemstack) != null && (infuseStored.getType() == null || infuseStored.getType() == InfuseRegistry.getObject(itemstack).type);
InfuseObject infuseObject = InfuseRegistry.getObject(itemstack);
return infuseObject != null && (infuseStored.getType() == null || infuseStored.getType() == infuseObject.type);
} else if (slotID == 0) {
return itemstack.getItem() == MekanismItems.SpeedUpgrade || itemstack.getItem() == MekanismItems.EnergyUpgrade;
} else if (slotID == 2) {
@@ -209,6 +212,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
ejectorComponent.outputItems();
}
@Contract("null -> false")
public boolean canOperate(MetallurgicInfuserRecipe recipe) {
return recipe != null && recipe.canOperate(inventory, 2, 3, infuseStored);
}
@@ -281,7 +285,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{getEnergy()};
@@ -12,6 +12,7 @@ import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Mekanism;
import mekanism.common.SideData;
import mekanism.common.Upgrade;
import mekanism.common.base.FluidHandlerWrapper;
@@ -57,7 +58,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
public TileEntityPRC() {
super("prc", MachineType.PRESSURIZED_REACTION_CHAMBER.blockName, MachineType.PRESSURIZED_REACTION_CHAMBER.getStorage(),
MachineType.PRESSURIZED_REACTION_CHAMBER.getUsage(), 3, 100, new ResourceLocation("mekanism", "gui/GuiPRC.png"));
MachineType.PRESSURIZED_REACTION_CHAMBER.getUsage(), 3, 100, new ResourceLocation(Mekanism.MODID, "gui/GuiPRC.png"));
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.FLUID, TransmissionType.GAS);
configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY));
@@ -222,7 +223,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{getEnergy()};
@@ -593,7 +593,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
if (method == 0) {
if (!(arguments[0] instanceof String) || !(arguments[1] instanceof Boolean)) {
return new Object[]{"Invalid parameters."};
@@ -263,7 +263,7 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{getEnergy()};
@@ -488,7 +488,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{getEnergy()};
@@ -109,7 +109,7 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock
}
@Override
public Object[] invoke(int method, Object[] args) throws Exception {
public Object[] invoke(int method, Object[] args) throws NoSuchMethodException {
TileEntityThermalEvaporationController controller = getController();
if (controller == null) {
return new Object[]{"Unformed."};
@@ -333,7 +333,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{getEnergy()};
@@ -153,7 +153,7 @@ public abstract class TileEntityDoubleElectricMachine<RECIPE extends DoubleMachi
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{getEnergy()};
@@ -139,7 +139,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception {
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
switch (method) {
case 0:
return new Object[]{getEnergy()};
@@ -1,6 +1,7 @@
package mekanism.common.tile.prefab;
import io.netty.buffer.ByteBuf;
import java.util.Objects;
import javax.annotation.Nonnull;
import mekanism.api.TileNetworkList;
import mekanism.common.Upgrade;
@@ -24,7 +25,7 @@ public abstract class TileEntityMachine extends TileEntityEffectsBlock implement
/**
* This machine's current RedstoneControl type.
*/
public RedstoneControl controlType = RedstoneControl.DISABLED;
private RedstoneControl controlType = RedstoneControl.DISABLED;
public TileComponentUpgrade upgradeComponent;
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
@@ -91,8 +92,8 @@ public abstract class TileEntityMachine extends TileEntityEffectsBlock implement
}
@Override
public void setControlType(RedstoneControl type) {
controlType = type;
public void setControlType(@Nonnull RedstoneControl type) {
controlType = Objects.requireNonNull(type);
MekanismUtils.saveChunk(this);
}
@@ -1,5 +1,6 @@
package mekanism.common.tile.prefab;
import java.util.Objects;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.MekanismBlocks;
import mekanism.common.Upgrade;
@@ -35,7 +36,7 @@ public abstract class TileEntityUpgradeableMachine<INPUT extends MachineInput<IN
world.setBlockToAir(getPos());
world.setBlockState(getPos(), MekanismBlocks.MachineBlock.getStateFromMeta(5), 3);
TileEntityFactory factory = (TileEntityFactory) world.getTileEntity(getPos());
TileEntityFactory factory = Objects.requireNonNull((TileEntityFactory) world.getTileEntity(getPos()));
RecipeType type = RecipeType.getFromMachine(getBlockType(), getBlockMetadata());
//Basic
@@ -52,7 +53,7 @@ public abstract class TileEntityUpgradeableMachine<INPUT extends MachineInput<IN
//Machine
factory.progress[0] = operatingTicks;
factory.isActive = isActive;
factory.controlType = controlType;
factory.setControlType(getControlType());
factory.prevEnergy = prevEnergy;
factory.upgradeComponent.readFrom(upgradeComponent);
factory.upgradeComponent.setUpgradeSlot(0);
@@ -78,39 +78,40 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyAccept
for (EnumFacing side : sides) {
if (connectedOutputters[side.ordinal()] != null) {
TileEntity outputter = connectedOutputters[side.ordinal()];
//pre declare some variables for inline assignment & checks
IStrictEnergyStorage strictStorage;
ITeslaProducer teslaProducer;//do not assign anything to this here, or classloader issues may happen
IEnergyStorage forgeStorage;
if (CapabilityUtils.hasCapability(outputter, Capabilities.ENERGY_OUTPUTTER_CAPABILITY, side.getOpposite())
&& CapabilityUtils.hasCapability(outputter, Capabilities.ENERGY_STORAGE_CAPABILITY, side.getOpposite())) {
IStrictEnergyStorage storage = CapabilityUtils.getCapability(outputter, Capabilities.ENERGY_STORAGE_CAPABILITY, side.getOpposite());
double received = Math.min(storage.getEnergy(), canDraw);
&& (strictStorage = CapabilityUtils.getCapability(outputter, Capabilities.ENERGY_STORAGE_CAPABILITY, side.getOpposite())) != null) {
double received = Math.min(strictStorage.getEnergy(), canDraw);
double toDraw = received;
if (received > 0) {
toDraw -= takeEnergy(received, true);
}
storage.setEnergy(storage.getEnergy() - toDraw);
} else if (MekanismUtils.useTesla() && CapabilityUtils.hasCapability(outputter, Capabilities.TESLA_PRODUCER_CAPABILITY, side.getOpposite())) {
ITeslaProducer producer = CapabilityUtils.getCapability(outputter, Capabilities.TESLA_PRODUCER_CAPABILITY, side.getOpposite());
double toDraw = producer.takePower(MekanismUtils.clampToInt(canDraw * MekanismConfig.current().general.TO_TESLA.val()), true)
strictStorage.setEnergy(strictStorage.getEnergy() - toDraw);
} else if (MekanismUtils.useTesla() && (teslaProducer = CapabilityUtils.getCapability(outputter, Capabilities.TESLA_PRODUCER_CAPABILITY, side.getOpposite())) != null) {
double toDraw = teslaProducer.takePower(MekanismUtils.clampToInt(canDraw * MekanismConfig.current().general.TO_TESLA.val()), true)
* MekanismConfig.current().general.FROM_TESLA.val();
if (toDraw > 0) {
toDraw -= takeEnergy(toDraw, true);
}
producer.takePower(Math.round(toDraw * MekanismConfig.current().general.TO_TESLA.val()), false);
} else if (MekanismUtils.useForge() && CapabilityUtils.hasCapability(outputter, CapabilityEnergy.ENERGY, side.getOpposite())) {
IEnergyStorage storage = CapabilityUtils.getCapability(outputter, CapabilityEnergy.ENERGY, side.getOpposite());
double toDraw = storage.extractEnergy(MekanismUtils.clampToInt(canDraw * MekanismConfig.current().general.TO_FORGE.val()), true)
teslaProducer.takePower(Math.round(toDraw * MekanismConfig.current().general.TO_TESLA.val()), false);
} else if (MekanismUtils.useForge() && (forgeStorage = CapabilityUtils.getCapability(outputter, CapabilityEnergy.ENERGY, side.getOpposite())) != null) {
double toDraw = forgeStorage.extractEnergy(MekanismUtils.clampToInt(canDraw * MekanismConfig.current().general.TO_FORGE.val()), true)
* MekanismConfig.current().general.FROM_FORGE.val();
if (toDraw > 0) {
toDraw -= takeEnergy(toDraw, true);
}
storage.extractEnergy(MekanismUtils.clampToInt(toDraw * MekanismConfig.current().general.TO_TESLA.val()), false);
forgeStorage.extractEnergy(MekanismUtils.clampToInt(toDraw * MekanismConfig.current().general.TO_TESLA.val()), false);
} else if (MekanismUtils.useRF() && outputter instanceof IEnergyProvider) {
double toDraw = ((IEnergyProvider) outputter).extractEnergy(side.getOpposite(),
IEnergyProvider rfProvider = (IEnergyProvider) outputter;
double toDraw = rfProvider.extractEnergy(side.getOpposite(),
MekanismUtils.clampToInt(canDraw * MekanismConfig.current().general.TO_RF.val()), true) * MekanismConfig.current().general.FROM_RF.val();
if (toDraw > 0) {
toDraw -= takeEnergy(toDraw, true);
}
((IEnergyProvider) outputter).extractEnergy(side.getOpposite(), MekanismUtils.clampToInt(toDraw * MekanismConfig.current().general.TO_RF.val()), false);
rfProvider.extractEnergy(side.getOpposite(), MekanismUtils.clampToInt(toDraw * MekanismConfig.current().general.TO_RF.val()), false);
} else if (MekanismUtils.useIC2()) {
IEnergyTile tile = EnergyNet.instance.getSubTile(outputter.getWorld(), outputter.getPos());
if (tile instanceof IEnergySource) {
@@ -6,7 +6,9 @@ import cofh.redstoneflux.api.IEnergyReceiver;
import java.util.HashSet;
import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyOutputter;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.base.EnergyAcceptorWrapper;
import mekanism.common.base.IEnergyWrapper;
@@ -18,12 +20,14 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
public final class CableUtils {
public static boolean isCable(TileEntity tileEntity) {
if (CapabilityUtils.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null)) {
return TransmissionType.checkTransmissionType(CapabilityUtils.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null), TransmissionType.ENERGY);
IGridTransmitter gridTransmitter = CapabilityUtils.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null);
if (gridTransmitter != null) {
return TransmissionType.checkTransmissionType(gridTransmitter, TransmissionType.ENERGY);
}
return false;
}
@@ -71,19 +75,24 @@ public final class CableUtils {
if (tileEntity == null) {
return false;
}
if (CapabilityUtils.hasCapability(tileEntity, Capabilities.ENERGY_OUTPUTTER_CAPABILITY, side.getOpposite())) {
IStrictEnergyOutputter outputter = CapabilityUtils.getCapability(tileEntity, Capabilities.ENERGY_OUTPUTTER_CAPABILITY, side.getOpposite());
if (outputter != null && outputter.canOutputEnergy(side.getOpposite())) {
return true;
}
}
if (MekanismUtils.useTesla() && CapabilityUtils.hasCapability(tileEntity, Capabilities.TESLA_PRODUCER_CAPABILITY, side.getOpposite())) {
EnumFacing opposite = side.getOpposite();
IStrictEnergyOutputter outputter = CapabilityUtils.getCapability(tileEntity, Capabilities.ENERGY_OUTPUTTER_CAPABILITY, opposite);
if (outputter != null && outputter.canOutputEnergy(opposite)) {
return true;
}
if (MekanismUtils.useForge() && CapabilityUtils.hasCapability(tileEntity, CapabilityEnergy.ENERGY, side.getOpposite())) {
return CapabilityUtils.getCapability(tileEntity, CapabilityEnergy.ENERGY, side.getOpposite()).canExtract();
if (MekanismUtils.useTesla() && CapabilityUtils.hasCapability(tileEntity, Capabilities.TESLA_PRODUCER_CAPABILITY, opposite)) {
return true;
}
if (MekanismUtils.useRF() && tileEntity instanceof IEnergyProvider && ((IEnergyConnection) tileEntity).canConnectEnergy(side.getOpposite())) {
IEnergyStorage forgeStorage;
if (MekanismUtils.useForge() && (forgeStorage = CapabilityUtils.getCapability(tileEntity, CapabilityEnergy.ENERGY, opposite))!=null) {
return forgeStorage.canExtract();
}
if (MekanismUtils.useRF() && tileEntity instanceof IEnergyProvider && ((IEnergyConnection) tileEntity).canConnectEnergy(opposite)) {
return true;
}
return MekanismUtils.useIC2() && IC2Integration.isOutputter(tileEntity, side);
@@ -94,12 +103,14 @@ public final class CableUtils {
if (CapabilityUtils.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite())) {
return false;
}
if (CapabilityUtils.hasCapability(tileEntity, Capabilities.ENERGY_ACCEPTOR_CAPABILITY, side.getOpposite())) {
return CapabilityUtils.getCapability(tileEntity, Capabilities.ENERGY_ACCEPTOR_CAPABILITY, side.getOpposite()).canReceiveEnergy(side.getOpposite());
IStrictEnergyAcceptor strictEnergyAcceptor;
IEnergyStorage energyStorage;
if ((strictEnergyAcceptor = CapabilityUtils.getCapability(tileEntity, Capabilities.ENERGY_ACCEPTOR_CAPABILITY, side.getOpposite())) != null) {
return strictEnergyAcceptor.canReceiveEnergy(side.getOpposite());
} else if (MekanismUtils.useTesla() && CapabilityUtils.hasCapability(tileEntity, Capabilities.TESLA_CONSUMER_CAPABILITY, side.getOpposite())) {
return true;
} else if (MekanismUtils.useForge() && CapabilityUtils.hasCapability(tileEntity, CapabilityEnergy.ENERGY, side.getOpposite())) {
return CapabilityUtils.getCapability(tileEntity, CapabilityEnergy.ENERGY, side.getOpposite()).canReceive();
} else if (MekanismUtils.useForge() && (energyStorage = CapabilityUtils.getCapability(tileEntity, CapabilityEnergy.ENERGY, side.getOpposite())) != null) {
return energyStorage.canReceive();
} else if (MekanismUtils.useIC2() && IC2Integration.isAcceptor(orig, tileEntity, side)) {
return true;
} else if (MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver) {
@@ -1,5 +1,6 @@
package mekanism.common.util;
import java.util.function.Consumer;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
@@ -19,4 +20,80 @@ public final class CapabilityUtils {
}
return provider.getCapability(cap, side);
}
public static <T> OptionalCapability withCapability(ICapabilityProvider provider, Capability<T> cap, EnumFacing side, Consumer<T> consumer) {
return new OptionalCapability(provider).orElseWith(cap, side, consumer);
}
public static <T> OptionalCapability withCapability(boolean testResult, ICapabilityProvider provider, Capability<T> cap, EnumFacing side, Consumer<T> consumer) {
return new OptionalCapability(provider).orElseWith(testResult, cap, side, consumer);
}
public static class OptionalCapability {
private final ICapabilityProvider provider;
OptionalCapability(ICapabilityProvider provider) {
this.provider = provider;
}
/**
* If this chain has not yet been satisfied, try to get the capability and consume it.
*
* @param capability the cap to check
* @param side side to give to the provider
* @param consumer function to use the capability
* @param <T> the capability type
*
* @return this instance if unsuccessful, otherwise a no-op OptionalCapability
*/
public <T> OptionalCapability orElseWith(Capability<T> capability, EnumFacing side, Consumer<T> consumer) {
T cap = this.provider.getCapability(capability, side);
if (cap != null) {
consumer.accept(cap);
return NoOpOptionalCapability.INSTANCE;
}
return this;
}
/**
* Like {@link #orElseWith(Capability, EnumFacing, Consumer)}, but skips if boolean testResult fails.
*
* @param testResult if this param is false, cap is not processed
* @param capability the cap to check
* @param side side to give to the provider
* @param consumer function to use the capability
* @param <T> the capability type
*
* @return this instance if unsuccessful (or testResult is false), otherwise a no-op OptionalCapability
*/
public <T> OptionalCapability orElseWith(boolean testResult, Capability<T> capability, EnumFacing side, Consumer<T> consumer) {
if (!testResult) {
return this;
}
return orElseWith(capability, side, consumer);
}
}
/**
* All method should be no-op version of super, return this instance when the action succeeded
*/
public static class NoOpOptionalCapability extends OptionalCapability {
public static final NoOpOptionalCapability INSTANCE = new NoOpOptionalCapability();
private NoOpOptionalCapability() {
super(null);
}
@Override
public <T> OptionalCapability orElseWith(Capability<T> capability, EnumFacing side, Consumer<T> consumer) {
return this;
}
@Override
public <T> OptionalCapability orElseWith(boolean testResult, Capability<T> capability, EnumFacing side, Consumer<T> consumer) {
return this;
}
}
}
@@ -155,7 +155,6 @@ public final class InventoryUtils {
return CapabilityUtils.getCapability(tile, CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
}
/* TODO From CCLib -- go back to that version when we're using dependencies again */
public static boolean canStack(ItemStack stack1, ItemStack stack2) {
return stack1.isEmpty() || stack2.isEmpty() ||
stack1.getItem() == stack2.getItem() && (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage())
@@ -38,7 +38,6 @@ public final class ItemRegistryUtils {
String modId = itemResourceLocation.getNamespace();
String lowercaseModId = modId.toLowerCase(Locale.ENGLISH);
String modName = modIDMap.computeIfAbsent(lowercaseModId, k -> WordUtils.capitalize(modId));
return modName;
return modIDMap.computeIfAbsent(lowercaseModId, k -> WordUtils.capitalize(modId));
}
}
@@ -640,7 +640,7 @@ public final class MekanismUtils {
* @return the corresponding ResourceLocation
*/
public static ResourceLocation getResource(ResourceType type, String name) {
return new ResourceLocation("mekanism", type.getPrefix() + name);
return new ResourceLocation(Mekanism.MODID, type.getPrefix() + name);
}
/**
@@ -980,6 +980,7 @@ public final class MekanismUtils {
return Item.getIdFromItem(itemStack.getItem());
}
@Deprecated//todo remove this
public static boolean classExists(String className) {
if (classesFound.containsKey(className)) {
return classesFound.get(className) != null;
@@ -994,6 +995,7 @@ public final class MekanismUtils {
return found != null;
}
@Deprecated//todo remove this
public static boolean existsAndInstance(Object obj, String className) {
Class<?> theClass;
if (classesFound.containsKey(className)) {
@@ -27,6 +27,7 @@ import mekanism.generators.client.render.item.RenderGeneratorItem;
import mekanism.generators.common.GeneratorsBlocks;
import mekanism.generators.common.GeneratorsCommonProxy;
import mekanism.generators.common.GeneratorsItems;
import mekanism.generators.common.MekanismGenerators;
import mekanism.generators.common.block.states.BlockStateGenerator.GeneratorBlockStateMapper;
import mekanism.generators.common.block.states.BlockStateGenerator.GeneratorType;
import mekanism.generators.common.block.states.BlockStateReactor.ReactorBlockStateMapper;
@@ -50,6 +51,7 @@ import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.world.World;
@@ -99,16 +101,16 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy {
ModelLoader.setCustomStateMapper(GeneratorsBlocks.ReactorGlass, reactorMapper);
for (GeneratorType type : GeneratorType.values()) {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(type.blockType.getBlock()), type.meta, new ModelResourceLocation("mekanismgenerators:" + type.getName(), "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(type.blockType.getBlock()), type.meta, new ModelResourceLocation(new ResourceLocation(MekanismGenerators.MODID, type.getName()), "inventory"));
}
for (ReactorBlockType type : ReactorBlockType.values()) {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(type.blockType.getBlock()), type.meta, new ModelResourceLocation("mekanismgenerators:" + type.getName(), "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(type.blockType.getBlock()), type.meta, new ModelResourceLocation(new ResourceLocation(MekanismGenerators.MODID, type.getName()), "inventory"));
}
}
public void registerItemRender(Item item) {
MekanismRenderer.registerItemRender("mekanismgenerators", item);
MekanismRenderer.registerItemRender(MekanismGenerators.MODID, item);
}
@SubscribeEvent
@@ -123,7 +125,7 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy {
}
private void generatorModelBake(IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, GeneratorType type) {
ModelResourceLocation modelResourceLocation = new ModelResourceLocation("mekanismgenerators:" + type.getName(), "inventory");
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(new ResourceLocation(MekanismGenerators.MODID, type.getName()), "inventory");
ItemLayerWrapper itemLayerWrapper = new ItemLayerWrapper(modelRegistry.getObject(modelResourceLocation));
RenderGeneratorItem.modelMap.put(type, itemLayerWrapper);
modelRegistry.putObject(modelResourceLocation, itemLayerWrapper);
Loaded 100 of 115 files, more files were not shown because too many files have changed in this diff. Show more