Merge branch '1.12' into feature/solar-panles

Conflicts:
	build.gradle
	src/main/java/techreborn/blocks/generator/BlockSolarPanel.java
	src/main/java/techreborn/blocks/lighting/BlockLamp.java
This commit is contained in:
drcrazy 2017-11-28 17:28:47 +03:00
commit eab088c094
77 changed files with 948 additions and 967 deletions

View file

@ -226,41 +226,44 @@ public class TileAutoCraftingTable extends TilePowerAcceptor implements IContain
}
public boolean make(IRecipe recipe) {
if (canMake(recipe)) {
if (recipe == null && customRecipe) {
IRecipe recipe2 = recipe;
if (canMake(recipe2)) {
if (recipe2 == null && customRecipe) {
if (lastCustomRecipe == null) {
return false;
}//Should be uptodate as we just set it in canMake
recipe = lastCustomRecipe;
}
for (int i = 0; i < recipe.getIngredients().size(); i++) {
Ingredient ingredient = recipe.getIngredients().get(i);
//Looks for the best slot to take it from
ItemStack bestSlot = inventory.getStackInSlot(i);
if (ingredient.apply(bestSlot)) {
handleContainerItem(bestSlot);
bestSlot.shrink(1);
} else {
for (int j = 0; j < 9; j++) {
ItemStack stack = inventory.getStackInSlot(j);
if (ingredient.apply(stack)) {
handleContainerItem(stack);
stack.shrink(1); //TODO is this right? or do I need to use it as an actull crafting grid
break;
else if (recipe2 != null) {
for (int i = 0; i < recipe2.getIngredients().size(); i++) {
Ingredient ingredient = recipe2.getIngredients().get(i);
//Looks for the best slot to take it from
ItemStack bestSlot = inventory.getStackInSlot(i);
if (ingredient.apply(bestSlot)) {
handleContainerItem(bestSlot);
bestSlot.shrink(1);
} else {
for (int j = 0; j < 9; j++) {
ItemStack stack = inventory.getStackInSlot(j);
if (ingredient.apply(stack)) {
handleContainerItem(stack);
stack.shrink(1); //TODO is this right? or do I need to use it as an actull crafting grid
break;
}
}
}
}
ItemStack output = inventory.getStackInSlot(9);
//TODO fire forge recipe event
ItemStack ouputStack = recipe2.getCraftingResult(getCraftingInventory());
if (output.isEmpty()) {
inventory.setInventorySlotContents(9, ouputStack.copy());
} else {
//TODO use ouputStack in someway?
output.grow(recipe2.getRecipeOutput().getCount());
}
return true;
}
ItemStack output = inventory.getStackInSlot(9);
//TODO fire forge recipe event
ItemStack ouputStack = recipe.getCraftingResult(getCraftingInventory());
if (output.isEmpty()) {
inventory.setInventorySlotContents(9, ouputStack.copy());
} else {
//TODO use ouputStack in someway?
output.grow(recipe.getRecipeOutput().getCount());
}
return true;
}
return false;
}

View file

@ -72,6 +72,8 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
/**
* Returns the number of ticks that the supplied fuel item will keep the
* furnace burning, or 0 if the item isn't fuel
* @param stack Itemstack of fuel
* @return Integer Number of ticks
*/
public static int getItemBurnTime(ItemStack stack) {
if (stack.isEmpty()) {
@ -273,6 +275,7 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
/**
* Furnace isBurning
* @return Boolean True if furnace is burning
*/
public boolean isBurning() {
return this.burnTime > 0;

View file

@ -235,9 +235,9 @@ public class TileIronFurnace extends TileLegacyMachineBase
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
return new ContainerBuilder("ironfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(this).slot(0, 56, 17).outputSlot(1, 116, 35).fuelSlot(2, 56, 53)
.syncIntegerValue(this::getBurnTime, this::setBurnTime)
.syncIntegerValue(this::getProgress, this::setProgress)
.syncIntegerValue(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(this);
.addInventory().tile(this).fuelSlot(2, 56, 53).slot(0, 56, 17).outputSlot(1, 116, 35)
.syncIntegerValue(this::getBurnTime, this::setBurnTime)
.syncIntegerValue(this::getProgress, this::setProgress)
.syncIntegerValue(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(this);
}
}

View file

@ -76,6 +76,7 @@ public class TileMachineCasing extends RectangularMultiblockTileEntityBase {
}
@Override
public MultiBlockCasing getMultiblockController() {
return (MultiBlockCasing) super.getMultiblockController();
}

View file

@ -143,6 +143,7 @@ public class TilePump extends TilePowerAcceptor {
readFromNBTWithoutCoords(tagCompound);
}
@Override
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
tank.readFromNBT(tagCompound);
}
@ -154,6 +155,7 @@ public class TilePump extends TilePowerAcceptor {
return tagCompound;
}
@Override
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
tank.writeToNBT(tagCompound);
return tagCompound;

View file

@ -114,7 +114,7 @@ public class TileRollingMachine extends TilePowerAcceptor
boolean hasCrafted = false;
if (this.inventory.getStackInSlot(outputSlot) == ItemStack.EMPTY) {
this.inventory.setInventorySlotContents(outputSlot, this.currentRecipe);
this.tickTime = -1;
this.tickTime = 0;
hasCrafted = true;
} else {
if (this.inventory.getStackInSlot(outputSlot).getCount() + this.currentRecipe.getCount() <= this.currentRecipe
@ -122,7 +122,7 @@ public class TileRollingMachine extends TilePowerAcceptor
final ItemStack stack = this.inventory.getStackInSlot(outputSlot);
stack.setCount(stack.getCount() + this.currentRecipe.getCount());
this.inventory.setInventorySlotContents(outputSlot, stack);
this.tickTime = -1;
this.tickTime = 0;
hasCrafted = true;
}
}
@ -136,13 +136,13 @@ public class TileRollingMachine extends TilePowerAcceptor
}
}
if (!this.currentRecipe.isEmpty()) {
if (this.canUseEnergy(energyPerTick) && this.tickTime < TileRollingMachine.runTime) {
if (this.canUseEnergy(energyPerTick) && this.tickTime < TileRollingMachine.runTime && canMake()) {
this.useEnergy(energyPerTick);
this.tickTime++;
}
}
if (this.currentRecipe.isEmpty()) {
this.tickTime = -1;
this.tickTime = 0;
}
} else {
this.currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(this.craftMatrix, this.world);
@ -155,7 +155,15 @@ public class TileRollingMachine extends TilePowerAcceptor
}
public boolean canMake() {
return RollingMachineRecipe.instance.findMatchingRecipe(this.craftMatrix, this.world) != null;
ItemStack stack = RollingMachineRecipe.instance.findMatchingRecipe(this.craftMatrix, this.world);
if(stack.isEmpty()){
return false;
}
ItemStack output = getStackInSlot(outputSlot);
if(output.isEmpty()){
return true;
}
return ItemUtils.isItemEqual(stack, output, true, true);
}
@Override

View file

@ -169,6 +169,11 @@ public class TileFusionControlComputer extends TilePowerAcceptor implements IToo
private boolean isCoil(final int x, final int y, final int z) {
return this.world.getBlockState(new BlockPos(x, y, z)).getBlock() == ModBlocks.FUSION_COIL;
}
@Override
public void onLoad() {
this.checkCoils();
}
@Override
public void update() {

View file

@ -92,11 +92,13 @@ public class TileInterdimensionalSU extends TileEnergyStorage implements IContai
return input <= IDSUManager.getData(world).getStoredPower();
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
this.ownerUdid = nbttagcompound.getString("ownerUdid");
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid)) {

View file

@ -29,6 +29,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.RebornCoreConfig;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
import techreborn.blocks.storage.BlockLapotronicSU;
@ -89,7 +90,7 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro
}
}
}
this.maxStorage = ((connectedBlocks + 1) * storagePerBlock);
setMaxStorage();
this.maxOutput = (connectedBlocks * extraIOPerBlock) + baseOutput;
}
@ -110,12 +111,22 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro
this.maxOutput = output;
}
public int getMaxStorage() {
return this.maxStorage;
public int getConnectedBlocksNum() {
return this.connectedBlocks;
}
public void setMaxStorage(int value) {
this.maxStorage = value;
public void setConnectedBlocksNum(int value) {
this.connectedBlocks = value;
if (world.isRemote) {
setMaxStorage();
}
}
public void setMaxStorage(){
this.maxStorage = (this.connectedBlocks + 1) * storagePerBlock;
if (this.maxStorage < 0 || this.maxStorage > Integer.MAX_VALUE / RebornCoreConfig.euPerFU) {
this.maxStorage = Integer.MAX_VALUE / RebornCoreConfig.euPerFU;
}
}
@Override
@ -123,6 +134,6 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro
return new ContainerBuilder("lesu").player(player.inventory).inventory().hotbar().armor().complete(8, 18)
.addArmor().addInventory().tile(this).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue()
.syncIntegerValue(this::getOutputRate, this::setOutputRate)
.syncIntegerValue(this::getMaxStorage, this::setMaxStorage).addInventory().create(this);
.syncIntegerValue(this::getConnectedBlocksNum, this::setConnectedBlocksNum).addInventory().create(this);
}
}

View file

@ -37,6 +37,7 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
@ -44,7 +45,9 @@ import techreborn.client.container.IContainerProvider;
import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileDistillationTower extends TilePowerAcceptor
implements IToolDrop, IRecipeCrafterProvider, IInventoryProvider, IContainerProvider {

View file

@ -34,15 +34,24 @@ import reborncore.api.tile.IInventoryProvider;
import reborncore.api.IToolDrop;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.client.container.IContainerProvider;
import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileImplosionCompressor extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
@ConfigRegistry(config = "machines", category = "implosion_compressor", key = "ImplosionCompressorMaxInput", comment = "Implosion Compressor Max Input (Value in EU)")
public static int maxInput = 64;
@ConfigRegistry(config = "machines", category = "implosion_compressor", key = "ImplosionCompressorMaxEnergy", comment = "Implosion Compressor Max Energy (Value in EU)")
public static int maxEnergy = 64000;
public Inventory inventory = new Inventory(5, "TileImplosionCompressor", 64, this);
public MultiblockChecker multiblockChecker;
@ -119,7 +128,7 @@ public class TileImplosionCompressor extends TilePowerAcceptor
@Override
public double getBaseMaxPower() {
return 64000;
return maxEnergy;
}
@Override
@ -139,7 +148,7 @@ public class TileImplosionCompressor extends TilePowerAcceptor
@Override
public double getBaseMaxInput() {
return 64;
return maxInput;
}
@Override

View file

@ -40,6 +40,8 @@ import reborncore.api.IToolDrop;
import reborncore.common.multiblock.IMultiblockPart;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.api.recipe.ITileRecipeHandler;
@ -49,11 +51,18 @@ import techreborn.client.container.IContainerProvider;
import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import techreborn.multiblocks.MultiBlockCasing;
import techreborn.tiles.TileMachineCasing;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileIndustrialBlastFurnace extends TilePowerAcceptor implements IToolDrop, IInventoryProvider,
ITileRecipeHandler<BlastFurnaceRecipe>, IRecipeCrafterProvider, IContainerProvider {
@ConfigRegistry(config = "machines", category = "industrial_furnace", key = "IndustrialFurnaceMaxInput", comment = "Industrial Blast Furnace Max Input (Value in EU)")
public static int maxInput = 128;
@ConfigRegistry(config = "machines", category = "industrial_furnace", key = "IndustrialFurnaceMaxEnergy", comment = "Industrial Blast Furnace Max Energy (Value in EU)")
public static int maxEnergy = 10000;
public Inventory inventory;
public RecipeCrafter crafter;
@ -62,14 +71,9 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor implements ITo
public TileIndustrialBlastFurnace() {
super();
// TODO configs
this.inventory = new Inventory(5, "TileIndustrialBlastFurnace", 64, this);
final int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
final int[] outputs = new int[2];
outputs[0] = 2;
outputs[1] = 3;
final int[] inputs = new int[] { 0, 1 };
final int[] outputs = new int[] { 2, 3 };
this.crafter = new RecipeCrafter(Reference.blastFurnaceRecipe, this, 2, 2, this.inventory, inputs, outputs);
}
@ -194,7 +198,7 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor implements ITo
@Override
public double getBaseMaxPower() {
return 10000;
return maxEnergy;
}
@Override
@ -214,7 +218,7 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor implements ITo
@Override
public double getBaseMaxInput() {
return 128;
return maxInput;
}
@Override

View file

@ -40,6 +40,8 @@ import reborncore.api.tile.IInventoryProvider;
import reborncore.api.IToolDrop;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
@ -50,11 +52,18 @@ import techreborn.client.container.IContainerProvider;
import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileIndustrialGrinder extends TilePowerAcceptor implements IToolDrop, IInventoryProvider,
ITileRecipeHandler<IndustrialGrinderRecipe>, IRecipeCrafterProvider, IContainerProvider {
@ConfigRegistry(config = "machines", category = "industrial_grinder", key = "IndustrialGrinderMaxInput", comment = "Industrial Grinder Max Input (Value in EU)")
public static int maxInput = 128;
@ConfigRegistry(config = "machines", category = "industrial_grinder", key = "IndustrialGrinderMaxEnergy", comment = "Industrial Grinder Max Energy (Value in EU)")
public static int maxEnergy = 10000;
public static final int TANK_CAPACITY = 16000;
public Inventory inventory;
public Tank tank;
public RecipeCrafter crafter;
@ -63,19 +72,11 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IToolDro
public TileIndustrialGrinder() {
super();
// TODO configs
tank = new Tank("TileIndustrialGrinder", TileIndustrialGrinder.TANK_CAPACITY, this);
inventory = new Inventory(8, "TileIndustrialGrinder", 64, this);
ticksSinceLastChange = 0;
final int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
final int[] outputs = new int[4];
outputs[0] = 2;
outputs[1] = 3;
outputs[2] = 4;
outputs[3] = 5;
this.tank = new Tank("TileIndustrialGrinder", TileIndustrialGrinder.TANK_CAPACITY, this);
this.inventory = new Inventory(8, "TileIndustrialGrinder", 64, this);
this.ticksSinceLastChange = 0;
final int[] inputs = new int[] { 0, 1 };
final int[] outputs = new int[] {2, 3, 4, 5};
this.crafter = new RecipeCrafter(Reference.industrialGrinderRecipe, this, 1, 4, this.inventory, inputs,
outputs);
}
@ -192,7 +193,7 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IToolDro
@Override
public double getBaseMaxPower() {
return 10000;
return maxEnergy;
}
@Override
@ -212,7 +213,7 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IToolDro
@Override
public double getBaseMaxInput() {
return 64;
return maxInput;
}
@Override

View file

@ -69,14 +69,13 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I
super.update();
if (!inventory.getStackInSlot(0).isEmpty()) {
ItemStack stack = inventory.getStackInSlot(0);
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
return;
}
IEnergyItemInfo item = (IEnergyItemInfo) inventory.getStackInSlot(0).getItem();
if (PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack)) {
if (canUseEnergy(item.getMaxTransfer(stack))) {
useEnergy(item.getMaxTransfer(stack));
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) + item.getMaxTransfer(stack), stack);
if (stack.getItem() instanceof IEnergyItemInfo) {
IEnergyItemInfo item = (IEnergyItemInfo) inventory.getStackInSlot(0).getItem();
if (PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack)) {
if (canUseEnergy(item.getMaxTransfer(stack))) {
useEnergy(item.getMaxTransfer(stack));
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) + item.getMaxTransfer(stack), stack);
}
}
}
if(CompatManager.isIC2Loaded){

View file

@ -34,15 +34,22 @@ import reborncore.api.IListInfoProvider;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.IToolDrop;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.util.StringUtils;
import techreborn.blocks.transformers.BlockTransformer;
import techreborn.lib.ModInfo;
import java.util.List;
/**
* Created by Rushmead
*/
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileTransformer extends TilePowerAcceptor implements IToolDrop, ITickable, IListInfoProvider {
@ConfigRegistry(config = "misc", category = "general", key = "IC2TransformersStyle", comment = "Input from dots side, output from other sides, like in IC2.")
public static boolean IC2TransformersStyle = false;
public String name;
public Block wrenchDrop;
@ -79,7 +86,9 @@ public class TileTransformer extends TilePowerAcceptor implements IToolDrop, ITi
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
if (IC2TransformersStyle == true){
return getFacingEnum() == direction;
}
return getFacingEnum() != direction;
}
@ -94,6 +103,9 @@ public class TileTransformer extends TilePowerAcceptor implements IToolDrop, ITi
@Override
public boolean canProvideEnergy(EnumFacing direction) {
if (IC2TransformersStyle == true){
return getFacingEnum() != direction;
}
return getFacing() == direction;
}