Fixed ore dic, and some work on multi blocks

This commit is contained in:
modmuss50 2015-05-08 21:23:04 +01:00
parent 446f94770d
commit c6d9f302c3
7 changed files with 16 additions and 426 deletions

View file

@ -58,7 +58,7 @@ public class BlockBlastFurnace extends BlockMachineBase {
.getTileEntity(x + direction.offsetX, y
+ direction.offsetY, z + direction.offsetZ);
if (casing.getMultiblockController() != null
&& casing.getMultiblockController().isAssembled())
&& casing.getMultiblockController().isAssembled() && !casing.getMultiblockController().isStar)
{
player.openGui(Core.INSTANCE,
GuiHandler.blastFurnaceID, world, x, y, z);

View file

@ -1,7 +1,6 @@
package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
@ -10,6 +9,7 @@ import org.lwjgl.opengl.GL11;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.RecipeHanderer;
import techreborn.config.ConfigTechReborn;
import techreborn.util.ItemUtils;
import java.awt.*;
import java.util.ArrayList;
@ -131,7 +131,7 @@ public abstract class GenericRecipeHander extends TemplateRecipeHandler {
for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName()))
{
for(ItemStack output : recipeType.getOutputs()){
if (NEIServerUtils.areStacksSameTypeCrafting(output, result))
if (ItemUtils.isItemEqual(output, result, true, false, true))
{
addCached(recipeType);
}
@ -145,7 +145,7 @@ public abstract class GenericRecipeHander extends TemplateRecipeHandler {
for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName()))
{
for(ItemStack input : recipeType.getInputs()){
if (NEIServerUtils.areStacksSameTypeCrafting(input, ingredient))
if (ItemUtils.isItemEqual(ingredient, input, true, false, true))
{
addCached(recipeType);
}

View file

@ -195,7 +195,7 @@ public class ModRecipes {
Blocks.cobblestone);
TechRebornAPI.registerBlastFurnaceRecipe(new BlastFurnaceRecipe(new ItemStack(Items.apple), new ItemStack(Items.ender_pearl), new ItemStack(Items.golden_apple), new ItemStack(Items.diamond), 120, 1000));
RecipeHanderer.addRecipe(new ImplosionCompressorRecipe(new ItemStack(Items.diamond), new ItemStack(Items.golden_apple), new ItemStack(Items.brewing_stand), new ItemStack(Items.carrot), 120, 5));
RecipeHanderer.addRecipe(new ImplosionCompressorRecipe(new ItemStack(Items.record_11), new ItemStack(Items.golden_apple), new ItemStack(Items.brewing_stand), new ItemStack(Items.carrot), 120, 5));
LogHelper.info("Machine Recipes Added");
}

View file

@ -1,144 +0,0 @@
package techreborn.multiblocks;
import erogenousbeef.coreTR.multiblock.IMultiblockPart;
import erogenousbeef.coreTR.multiblock.MultiblockControllerBase;
import erogenousbeef.coreTR.multiblock.MultiblockValidationException;
import erogenousbeef.coreTR.multiblock.rectangular.RectangularMultiblockControllerBase;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import techreborn.util.LogHelper;
public class MultiBlockCasing extends RectangularMultiblockControllerBase {
public boolean hasLava;
public MultiBlockCasing(World world) {
super(world);
}
@Override
public void onAttachedPartWithMultiblockData(IMultiblockPart part,
NBTTagCompound data) {
}
@Override
protected void onBlockAdded(IMultiblockPart newPart) {
}
@Override
protected void onBlockRemoved(IMultiblockPart oldPart) {
}
@Override
protected void onMachineAssembled() {
LogHelper.warn("New multiblock created!");
}
@Override
protected void onMachineRestored() {
}
@Override
protected void onMachinePaused() {
}
@Override
protected void onMachineDisassembled() {
}
@Override
protected int getMinimumNumberOfBlocksForAssembledMachine() {
return 1;
}
@Override
protected int getMaximumXSize() {
return 3;
}
@Override
protected int getMaximumZSize() {
return 3;
}
@Override
protected int getMaximumYSize() {
return 4;
}
@Override
protected int getMinimumXSize() {
return 3;
}
@Override
protected int getMinimumYSize() {
return 4;
}
@Override
protected int getMinimumZSize() {
return 3;
}
@Override
protected void onAssimilate(MultiblockControllerBase assimilated) {
}
@Override
protected void onAssimilated(MultiblockControllerBase assimilator) {
}
@Override
protected boolean updateServer() {
return true;
}
@Override
protected void updateClient() {
}
@Override
public void writeToNBT(NBTTagCompound data) {
}
@Override
public void readFromNBT(NBTTagCompound data) {
}
@Override
public void formatDescriptionPacket(NBTTagCompound data) {
}
@Override
public void decodeDescriptionPacket(NBTTagCompound data) {
}
@Override
protected void isBlockGoodForInterior(World world, int x, int y, int z)
throws MultiblockValidationException {
Block block = world.getBlock(x, y, z);
if (block.getUnlocalizedName().equals("tile.air")) {
} else if (block.getUnlocalizedName().equals("tile.lava")) {
hasLava = true;
} else {
super.isBlockGoodForInterior(world, x, y, z);
}
}
}

View file

@ -1,247 +0,0 @@
package techreborn.multiblocks;
import erogenousbeef.coreTR.common.CoordTriplet;
import erogenousbeef.coreTR.multiblock.IMultiblockPart;
import erogenousbeef.coreTR.multiblock.MultiblockControllerBase;
import erogenousbeef.coreTR.multiblock.MultiblockValidationException;
import erogenousbeef.coreTR.multiblock.rectangular.RectangularMultiblockControllerBase;
import erogenousbeef.coreTR.multiblock.rectangular.RectangularMultiblockTileEntityBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import techreborn.blocks.BlockMachineCasing;
import techreborn.util.LogHelper;
/**
* Created by mark on 04/05/15.
*/
public class MultiblockImplosionCompressor extends MultiBlockCasing {
public MultiblockImplosionCompressor(World world) {
super(world);
}
@Override
public void onAttachedPartWithMultiblockData(IMultiblockPart part,
NBTTagCompound data) {
}
@Override
protected void onBlockAdded(IMultiblockPart newPart) {
}
@Override
protected void onBlockRemoved(IMultiblockPart oldPart) {
}
@Override
protected void onMachineAssembled() {
LogHelper.warn("New multiblock created!");
}
@Override
protected void onMachineRestored() {
}
@Override
protected void onMachinePaused() {
}
@Override
protected void onMachineDisassembled() {
}
@Override
protected int getMinimumNumberOfBlocksForAssembledMachine() {
return 1;
}
@Override
protected int getMaximumXSize() {
return 3;
}
@Override
protected int getMaximumZSize() {
return 3;
}
@Override
protected int getMaximumYSize() {
return 3;
}
@Override
protected int getMinimumXSize() {
return 3;
}
@Override
protected int getMinimumYSize() {
return 3;
}
@Override
protected int getMinimumZSize() {
return 3;
}
@Override
protected void onAssimilate(MultiblockControllerBase assimilated) {
}
@Override
protected void onAssimilated(MultiblockControllerBase assimilator) {
}
@Override
protected boolean updateServer() {
return true;
}
@Override
protected void updateClient() {
}
@Override
public void writeToNBT(NBTTagCompound data) {
}
@Override
public void readFromNBT(NBTTagCompound data) {
}
@Override
public void formatDescriptionPacket(NBTTagCompound data) {
}
@Override
public void decodeDescriptionPacket(NBTTagCompound data) {
}
/**
* @return True if the machine is "whole" and should be assembled. False
* otherwise.
*/
@Override
protected void isMachineWhole() throws MultiblockValidationException
{
if (connectedParts.size() < getMinimumNumberOfBlocksForAssembledMachine())
{
throw new MultiblockValidationException("Machine is too small.");
}
CoordTriplet maximumCoord = getMaximumCoord();
CoordTriplet minimumCoord = getMinimumCoord();
// Quickly check for exceeded dimensions
int deltaX = maximumCoord.x - minimumCoord.x + 1;
int deltaY = maximumCoord.y - minimumCoord.y + 1;
int deltaZ = maximumCoord.z - minimumCoord.z + 1;
int maxX = getMaximumXSize();
int maxY = getMaximumYSize();
int maxZ = getMaximumZSize();
int minX = getMinimumXSize();
int minY = getMinimumYSize();
int minZ = getMinimumZSize();
if (maxX > 0 && deltaX > maxX)
{
throw new MultiblockValidationException(
String.format(
"Machine is too large, it may be at most %d blocks in the X dimension",
maxX));
}
if (maxY > 0 && deltaY > maxY)
{
throw new MultiblockValidationException(
String.format(
"Machine is too large, it may be at most %d blocks in the Y dimension",
maxY));
}
if (maxZ > 0 && deltaZ > maxZ)
{
throw new MultiblockValidationException(
String.format(
"Machine is too large, it may be at most %d blocks in the Z dimension",
maxZ));
}
if (deltaX < minX)
{
throw new MultiblockValidationException(
String.format(
"Machine is too small, it must be at least %d blocks in the X dimension",
minX));
}
if (deltaY < minY)
{
throw new MultiblockValidationException(
String.format(
"Machine is too small, it must be at least %d blocks in the Y dimension",
minY));
}
if (deltaZ < minZ)
{
throw new MultiblockValidationException(
String.format(
"Machine is too small, it must be at least %d blocks in the Z dimension",
minZ));
}
// Now we run a simple check on each block within that volume.
// Any block deviating = NO DEAL SIR
TileEntity te;
RectangularMultiblockTileEntityBase part;
Class<? extends RectangularMultiblockControllerBase> myClass = this
.getClass();
//This is the bottom corner block
te = this.worldObj.getTileEntity(minimumCoord.x, minimumCoord.y, minimumCoord.z);
checkTeIsCorner(te);
te = this.worldObj.getTileEntity(minimumCoord.x + 2, minimumCoord.y, minimumCoord.z);
checkTeIsCorner(te);
te = this.worldObj.getTileEntity(minimumCoord.x, minimumCoord.y, minimumCoord.z + 2);
checkTeIsCorner(te);
te = this.worldObj.getTileEntity(minimumCoord.x + 2, minimumCoord.y, minimumCoord.z + 2);
checkTeIsCorner(te);
te = this.worldObj.getTileEntity(minimumCoord.x, minimumCoord.y + 2, minimumCoord.z);
checkTeIsCorner(te);
te = this.worldObj.getTileEntity(minimumCoord.x + 2, minimumCoord.y + 2, minimumCoord.z);
checkTeIsCorner(te);
te = this.worldObj.getTileEntity(minimumCoord.x, minimumCoord.y + 2, minimumCoord.z + 2);
checkTeIsCorner(te);
te = this.worldObj.getTileEntity(minimumCoord.x + 2, minimumCoord.y + 2, minimumCoord.z + 2);
checkTeIsCorner(te);
}
public void checkTeIsCorner(TileEntity te) throws MultiblockValidationException{
if(!(te.blockType instanceof BlockMachineCasing && te.blockMetadata == 0)){
throw new MultiblockValidationException(
String.format(
"Part @ %d, %d, %d is incompatible with machines of type %s",
te.xCoord, te.yCoord, te.zCoord, "MultiBlock Implosion"));
}
}
}

View file

@ -1,23 +1,16 @@
package techreborn.tiles;
import codechicken.multipart.MultiPartRegistry;
import erogenousbeef.coreTR.multiblock.MultiblockRegistry;
import erogenousbeef.coreTR.multiblock.MultiblockWorldRegistry;
import techreborn.multiblocks.MultiBlockCasing;
import erogenousbeef.coreTR.multiblock.MultiblockControllerBase;
import erogenousbeef.coreTR.multiblock.MultiblockValidationException;
import erogenousbeef.coreTR.multiblock.rectangular.RectangularMultiblockTileEntityBase;
import techreborn.multiblocks.MultiblockImplosionCompressor;
public class TileMachineCasing extends RectangularMultiblockTileEntityBase {
int ticks;
boolean isStarShape = false;
@Override
public boolean canUpdate()
{
return true;
return false;
}
@Override
@ -35,20 +28,12 @@ public class TileMachineCasing extends RectangularMultiblockTileEntityBase {
@Override
public MultiblockControllerBase createNewMultiblock()
{
if(isStarShape)
{
return new MultiblockImplosionCompressor(worldObj);
}
return new MultiBlockCasing(worldObj);
}
@Override
public Class<? extends MultiblockControllerBase> getMultiblockControllerType()
{
if(isStarShape)
{
return MultiblockImplosionCompressor.class;
}
return MultiBlockCasing.class;
}
@ -87,16 +72,4 @@ public class TileMachineCasing extends RectangularMultiblockTileEntityBase {
return (MultiBlockCasing) super.getMultiblockController();
}
@Override
public void updateEntity() {
super.updateEntity();
if(getMultiblockController() == null || !getMultiblockController().isAssembled()){
ticks ++;
if(ticks == 20){
isStarShape = !isStarShape;
ticks = 0;
//TODO recalculate multiblock
}
}
}
}

View file

@ -40,8 +40,16 @@ public class ItemUtils {
}
if (a == null || b == null)
return false;
return OreDictionary.itemMatches(a, b, false);
if(useOreDic){
for (int inta : OreDictionary.getOreIDs(a)){
for (int intb : OreDictionary.getOreIDs(b)){
if(inta == intb){
return true;
}
}
}
}
return false;
}