Merge remote-tracking branch 'origin/1.16' into 1.16
# Conflicts: # src/main/java/techreborn/init/TRContent.java
This commit is contained in:
commit
18a08b798e
235 changed files with 3995 additions and 3065 deletions
|
@ -49,7 +49,7 @@ repositories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "3.4.2"
|
version = "3.4.3"
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
shade
|
shade
|
||||||
|
@ -80,7 +80,7 @@ dependencies {
|
||||||
//Fabric api
|
//Fabric api
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:0.16.0+build.384-1.16.1"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:0.16.0+build.384-1.16.1"
|
||||||
|
|
||||||
optionalDependency ("me.shedaniel:RoughlyEnoughItems:4.5.4")
|
optionalDependency ("me.shedaniel:RoughlyEnoughItems:4.10.2")
|
||||||
disabledOptionalDependency ('io.github.cottonmc:LibCD:2.4.1+1.15.2')
|
disabledOptionalDependency ('io.github.cottonmc:LibCD:2.4.1+1.15.2')
|
||||||
disabledOptionalDependency ('com.github.emilyploszaj:trinkets:2.6.0')
|
disabledOptionalDependency ('com.github.emilyploszaj:trinkets:2.6.0')
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,7 @@ public class TechRebornClient implements ClientModInitializer {
|
||||||
BlockRenderLayerMap.INSTANCE.putBlock(TRContent.Machine.ALARM.block, RenderLayer.getCutout());
|
BlockRenderLayerMap.INSTANCE.putBlock(TRContent.Machine.ALARM.block, RenderLayer.getCutout());
|
||||||
BlockRenderLayerMap.INSTANCE.putBlock(TRContent.RUBBER_SAPLING, RenderLayer.getCutout());
|
BlockRenderLayerMap.INSTANCE.putBlock(TRContent.RUBBER_SAPLING, RenderLayer.getCutout());
|
||||||
BlockRenderLayerMap.INSTANCE.putBlock(TRContent.REINFORCED_GLASS, RenderLayer.getCutout());
|
BlockRenderLayerMap.INSTANCE.putBlock(TRContent.REINFORCED_GLASS, RenderLayer.getCutout());
|
||||||
|
BlockRenderLayerMap.INSTANCE.putBlock(TRContent.Machine.RESIN_BASIN.block, RenderLayer.getCutout());
|
||||||
|
|
||||||
BlockRenderLayerMap.INSTANCE.putBlock(TRContent.RUBBER_LEAVES, RenderLayer.getCutoutMipped());
|
BlockRenderLayerMap.INSTANCE.putBlock(TRContent.RUBBER_LEAVES, RenderLayer.getCutoutMipped());
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public enum EFluidGenerator {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final String recipeID;
|
private final String recipeID;
|
||||||
|
|
||||||
private EFluidGenerator(@Nonnull String recipeID) {
|
EFluidGenerator(@Nonnull String recipeID) {
|
||||||
this.recipeID = recipeID;
|
this.recipeID = recipeID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,6 @@ public class FluidGeneratorRecipe {
|
||||||
return false;
|
return false;
|
||||||
} else if (!FluidUtils.fluidEquals(other.fluid, fluid))
|
} else if (!FluidUtils.fluidEquals(other.fluid, fluid))
|
||||||
return false;
|
return false;
|
||||||
if (generatorType != other.generatorType)
|
return generatorType == other.generatorType;
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,10 +83,7 @@ public class FluidGeneratorRecipeList {
|
||||||
return false;
|
return false;
|
||||||
FluidGeneratorRecipeList other = (FluidGeneratorRecipeList) obj;
|
FluidGeneratorRecipeList other = (FluidGeneratorRecipeList) obj;
|
||||||
if (recipes == null) {
|
if (recipes == null) {
|
||||||
if (other.recipes != null)
|
return other.recipes == null;
|
||||||
return false;
|
} else return recipes.equals(other.recipes);
|
||||||
} else if (!recipes.equals(other.recipes))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
package techreborn.api.generator;
|
package techreborn.api.generator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
|
|
@ -34,7 +34,6 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ScrapboxRecipeCrafter extends RecipeCrafter {
|
public class ScrapboxRecipeCrafter extends RecipeCrafter {
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class FluidReplicatorRecipe extends RebornFluidRecipe {
|
||||||
@Override
|
@Override
|
||||||
public boolean canCraft(BlockEntity be) {
|
public boolean canCraft(BlockEntity be) {
|
||||||
FluidReplicatorBlockEntity blockEntity = (FluidReplicatorBlockEntity) be;
|
FluidReplicatorBlockEntity blockEntity = (FluidReplicatorBlockEntity) be;
|
||||||
if (!blockEntity.getMultiBlock()) {
|
if (!blockEntity.isMultiblockValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final BlockPos hole = blockEntity.getPos().offset(blockEntity.getFacing().getOpposite(), 2);
|
final BlockPos hole = blockEntity.getPos().offset(blockEntity.getFacing().getOpposite(), 2);
|
||||||
|
|
|
@ -37,7 +37,6 @@ import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class FusionReactorRecipe extends RebornRecipe {
|
public class FusionReactorRecipe extends RebornRecipe {
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class IndustrialGrinderRecipe extends RebornFluidRecipe {
|
||||||
@Override
|
@Override
|
||||||
public boolean canCraft(BlockEntity be) {
|
public boolean canCraft(BlockEntity be) {
|
||||||
IndustrialGrinderBlockEntity blockEntity = (IndustrialGrinderBlockEntity) be;
|
IndustrialGrinderBlockEntity blockEntity = (IndustrialGrinderBlockEntity) be;
|
||||||
if (!blockEntity.getMultiBlock()) {
|
if (!blockEntity.isMultiblockValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return super.canCraft(be);
|
return super.canCraft(be);
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class IndustrialSawmillRecipe extends RebornFluidRecipe {
|
||||||
@Override
|
@Override
|
||||||
public boolean canCraft(BlockEntity be) {
|
public boolean canCraft(BlockEntity be) {
|
||||||
IndustrialSawmillBlockEntity blockEntity = (IndustrialSawmillBlockEntity) be;
|
IndustrialSawmillBlockEntity blockEntity = (IndustrialSawmillBlockEntity) be;
|
||||||
if (!blockEntity.getMutliBlock()) {
|
if (!blockEntity.isMultiblockValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return super.canCraft(be);
|
return super.canCraft(be);
|
||||||
|
|
|
@ -143,13 +143,27 @@ public class CableBlockEntity extends BlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Pair<BlockEntity, Direction>> acceptors = new ArrayList<>();
|
ArrayList<Pair<BlockEntity, Direction>> acceptors = new ArrayList<>();
|
||||||
|
ArrayList<CableBlockEntity> cables = new ArrayList<>();
|
||||||
|
|
||||||
for (Direction face : Direction.values()) {
|
for (Direction face : Direction.values()) {
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos.offset(face));
|
BlockEntity blockEntity = world.getBlockEntity(pos.offset(face));
|
||||||
|
|
||||||
if (blockEntity != null && Energy.valid(blockEntity)) {
|
if (blockEntity != null && Energy.valid(blockEntity)) {
|
||||||
if (blockEntity instanceof CableBlockEntity && energy <= Energy.of(blockEntity).side(face).getEnergy()) {
|
if (blockEntity instanceof CableBlockEntity ) {
|
||||||
|
CableBlockEntity cableBlockEntity = (CableBlockEntity)blockEntity;
|
||||||
|
|
||||||
|
if(cableBlockEntity.getTier() == this.getTier()) {
|
||||||
|
// Only need ones with energy stores less than ours
|
||||||
|
if (cableBlockEntity.getEnergy() < this.getEnergy()) {
|
||||||
|
cables.add(cableBlockEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}else if(energy <= Energy.of(blockEntity).side(face).getEnergy()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(Energy.of(blockEntity).side(face.getOpposite()).getMaxInput() > 0){
|
if(Energy.of(blockEntity).side(face.getOpposite()).getMaxInput() > 0){
|
||||||
acceptors.add(Pair.of(blockEntity, face));
|
acceptors.add(Pair.of(blockEntity, face));
|
||||||
if (!sendingFace.contains(face)) {
|
if (!sendingFace.contains(face)) {
|
||||||
|
@ -159,9 +173,7 @@ public class CableBlockEntity extends BlockEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (acceptors.isEmpty()) {
|
if (!acceptors.isEmpty()) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
Collections.shuffle(acceptors);
|
Collections.shuffle(acceptors);
|
||||||
|
|
||||||
acceptors.forEach(pair -> {
|
acceptors.forEach(pair -> {
|
||||||
|
@ -171,6 +183,19 @@ public class CableBlockEntity extends BlockEntity
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Distribute energy between cables (TODO DIRTY FIX, until we game network cables)
|
||||||
|
|
||||||
|
if(!cables.isEmpty()) {
|
||||||
|
|
||||||
|
cables.add(this);
|
||||||
|
double energyTotal = cables.stream().mapToDouble(CableBlockEntity::getEnergy).sum();
|
||||||
|
double energyPer = energyTotal / cables.size();
|
||||||
|
|
||||||
|
cables.forEach(cableBlockEntity -> cableBlockEntity.setEnergy(energyPer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// IListInfoProvider
|
// IListInfoProvider
|
||||||
@Override
|
@Override
|
||||||
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
||||||
|
@ -223,6 +248,25 @@ public class CableBlockEntity extends BlockEntity
|
||||||
return energyOut;
|
return energyOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double addEnergy(double energyIn) {
|
||||||
|
if(this.isFull()){
|
||||||
|
return energyIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
double maxStore = this.getMaxStoredPower();
|
||||||
|
|
||||||
|
if (energyIn + energy <= maxStore) {
|
||||||
|
setEnergy(energyIn + energy);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't fit energy fully, add part of it
|
||||||
|
double amountCanAdd = (maxStore - energy);
|
||||||
|
setEnergy(amountCanAdd + energy);
|
||||||
|
|
||||||
|
return energyIn - amountCanAdd;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canAcceptEnergy(EnergySide direction) {
|
public boolean canAcceptEnergy(EnergySide direction) {
|
||||||
if (sendingFace.contains(direction)) {
|
if (sendingFace.contains(direction)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -230,6 +274,10 @@ public class CableBlockEntity extends BlockEntity
|
||||||
return getMaxStoredPower() != getEnergy();
|
return getMaxStoredPower() != getEnergy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFull(){
|
||||||
|
return getMaxStoredPower() == getEnergy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxInput(EnergySide side) {
|
public double getMaxInput(EnergySide side) {
|
||||||
if(!canAcceptEnergy(side)) {
|
if(!canAcceptEnergy(side)) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ public enum SlotType {
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BiConsumer<BlockEntityScreenHandlerBuilder, DataDrivenSlot> slotBiConsumer;
|
private final BiConsumer<BlockEntityScreenHandlerBuilder, DataDrivenSlot> slotBiConsumer;
|
||||||
|
|
||||||
SlotType(BiConsumer<BlockEntityScreenHandlerBuilder, DataDrivenSlot> slotBiConsumer) {
|
SlotType(BiConsumer<BlockEntityScreenHandlerBuilder, DataDrivenSlot> slotBiConsumer) {
|
||||||
this.slotBiConsumer = slotBiConsumer;
|
this.slotBiConsumer = slotBiConsumer;
|
||||||
|
|
|
@ -89,8 +89,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
||||||
if (!inputStack.isEmpty()) {
|
if (!inputStack.isEmpty()) {
|
||||||
if (FluidUtils.isContainerEmpty(inputStack) && !tank.getFluidAmount().isEmpty()) {
|
if (FluidUtils.isContainerEmpty(inputStack) && !tank.getFluidAmount().isEmpty()) {
|
||||||
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid());
|
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid());
|
||||||
}
|
} else if (inputStack.getItem() instanceof ItemFluidInfo && getRecipes().getRecipeForFluid(((ItemFluidInfo) inputStack.getItem()).getFluid(inputStack)).isPresent()) {
|
||||||
else if (inputStack.getItem() instanceof ItemFluidInfo && getRecipes().getRecipeForFluid(((ItemFluidInfo) inputStack.getItem()).getFluid(inputStack)).isPresent()) {
|
|
||||||
FluidUtils.drainContainers(tank, inventory, 0, 1);
|
FluidUtils.drainContainers(tank, inventory, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,8 +117,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
||||||
|
|
||||||
if (world.getTime() - lastOutput < 30 && !isActive()) {
|
if (world.getTime() - lastOutput < 30 && !isActive()) {
|
||||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
|
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
|
||||||
}
|
} else if (world.getTime() - lastOutput > 30 && isActive()) {
|
||||||
else if (world.getTime() - lastOutput > 30 && isActive()) {
|
|
||||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
|
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,9 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
if (onStatusHoldTicks > 0) { --onStatusHoldTicks; }
|
if (onStatusHoldTicks > 0) {
|
||||||
|
--onStatusHoldTicks;
|
||||||
|
}
|
||||||
|
|
||||||
Block BEBlock = getCachedState().getBlock();
|
Block BEBlock = getCachedState().getBlock();
|
||||||
if (!(BEBlock instanceof BlockMachineBase)) {
|
if (!(BEBlock instanceof BlockMachineBase)) {
|
||||||
|
@ -83,7 +85,7 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
lightningBolt.method_29495(Vec3d.ofBottomCenter(world.getTopPosition(Heightmap.Type.MOTION_BLOCKING, getPos())));
|
lightningBolt.method_29495(Vec3d.ofBottomCenter(world.getTopPosition(Heightmap.Type.MOTION_BLOCKING, getPos())));
|
||||||
|
|
||||||
if (!world.isClient) {
|
if (!world.isClient) {
|
||||||
((ServerWorld) world).spawnEntity(lightningBolt);
|
world.spawnEntity(lightningBolt);
|
||||||
}
|
}
|
||||||
addEnergy(TechRebornConfig.lightningRodBaseEnergyStrike * (0.3F + weatherStrength));
|
addEnergy(TechRebornConfig.lightningRodBaseEnergyStrike * (0.3F + weatherStrength));
|
||||||
machineBaseBlock.setActive(true, world, pos);
|
machineBaseBlock.setActive(true, world, pos);
|
||||||
|
@ -110,10 +112,7 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
|
|
||||||
public boolean isValidIronFence(int y) {
|
public boolean isValidIronFence(int y) {
|
||||||
Block block = this.world.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock();
|
Block block = this.world.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock();
|
||||||
if(block == TRContent.REFINED_IRON_FENCE){
|
return block == TRContent.REFINED_IRON_FENCE;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,7 +26,6 @@ package techreborn.blockentity.generator;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
|
@ -55,8 +55,7 @@ public class WaterMillBlockEntity extends PowerAcceptorBlockEntity implements IT
|
||||||
if (waterblocks > 0) {
|
if (waterblocks > 0) {
|
||||||
addEnergy(waterblocks * TechRebornConfig.waterMillEnergyMultiplier);
|
addEnergy(waterblocks * TechRebornConfig.waterMillEnergyMultiplier);
|
||||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
|
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
|
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import techreborn.init.TRBlockEntities;
|
||||||
public class LampBlockEntity extends PowerAcceptorBlockEntity
|
public class LampBlockEntity extends PowerAcceptorBlockEntity
|
||||||
implements IToolDrop {
|
implements IToolDrop {
|
||||||
|
|
||||||
private static int capacity = 33;
|
private static final int capacity = 33;
|
||||||
|
|
||||||
public LampBlockEntity() {
|
public LampBlockEntity() {
|
||||||
super(TRBlockEntities.LAMP);
|
super(TRBlockEntities.LAMP);
|
||||||
|
|
|
@ -38,7 +38,6 @@ import reborncore.common.util.RebornInventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
implements IToolDrop, InventoryProvider, IRecipeCrafterProvider {
|
implements IToolDrop, InventoryProvider, IRecipeCrafterProvider {
|
||||||
|
@ -79,7 +78,7 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (!world.isClient) {
|
if (!world.isClient && energySlot != -1) {
|
||||||
charge(energySlot);
|
charge(energySlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that we have all inputs and can put output into slot
|
* Checks that we have all inputs and can put output into slot
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract boolean canSmelt();
|
protected abstract boolean canSmelt();
|
||||||
|
@ -73,6 +74,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
||||||
/**
|
/**
|
||||||
* Returns the number of ticks that the supplied fuel item will keep the
|
* Returns the number of ticks that the supplied fuel item will keep the
|
||||||
* furnace burning, or 0 if the item isn't fuel
|
* furnace burning, or 0 if the item isn't fuel
|
||||||
|
*
|
||||||
* @param stack Itemstack of fuel
|
* @param stack Itemstack of fuel
|
||||||
* @return Integer Number of ticks
|
* @return Integer Number of ticks
|
||||||
*/
|
*/
|
||||||
|
@ -85,6 +87,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns remaining fraction of fuel burn time
|
* Returns remaining fraction of fuel burn time
|
||||||
|
*
|
||||||
* @param scale Scale to use for burn time
|
* @param scale Scale to use for burn time
|
||||||
* @return int scaled remaining fuel burn time
|
* @return int scaled remaining fuel burn time
|
||||||
*/
|
*/
|
||||||
|
@ -98,6 +101,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns crafting progress
|
* Returns crafting progress
|
||||||
|
*
|
||||||
* @param scale Scale to use for crafting progress
|
* @param scale Scale to use for crafting progress
|
||||||
* @return int Scaled crafting progress
|
* @return int Scaled crafting progress
|
||||||
*/
|
*/
|
||||||
|
@ -110,6 +114,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if Iron Machine is burning fuel thus can do work
|
* Returns true if Iron Machine is burning fuel thus can do work
|
||||||
|
*
|
||||||
* @return Boolean True if machine is burning
|
* @return Boolean True if machine is burning
|
||||||
*/
|
*/
|
||||||
public boolean isBurning() {
|
public boolean isBurning() {
|
||||||
|
|
|
@ -24,12 +24,12 @@
|
||||||
|
|
||||||
package techreborn.blockentity.machine.multiblock;
|
package techreborn.blockentity.machine.multiblock;
|
||||||
|
|
||||||
import net.minecraft.block.Material;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.Direction;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
import reborncore.common.blockentity.MultiblockWriter;
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
@ -41,8 +41,6 @@ import techreborn.init.TRContent;
|
||||||
|
|
||||||
public class DistillationTowerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
public class DistillationTowerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
public MultiblockChecker multiblockChecker;
|
|
||||||
|
|
||||||
public DistillationTowerBlockEntity() {
|
public DistillationTowerBlockEntity() {
|
||||||
super(TRBlockEntities.DISTILLATION_TOWER, "DistillationTower", TechRebornConfig.distillationTowerMaxInput, TechRebornConfig.distillationTowerMaxEnergy, TRContent.Machine.DISTILLATION_TOWER.block, 6);
|
super(TRBlockEntities.DISTILLATION_TOWER, "DistillationTower", TechRebornConfig.distillationTowerMaxInput, TechRebornConfig.distillationTowerMaxEnergy, TRContent.Machine.DISTILLATION_TOWER.block, 6);
|
||||||
final int[] inputs = new int[]{0, 1};
|
final int[] inputs = new int[]{0, 1};
|
||||||
|
@ -51,30 +49,13 @@ public class DistillationTowerBlockEntity extends GenericMachineBlockEntity impl
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.DISTILLATION_TOWER, this, 2, 4, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.DISTILLATION_TOWER, this, 2, 4, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getMutliBlock() {
|
|
||||||
if (multiblockChecker == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final boolean layer0 = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET);
|
|
||||||
final boolean layer1 = multiblockChecker.checkRingY(1, 1, MultiblockChecker.INDUSTRIAL_CASING, new BlockPos(0, 1, 0));
|
|
||||||
final boolean layer2 = multiblockChecker.checkRingY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0));
|
|
||||||
final boolean layer3 = multiblockChecker.checkRectY(1, 1, MultiblockChecker.INDUSTRIAL_CASING, new BlockPos(0, 3, 0));
|
|
||||||
final Material centerBlock1 = multiblockChecker.getBlock(0, 1, 0).getMaterial();
|
|
||||||
final Material centerBlock2 = multiblockChecker.getBlock(0, 2, 0).getMaterial();
|
|
||||||
final boolean center1 = (centerBlock1 == Material.AIR);
|
|
||||||
final boolean center2 = (centerBlock2 == Material.AIR);
|
|
||||||
return layer0 && layer1 && layer2 && layer3 && center1 && center2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TileGenericMachine
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
if (multiblockChecker == null) {
|
writer.translate(1, 0, -1)
|
||||||
final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2);
|
.fill(0, 0, 0, 3, 1, 3, TRContent.MachineBlocks.BASIC.getCasing().getDefaultState())
|
||||||
multiblockChecker = new MultiblockChecker(world, downCenter);
|
.ringWithAir(Direction.Axis.Y, 3, 1, 3, TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState())
|
||||||
}
|
.ringWithAir(Direction.Axis.Y, 3, 2, 3, TRContent.MachineBlocks.BASIC.getCasing().getDefaultState())
|
||||||
|
.fill(0, 3, 0, 3, 4, 3, TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState());
|
||||||
super.tick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IContainerProvider
|
// IContainerProvider
|
||||||
|
@ -88,6 +69,6 @@ public class DistillationTowerBlockEntity extends GenericMachineBlockEntity impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canCraft(RebornRecipe rebornRecipe) {
|
public boolean canCraft(RebornRecipe rebornRecipe) {
|
||||||
return getMutliBlock();
|
return isMultiblockValid();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,10 +27,11 @@ package techreborn.blockentity.machine.multiblock;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.Direction;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
import reborncore.common.blockentity.MultiblockWriter;
|
||||||
import reborncore.common.fluid.FluidValue;
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.IInventoryAccess;
|
import reborncore.common.util.IInventoryAccess;
|
||||||
|
@ -47,11 +48,9 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
public MultiblockChecker multiblockChecker;
|
|
||||||
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
|
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
|
||||||
public Tank tank;
|
public Tank tank;
|
||||||
int ticksSinceLastChange;
|
int ticksSinceLastChange;
|
||||||
|
@ -63,23 +62,16 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
|
||||||
this.tank = new Tank("FluidReplicatorBlockEntity", FluidReplicatorBlockEntity.TANK_CAPACITY, this);
|
this.tank = new Tank("FluidReplicatorBlockEntity", FluidReplicatorBlockEntity.TANK_CAPACITY, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getMultiBlock() {
|
@Override
|
||||||
if (multiblockChecker == null) {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
return false;
|
BlockState state = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||||
}
|
writer.translate(1, 0, -1)
|
||||||
final boolean ring = multiblockChecker.checkRingY(1, 1, MultiblockChecker.ADVANCED_CASING,
|
.ring(Direction.Axis.Y, 3, 0, 3, (v, p) -> v.getBlockState(p) == state, state, null, null);
|
||||||
MultiblockChecker.ZERO_OFFSET);
|
|
||||||
return ring;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TileGenericMachine
|
// TileGenericMachine
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (multiblockChecker == null) {
|
|
||||||
final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2);
|
|
||||||
multiblockChecker = new MultiblockChecker(world, downCenter);
|
|
||||||
}
|
|
||||||
|
|
||||||
ticksSinceLastChange++;
|
ticksSinceLastChange++;
|
||||||
// Check cells input slot 2 time per second
|
// Check cells input slot 2 time per second
|
||||||
if (!world.isClient && ticksSinceLastChange >= 10) {
|
if (!world.isClient && ticksSinceLastChange >= 10) {
|
||||||
|
@ -95,7 +87,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecipeCrafter getRecipeCrafter() {
|
public RecipeCrafter getRecipeCrafter() {
|
||||||
return (RecipeCrafter) crafter;
|
return crafter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TilePowerAcceptor
|
// TilePowerAcceptor
|
||||||
|
|
|
@ -33,32 +33,27 @@ import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import reborncore.api.IToolDrop;
|
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
import reborncore.common.blockentity.MultiblockWriter;
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import reborncore.common.util.StringUtils;
|
import reborncore.common.util.StringUtils;
|
||||||
import reborncore.common.util.Torus;
|
import reborncore.common.util.Torus;
|
||||||
import techreborn.api.recipe.recipes.FusionReactorRecipe;
|
import techreborn.api.recipe.recipes.FusionReactorRecipe;
|
||||||
|
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.ModRecipes;
|
import techreborn.init.ModRecipes;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
import java.util.List;
|
public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
|
||||||
implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
|
|
||||||
|
|
||||||
public RebornInventory<FusionControlComputerBlockEntity> inventory;
|
public RebornInventory<FusionControlComputerBlockEntity> inventory;
|
||||||
|
|
||||||
public int coilCount = 0;
|
|
||||||
public int crafingTickTime = 0;
|
public int crafingTickTime = 0;
|
||||||
public int neededPower = 0;
|
public int neededPower = 0;
|
||||||
public int size = 6;
|
public int size = 6;
|
||||||
|
@ -73,36 +68,15 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
long lastTick = -1;
|
long lastTick = -1;
|
||||||
|
|
||||||
public FusionControlComputerBlockEntity() {
|
public FusionControlComputerBlockEntity() {
|
||||||
super(TRBlockEntities.FUSION_CONTROL_COMPUTER);
|
super(TRBlockEntities.FUSION_CONTROL_COMPUTER, "FusionControlComputer", -1, -1, TRContent.Machine.FUSION_CONTROL_COMPUTER.block, -1);
|
||||||
checkOverfill = false;
|
checkOverfill = false;
|
||||||
this.inventory = new RebornInventory<>(3, "FusionControlComputerBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(3, "FusionControlComputerBlockEntity", 64, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Check that reactor has all necessary coils in place
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
*
|
BlockState coil = TRContent.Machine.FUSION_COIL.block.getDefaultState();
|
||||||
* @return boolean Return true if coils are present
|
Torus.generate(BlockPos.ORIGIN, size).forEach(pos -> writer.add(pos.getX(), pos.getY(), pos.getZ(), coil));
|
||||||
*/
|
|
||||||
public boolean checkCoils() {
|
|
||||||
List<BlockPos> coils = Torus.generate(pos, size);
|
|
||||||
for(BlockPos coilPos : coils){
|
|
||||||
if (!isCoil(coilPos)) {
|
|
||||||
coilCount = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
coilCount = coils.size();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if block is fusion coil
|
|
||||||
*
|
|
||||||
* @param pos coordinate for block
|
|
||||||
* @return boolean Returns true if block is fusion coil
|
|
||||||
*/
|
|
||||||
public boolean isCoil(BlockPos pos) {
|
|
||||||
return world.getBlockState(pos).getBlock() == TRContent.Machine.FUSION_COIL.block;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,11 +219,10 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
|
|
||||||
// Force check every second
|
// Force check every second
|
||||||
if (world.getTime() % 20 == 0) {
|
if (world.getTime() % 20 == 0) {
|
||||||
checkCoils();
|
|
||||||
inventory.setChanged();
|
inventory.setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coilCount == 0) {
|
if (!isMultiblockValid()) {
|
||||||
resetCrafter();
|
resetCrafter();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -375,24 +348,11 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return tagCompound;
|
return tagCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TileLegacyMachineBase
|
|
||||||
@Override
|
|
||||||
public void onLoad() {
|
|
||||||
super.onLoad();
|
|
||||||
this.checkCoils();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBeUpgraded() {
|
public boolean canBeUpgraded() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IToolDrop
|
|
||||||
@Override
|
|
||||||
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
|
||||||
return TRContent.Machine.FUSION_CONTROL_COMPUTER.getStack();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ItemHandlerProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public RebornInventory<FusionControlComputerBlockEntity> getInventory() {
|
public RebornInventory<FusionControlComputerBlockEntity> getInventory() {
|
||||||
|
@ -404,7 +364,6 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("fusionreactor").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("fusionreactor").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).syncEnergyValue()
|
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).syncEnergyValue()
|
||||||
.sync(this::getCoilStatus, this::setCoilStatus)
|
|
||||||
.sync(this::getCrafingTickTime, this::setCrafingTickTime)
|
.sync(this::getCrafingTickTime, this::setCrafingTickTime)
|
||||||
.sync(this::getSize, this::setSize)
|
.sync(this::getSize, this::setSize)
|
||||||
.sync(this::getState, this::setState)
|
.sync(this::getState, this::setState)
|
||||||
|
@ -414,14 +373,6 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
.create(this, syncID);
|
.create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCoilStatus() {
|
|
||||||
return coilCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCoilStatus(int coilStatus) {
|
|
||||||
this.coilCount = coilStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCrafingTickTime() {
|
public int getCrafingTickTime() {
|
||||||
return crafingTickTime;
|
return crafingTickTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,11 @@
|
||||||
package techreborn.blockentity.machine.multiblock;
|
package techreborn.blockentity.machine.multiblock;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.Direction;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
import reborncore.common.blockentity.MultiblockWriter;
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
@ -40,8 +41,6 @@ import techreborn.init.TRContent;
|
||||||
|
|
||||||
public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
public MultiblockChecker multiblockChecker;
|
|
||||||
|
|
||||||
public ImplosionCompressorBlockEntity() {
|
public ImplosionCompressorBlockEntity() {
|
||||||
super(TRBlockEntities.IMPLOSION_COMPRESSOR, "ImplosionCompressor", TechRebornConfig.implosionCompressorMaxInput, TechRebornConfig.implosionCompressorMaxEnergy, TRContent.Machine.IMPLOSION_COMPRESSOR.block, 4);
|
super(TRBlockEntities.IMPLOSION_COMPRESSOR, "ImplosionCompressor", TechRebornConfig.implosionCompressorMaxInput, TechRebornConfig.implosionCompressorMaxEnergy, TRContent.Machine.IMPLOSION_COMPRESSOR.block, 4);
|
||||||
final int[] inputs = new int[]{0, 1};
|
final int[] inputs = new int[]{0, 1};
|
||||||
|
@ -50,24 +49,12 @@ public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity im
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.IMPLOSION_COMPRESSOR, this, 2, 2, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.IMPLOSION_COMPRESSOR, this, 2, 2, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getMutliBlock() {
|
|
||||||
if(multiblockChecker == null){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final boolean down = multiblockChecker.checkRectY(1, 1, MultiblockChecker.ADVANCED_CASING, MultiblockChecker.ZERO_OFFSET);
|
|
||||||
final boolean up = multiblockChecker.checkRectY(1, 1, MultiblockChecker.ADVANCED_CASING, new BlockPos(0, 2, 0));
|
|
||||||
final boolean chamber = multiblockChecker.checkRingYHollow(1, 1, MultiblockChecker.ADVANCED_CASING, new BlockPos(0, 1, 0));
|
|
||||||
return down && chamber && up;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TileGenericMachine
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
if (multiblockChecker == null) {
|
writer.translate(-1, -3, -1)
|
||||||
multiblockChecker = new MultiblockChecker(world, pos.down(3));
|
.fill(0, 0, 0, 3, 1, 3, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState())
|
||||||
}
|
.ringWithAir(Direction.Axis.Y, 3, 1, 3, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState())
|
||||||
|
.fill(0, 2, 0, 3, 3, 3, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState());
|
||||||
super.tick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IContainerProvider
|
// IContainerProvider
|
||||||
|
@ -80,6 +67,6 @@ public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity im
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canCraft(RebornRecipe rebornRecipe) {
|
public boolean canCraft(RebornRecipe rebornRecipe) {
|
||||||
return getMutliBlock();
|
return isMultiblockValid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,18 @@
|
||||||
|
|
||||||
package techreborn.blockentity.machine.multiblock;
|
package techreborn.blockentity.machine.multiblock;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
import reborncore.common.blockentity.MultiblockWriter;
|
||||||
import reborncore.common.multiblock.IMultiblockPart;
|
import reborncore.common.multiblock.IMultiblockPart;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
@ -44,9 +48,10 @@ import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
import techreborn.multiblocks.MultiBlockCasing;
|
import techreborn.multiblocks.MultiBlockCasing;
|
||||||
|
|
||||||
|
import java.util.function.BiPredicate;
|
||||||
|
|
||||||
public class IndustrialBlastFurnaceBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
public class IndustrialBlastFurnaceBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
public MultiblockChecker multiblockChecker;
|
|
||||||
private int cachedHeat;
|
private int cachedHeat;
|
||||||
|
|
||||||
public IndustrialBlastFurnaceBlockEntity() {
|
public IndustrialBlastFurnaceBlockEntity() {
|
||||||
|
@ -57,8 +62,32 @@ public class IndustrialBlastFurnaceBlockEntity extends GenericMachineBlockEntity
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.BLAST_FURNACE, this, 2, 2, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.BLAST_FURNACE, this, 2, 2, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
|
BlockState basic = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||||
|
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||||
|
BlockState industrial = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState();
|
||||||
|
BlockState lava = Blocks.LAVA.getDefaultState();
|
||||||
|
|
||||||
|
BiPredicate<BlockView, BlockPos> casing = (view, pos) -> {
|
||||||
|
BlockState state = view.getBlockState(pos);
|
||||||
|
return basic == state || advanced == state || industrial == state;
|
||||||
|
};
|
||||||
|
|
||||||
|
BiPredicate<BlockView, BlockPos> maybeLava = (view, pos) -> {
|
||||||
|
BlockState state = view.getBlockState(pos);
|
||||||
|
return state == lava || state.getBlock() == Blocks.AIR;
|
||||||
|
};
|
||||||
|
|
||||||
|
writer.translate(1, 0, -1)
|
||||||
|
.fill(0, 0, 0, 3, 1, 3, casing, basic)
|
||||||
|
.ring(Direction.Axis.Y, 3, 1, 3, casing, basic, maybeLava, lava)
|
||||||
|
.ring(Direction.Axis.Y, 3, 2, 3, casing, basic, maybeLava, lava)
|
||||||
|
.fill(0, 3, 0, 3, 4, 3, casing, basic);
|
||||||
|
}
|
||||||
|
|
||||||
public int getHeat() {
|
public int getHeat() {
|
||||||
if (!getMutliBlock()){
|
if (!isMultiblockValid()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,21 +123,6 @@ public class IndustrialBlastFurnaceBlockEntity extends GenericMachineBlockEntity
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getMutliBlock() {
|
|
||||||
if(multiblockChecker == null){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final boolean layer0 = multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_ANY, MultiblockChecker.ZERO_OFFSET);
|
|
||||||
final boolean layer1 = multiblockChecker.checkRingY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 1, 0));
|
|
||||||
final boolean layer2 = multiblockChecker.checkRingY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 2, 0));
|
|
||||||
final boolean layer3 = multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 3, 0));
|
|
||||||
final Material centerBlock1 = multiblockChecker.getBlock(0, 1, 0).getMaterial();
|
|
||||||
final Material centerBlock2 = multiblockChecker.getBlock(0, 2, 0).getMaterial();
|
|
||||||
final boolean center1 = (centerBlock1 == Material.AIR || centerBlock1 == Material.LAVA);
|
|
||||||
final boolean center2 = (centerBlock2 == Material.AIR || centerBlock2 == Material.LAVA);
|
|
||||||
return layer0 && layer1 && layer2 && layer3 && center1 && center2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeat(final int heat) {
|
public void setHeat(final int heat) {
|
||||||
cachedHeat = heat;
|
cachedHeat = heat;
|
||||||
}
|
}
|
||||||
|
@ -117,16 +131,6 @@ public class IndustrialBlastFurnaceBlockEntity extends GenericMachineBlockEntity
|
||||||
return cachedHeat;
|
return cachedHeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TileGenericMachine
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
if (multiblockChecker == null) {
|
|
||||||
final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2);
|
|
||||||
multiblockChecker = new MultiblockChecker(world, downCenter);
|
|
||||||
}
|
|
||||||
super.tick();
|
|
||||||
}
|
|
||||||
|
|
||||||
// IContainerProvider
|
// IContainerProvider
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
|
|
|
@ -25,15 +25,15 @@
|
||||||
package techreborn.blockentity.machine.multiblock;
|
package techreborn.blockentity.machine.multiblock;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.FluidBlock;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
import reborncore.common.blockentity.MultiblockWriter;
|
||||||
import reborncore.common.fluid.FluidValue;
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
@ -51,7 +51,6 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
|
||||||
|
|
||||||
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
|
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
|
||||||
public Tank tank;
|
public Tank tank;
|
||||||
public MultiblockChecker multiblockChecker;
|
|
||||||
int ticksSinceLastChange;
|
int ticksSinceLastChange;
|
||||||
|
|
||||||
public IndustrialGrinderBlockEntity() {
|
public IndustrialGrinderBlockEntity() {
|
||||||
|
@ -64,28 +63,19 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
|
||||||
this.ticksSinceLastChange = 0;
|
this.ticksSinceLastChange = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getMultiBlock() {
|
@Override
|
||||||
if (multiblockChecker == null) {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
return false;
|
BlockState basic = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||||
}
|
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||||
final boolean down = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET);
|
writer.translate(1, -1, -1)
|
||||||
final boolean up = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0));
|
.fill(0, 0, 0, 3, 1, 3, basic)
|
||||||
final boolean blade = multiblockChecker.checkRingY(1, 1, MultiblockChecker.ADVANCED_CASING, new BlockPos(0, 1, 0));
|
.ring(Direction.Axis.Y, 3, 1, 3, (view, pos) -> view.getBlockState(pos) == advanced, advanced, (view, pos) -> view.getBlockState(pos).getMaterial() == Material.WATER, Blocks.WATER.getDefaultState())
|
||||||
final BlockState centerBlock = multiblockChecker.getBlock(0, 1, 0);
|
.fill(0, 2, 0, 3, 3, 3, basic);
|
||||||
final boolean center = ((centerBlock.getBlock() instanceof FluidBlock
|
|
||||||
|| centerBlock.getBlock() instanceof FluidBlock)
|
|
||||||
&& centerBlock.getMaterial() == Material.WATER);
|
|
||||||
return down && center && blade && up;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TilePowerAcceptor
|
// TilePowerAcceptor
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (multiblockChecker == null) {
|
|
||||||
final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2).offset(Direction.DOWN, 1);
|
|
||||||
multiblockChecker = new MultiblockChecker(world, downCenter);
|
|
||||||
}
|
|
||||||
|
|
||||||
ticksSinceLastChange++;
|
ticksSinceLastChange++;
|
||||||
// Check cells input slot 2 time per second
|
// Check cells input slot 2 time per second
|
||||||
if (!world.isClient && ticksSinceLastChange >= 10) {
|
if (!world.isClient && ticksSinceLastChange >= 10) {
|
||||||
|
|
|
@ -25,15 +25,15 @@
|
||||||
package techreborn.blockentity.machine.multiblock;
|
package techreborn.blockentity.machine.multiblock;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.FluidBlock;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
import reborncore.common.blockentity.MultiblockWriter;
|
||||||
import reborncore.common.fluid.FluidValue;
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
@ -51,7 +51,6 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
|
||||||
|
|
||||||
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
|
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
|
||||||
public Tank tank;
|
public Tank tank;
|
||||||
public MultiblockChecker multiblockChecker;
|
|
||||||
int ticksSinceLastChange;
|
int ticksSinceLastChange;
|
||||||
|
|
||||||
public IndustrialSawmillBlockEntity() {
|
public IndustrialSawmillBlockEntity() {
|
||||||
|
@ -64,28 +63,19 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
|
||||||
this.ticksSinceLastChange = 0;
|
this.ticksSinceLastChange = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getMutliBlock() {
|
@Override
|
||||||
if (multiblockChecker == null) {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
return false;
|
BlockState basic = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||||
}
|
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||||
final boolean down = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET);
|
writer.translate(1, -1, -1)
|
||||||
final boolean up = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0));
|
.fill(0, 0, 0, 3, 1, 3, basic)
|
||||||
final boolean blade = multiblockChecker.checkRingY(1, 1, MultiblockChecker.ADVANCED_CASING, new BlockPos(0, 1, 0));
|
.ring(Direction.Axis.Y, 3, 1, 3, (view, pos) -> view.getBlockState(pos) == advanced, advanced, (view, pos) -> view.getBlockState(pos).getMaterial() == Material.WATER, Blocks.WATER.getDefaultState())
|
||||||
final BlockState centerBlock = multiblockChecker.getBlock(0, 1, 0);
|
.fill(0, 2, 0, 3, 3, 3, basic);
|
||||||
final boolean center = ((centerBlock.getBlock() instanceof FluidBlock
|
|
||||||
|| centerBlock.getBlock() instanceof FluidBlock)
|
|
||||||
&& centerBlock.getMaterial() == Material.WATER);
|
|
||||||
return down && center && blade && up;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TileGenericMachine
|
// TileGenericMachine
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (multiblockChecker == null) {
|
|
||||||
final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2).offset(Direction.DOWN, 1);
|
|
||||||
multiblockChecker = new MultiblockChecker(world, downCenter);
|
|
||||||
}
|
|
||||||
|
|
||||||
ticksSinceLastChange++;
|
ticksSinceLastChange++;
|
||||||
// Check cells input slot 2 time per second
|
// Check cells input slot 2 time per second
|
||||||
if (!world.isClient && ticksSinceLastChange >= 10) {
|
if (!world.isClient && ticksSinceLastChange >= 10) {
|
||||||
|
|
|
@ -1,134 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TechReborn
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package techreborn.blockentity.machine.multiblock;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import techreborn.init.TRContent;
|
|
||||||
|
|
||||||
public class MultiblockChecker {
|
|
||||||
|
|
||||||
public static final BlockPos ZERO_OFFSET = BlockPos.ORIGIN;
|
|
||||||
|
|
||||||
public static final String STANDARD_CASING = "standard";
|
|
||||||
public static final String ADVANCED_CASING = "advanced";
|
|
||||||
public static final String INDUSTRIAL_CASING = "industrial";
|
|
||||||
public static final String CASING_ANY = "any";
|
|
||||||
|
|
||||||
private final World world;
|
|
||||||
private final BlockPos downCenter;
|
|
||||||
|
|
||||||
public MultiblockChecker(World world, BlockPos downCenter) {
|
|
||||||
this.world = world;
|
|
||||||
this.downCenter = downCenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: make thid not so ugly
|
|
||||||
public boolean checkCasing(int offX, int offY, int offZ, String type) {
|
|
||||||
Block block = getBlock(offX, offY, offZ).getBlock();
|
|
||||||
if (block == TRContent.MachineBlocks.BASIC.getCasing()|| block == TRContent.MachineBlocks.ADVANCED.getCasing() || block == TRContent.MachineBlocks.INDUSTRIAL.getCasing() ) {
|
|
||||||
if (type == MultiblockChecker.CASING_ANY) {
|
|
||||||
return true;
|
|
||||||
} else if ( type == "standard" && block == TRContent.MachineBlocks.BASIC.getCasing()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (type == "advanced" && block == TRContent.MachineBlocks.ADVANCED.getCasing()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (type == "industrial" && block == TRContent.MachineBlocks.INDUSTRIAL.getCasing()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkAir(int offX, int offY, int offZ) {
|
|
||||||
BlockPos pos = downCenter.add(offX, offY, offZ);
|
|
||||||
return world.isAir(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockState getBlock(int offX, int offY, int offZ) {
|
|
||||||
BlockPos pos = downCenter.add(offX, offY, offZ);
|
|
||||||
return world.getBlockState(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkRectY(int sizeX, int sizeZ, String casingType, BlockPos offset) {
|
|
||||||
for (int x = -sizeX; x <= sizeX; x++) {
|
|
||||||
for (int z = -sizeZ; z <= sizeZ; z++) {
|
|
||||||
if (!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkRectZ(int sizeX, int sizeY, String casingType, BlockPos offset) {
|
|
||||||
for (int x = -sizeX; x <= sizeX; x++) {
|
|
||||||
for (int y = -sizeY; y <= sizeY; y++) {
|
|
||||||
if (!checkCasing(x + offset.getX(), y + offset.getY(), offset.getZ(), casingType))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkRectX(int sizeZ, int sizeY, String casingType, BlockPos offset) {
|
|
||||||
for (int z = -sizeZ; z <= sizeZ; z++) {
|
|
||||||
for (int y = -sizeY; y <= sizeY; y++) {
|
|
||||||
if (!checkCasing(offset.getX(), y + offset.getY(), z + offset.getZ(), casingType))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkRingY(int sizeX, int sizeZ, String casingType, BlockPos offset) {
|
|
||||||
for (int x = -sizeX; x <= sizeX; x++) {
|
|
||||||
for (int z = -sizeZ; z <= sizeZ; z++) {
|
|
||||||
if ((x == sizeX || x == -sizeX) || (z == sizeZ || z == -sizeZ)) {
|
|
||||||
if (!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkRingYHollow(int sizeX, int sizeZ, String casingType, BlockPos offset) {
|
|
||||||
for (int x = -sizeX; x <= sizeX; x++) {
|
|
||||||
for (int z = -sizeZ; z <= sizeZ; z++) {
|
|
||||||
if ((x == sizeX || x == -sizeX) || (z == sizeZ || z == -sizeZ)) {
|
|
||||||
if (!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
|
||||||
return false;
|
|
||||||
} else if (!checkAir(x + offset.getX(), offset.getY(), z + offset.getZ()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -24,12 +24,14 @@
|
||||||
|
|
||||||
package techreborn.blockentity.machine.multiblock;
|
package techreborn.blockentity.machine.multiblock;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
import reborncore.common.blockentity.MultiblockWriter;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||||
|
@ -40,8 +42,6 @@ import techreborn.init.TRContent;
|
||||||
|
|
||||||
public class VacuumFreezerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
public class VacuumFreezerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
public MultiblockChecker multiblockChecker;
|
|
||||||
|
|
||||||
public VacuumFreezerBlockEntity() {
|
public VacuumFreezerBlockEntity() {
|
||||||
super(TRBlockEntities.VACUUM_FREEZER, "VacuumFreezer", TechRebornConfig.vacuumFreezerMaxInput, TechRebornConfig.vacuumFreezerMaxEnergy, TRContent.Machine.VACUUM_FREEZER.block, 2);
|
super(TRBlockEntities.VACUUM_FREEZER, "VacuumFreezer", TechRebornConfig.vacuumFreezerMaxInput, TechRebornConfig.vacuumFreezerMaxEnergy, TRContent.Machine.VACUUM_FREEZER.block, 2);
|
||||||
final int[] inputs = new int[]{0};
|
final int[] inputs = new int[]{0};
|
||||||
|
@ -50,21 +50,15 @@ public class VacuumFreezerBlockEntity extends GenericMachineBlockEntity implemen
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.VACUUM_FREEZER, this, 2, 1, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.VACUUM_FREEZER, this, 2, 1, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getMultiBlock() {
|
|
||||||
if (multiblockChecker == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final boolean up = multiblockChecker.checkRectY(1, 1, MultiblockChecker.ADVANCED_CASING, MultiblockChecker.ZERO_OFFSET);
|
|
||||||
final boolean down = multiblockChecker.checkRectY(1, 1, MultiblockChecker.ADVANCED_CASING, new BlockPos(0, -2, 0));
|
|
||||||
final boolean chamber = multiblockChecker.checkRingYHollow(1, 1, MultiblockChecker.INDUSTRIAL_CASING, new BlockPos(0, -1, 0));
|
|
||||||
return down && chamber && up;
|
|
||||||
}
|
|
||||||
|
|
||||||
// BlockEntity
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelRemoval() {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
super.cancelRemoval();
|
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||||
multiblockChecker = new MultiblockChecker(world, pos.offset(Direction.DOWN, 1));
|
BlockState industrial = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState();
|
||||||
|
|
||||||
|
writer.translate(-1, -3, -1)
|
||||||
|
.fill(0, 0, 0, 3, 1, 3, advanced)
|
||||||
|
.ringWithAir(Direction.Axis.Y, 3, 1, 3, industrial)
|
||||||
|
.fill(0, 2, 0, 3, 3, 3, advanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IContainerProvider
|
// IContainerProvider
|
||||||
|
@ -74,4 +68,13 @@ public class VacuumFreezerBlockEntity extends GenericMachineBlockEntity implemen
|
||||||
.blockEntity(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
|
.blockEntity(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
|
||||||
.syncCrafterValue().addInventory().create(this, syncID);
|
.syncCrafterValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCraft(RebornRecipe rebornRecipe) {
|
||||||
|
if (!this.isMultiblockValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.canCraft(rebornRecipe);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -150,9 +150,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!missingOutput) {
|
if (!missingOutput) {
|
||||||
if (hasOutputSpace(recipe.getOutput(), 9)) {
|
return hasOutputSpace(recipe.getOutput(), 9);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -173,9 +171,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ItemUtils.isItemEqual(stack, output, true, true)) {
|
if (ItemUtils.isItemEqual(stack, output, true, true)) {
|
||||||
if (stack.getMaxCount() > stack.getCount() + output.getCount()) {
|
return stack.getMaxCount() > stack.getCount() + output.getCount();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,8 +156,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
ItemStack outputStack = inventory.getStack(outputSlot);
|
ItemStack outputStack = inventory.getStack(outputSlot);
|
||||||
if (outputStack.isEmpty()) {
|
if (outputStack.isEmpty()) {
|
||||||
inventory.setStack(outputSlot, recipe.getOutput().copy());
|
inventory.setStack(outputSlot, recipe.getOutput().copy());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Just increment. We already checked stack match and stack size
|
// Just increment. We already checked stack match and stack size
|
||||||
outputStack.increment(1);
|
outputStack.increment(1);
|
||||||
}
|
}
|
||||||
|
@ -187,6 +186,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
public void setCookTimeTotal(int cookTimeTotal) {
|
public void setCookTimeTotal(int cookTimeTotal) {
|
||||||
this.cookTimeTotal = cookTimeTotal;
|
this.cookTimeTotal = cookTimeTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TilePowerAcceptor
|
// TilePowerAcceptor
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.state.property.IntProperty;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
|
@ -36,6 +37,7 @@ import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
import reborncore.common.blockentity.MultiblockWriter;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
@ -60,19 +62,22 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
super(TRBlockEntities.GREENHOUSE_CONTROLLER);
|
super(TRBlockEntities.GREENHOUSE_CONTROLLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getMultiBlock() {
|
@Override
|
||||||
if (multiblockCenter == null || world == null) {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
return false;
|
BlockState lamp = TRContent.Machine.LAMP_INCANDESCENT.block.getDefaultState().with(Properties.FACING, Direction.DOWN);
|
||||||
}
|
BlockState crop = Blocks.CACTUS.getDefaultState();
|
||||||
for (int i = -1; i <= 1; i++) {
|
|
||||||
for (int j = -1; j <= 1; j++) {
|
for (int i = -1; i < 2; i++) {
|
||||||
BlockState block = world.getBlockState(multiblockCenter.add(i * 3, 3, i * 3));
|
for (int j = -1; j < 2; j++) {
|
||||||
if (!(block.getBlock() instanceof BlockLamp) || !BlockLamp.isActive(block)) {
|
writer.add(i * 3, 3, j * 3, (world, pos) -> BlockLamp.isActive(world.getBlockState(pos)), lamp);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = -4; i <= 4; i++) {
|
||||||
|
for (int j = -4; j <= 4; j++) {
|
||||||
|
writer.add(i, 0, j, (world, pos) -> true, crop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,7 +97,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
if (--ticksToNextMultiblockCheck < 0) {
|
if (--ticksToNextMultiblockCheck < 0) {
|
||||||
growthBoost = getMultiBlock();
|
growthBoost = isMultiblockValid();
|
||||||
ticksToNextMultiblockCheck = 200;
|
ticksToNextMultiblockCheck = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,11 +216,6 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
public boolean canProvideEnergy(Direction direction) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -77,8 +77,7 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
if (randomchance == 1) {
|
if (randomchance == 1) {
|
||||||
if (inventory.getStack(1).isEmpty()) {
|
if (inventory.getStack(1).isEmpty()) {
|
||||||
inventory.setStack(1, itemstack.copy());
|
inventory.setStack(1, itemstack.copy());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
inventory.getStack(1).increment(itemstack.getCount());
|
inventory.getStack(1).increment(itemstack.getCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,10 +91,7 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
public boolean hasSlotGotSpace(int slot) {
|
public boolean hasSlotGotSpace(int slot) {
|
||||||
if (inventory.getStack(slot).isEmpty()) {
|
if (inventory.getStack(slot).isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (inventory.getStack(slot).getCount() < inventory.getStack(slot).getMaxCount()) {
|
} else return inventory.getStack(slot).getCount() < inventory.getStack(slot).getMaxCount();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBurning() {
|
public boolean isBurning() {
|
||||||
|
@ -129,8 +125,7 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
boolean updateInventory = false;
|
boolean updateInventory = false;
|
||||||
if (canRecycle() && !isBurning() && getEnergy() != 0) {
|
if (canRecycle() && !isBurning() && getEnergy() != 0) {
|
||||||
setBurning(true);
|
setBurning(true);
|
||||||
}
|
} else if (isBurning()) {
|
||||||
else if (isBurning()) {
|
|
||||||
if (useEnergy(getEuPerTick(cost)) != getEuPerTick(cost)) {
|
if (useEnergy(getEuPerTick(cost)) != getEuPerTick(cost)) {
|
||||||
this.setBurning(false);
|
this.setBurning(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,248 @@
|
||||||
|
/*
|
||||||
|
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TechReborn
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package techreborn.blockentity.machine.tier1;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.entity.HopperBlockEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.inventory.Inventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.sound.SoundCategory;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
|
import reborncore.common.util.WorldUtils;
|
||||||
|
import techreborn.blocks.machine.tier1.ResinBasinBlock;
|
||||||
|
import techreborn.blocks.misc.BlockRubberLog;
|
||||||
|
import techreborn.config.TechRebornConfig;
|
||||||
|
import techreborn.init.ModSounds;
|
||||||
|
import techreborn.init.TRBlockEntities;
|
||||||
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
import static reborncore.api.items.InventoryUtils.getInventoryAt;
|
||||||
|
|
||||||
|
public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
|
||||||
|
private Direction direction = Direction.NORTH;
|
||||||
|
|
||||||
|
// State
|
||||||
|
private boolean isPouring = false;
|
||||||
|
private boolean isFull = false;
|
||||||
|
|
||||||
|
private int pouringTimer = 0;
|
||||||
|
|
||||||
|
public ResinBasinBlockEntity() {
|
||||||
|
super(TRBlockEntities.RESIN_BASIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
super.tick();
|
||||||
|
if (world == null || world.isClient) return;
|
||||||
|
|
||||||
|
boolean shouldUpdateState = false;
|
||||||
|
|
||||||
|
if (isPouring) {
|
||||||
|
pouringTimer--;
|
||||||
|
|
||||||
|
// Play pouring audio
|
||||||
|
if (world.getTime() % 20 == 0) {
|
||||||
|
world.playSound(null, pos, ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS, 1F, 1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pouringTimer <= 0) {
|
||||||
|
isPouring = false;
|
||||||
|
isFull = true;
|
||||||
|
shouldUpdateState = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try and deposit
|
||||||
|
if (isFull) {
|
||||||
|
// Get inventory
|
||||||
|
Inventory invBelow = getInventoryBelow();
|
||||||
|
if (invBelow != null) {
|
||||||
|
|
||||||
|
ItemStack out = new ItemStack(TRContent.Parts.SAP, (Math.random() <= 0.5) ? 1 : 2);
|
||||||
|
out = HopperBlockEntity.transfer(null, invBelow, out, Direction.UP);
|
||||||
|
|
||||||
|
if (out.isEmpty()) {
|
||||||
|
// Successfully deposited
|
||||||
|
isFull = false;
|
||||||
|
shouldUpdateState = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean readyToHarvest = !isFull && !isPouring;
|
||||||
|
|
||||||
|
// Ensuring it's placed on a log
|
||||||
|
if ((readyToHarvest || world.getTime() % 20 == 0) && !validPlacement()) {
|
||||||
|
// Not placed on log, drop on ground
|
||||||
|
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||||
|
WorldUtils.dropItem(TRContent.Machine.RESIN_BASIN.asItem(), world, pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readyToHarvest) {
|
||||||
|
// Check for rubber
|
||||||
|
if (world.getTime() % TechRebornConfig.checkForSapTime == 0) {
|
||||||
|
BlockPos targetRubber = getLogWithSap();
|
||||||
|
|
||||||
|
if (targetRubber != null) {
|
||||||
|
// We have a valid sap log, harvest it
|
||||||
|
world.setBlockState(targetRubber, world.getBlockState(targetRubber).with(BlockRubberLog.HAS_SAP, false).with(BlockRubberLog.SAP_SIDE, Direction.fromHorizontal(0)));
|
||||||
|
isPouring = true;
|
||||||
|
pouringTimer = TechRebornConfig.sapTimeTicks;
|
||||||
|
shouldUpdateState = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldUpdateState) {
|
||||||
|
setPouringState(isPouring);
|
||||||
|
setFullState(isFull);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
|
||||||
|
super.onBreak(world, playerEntity, blockPos, blockState);
|
||||||
|
|
||||||
|
// Drop a sap if full
|
||||||
|
if (this.isFull) {
|
||||||
|
ItemStack out = new ItemStack(TRContent.Parts.SAP, (Math.random() <= 0.6) ? 1 : 2);
|
||||||
|
WorldUtils.dropItem(out, world, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag toTag(CompoundTag tagCompound) {
|
||||||
|
super.toTag(tagCompound);
|
||||||
|
|
||||||
|
return tagCompound;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromTag(BlockState blockState, CompoundTag tagCompound) {
|
||||||
|
super.fromTag(blockState, tagCompound);
|
||||||
|
|
||||||
|
this.isFull = blockState.get(ResinBasinBlock.FULL);
|
||||||
|
|
||||||
|
if (blockState.get(ResinBasinBlock.POURING)) {
|
||||||
|
this.isPouring = true;
|
||||||
|
pouringTimer = TechRebornConfig.sapTimeTicks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
super.onLoad();
|
||||||
|
|
||||||
|
if (world == null || world.isClient) return;
|
||||||
|
|
||||||
|
// Set facing
|
||||||
|
direction = world.getBlockState(pos).get(ResinBasinBlock.FACING).getOpposite();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Inventory getInventoryBelow() {
|
||||||
|
return getInventoryAt(this.getWorld(), this.pos.offset(Direction.DOWN));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validPlacement() {
|
||||||
|
return world.getBlockState(this.pos.offset(direction)).getBlock() == TRContent.RUBBER_LOG;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private BlockPos getLogWithSap() {
|
||||||
|
// Checking origin block
|
||||||
|
BlockPos originPos = this.pos.offset(direction);
|
||||||
|
BlockState originState = world.getBlockState(originPos);
|
||||||
|
|
||||||
|
if (originState.get(BlockRubberLog.HAS_SAP)) {
|
||||||
|
return originPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean shouldExit = false;
|
||||||
|
BlockPos current = originPos;
|
||||||
|
|
||||||
|
// Progress Up
|
||||||
|
while (!shouldExit) {
|
||||||
|
current = current.offset(Direction.UP);
|
||||||
|
|
||||||
|
BlockState state = world.getBlockState(current);
|
||||||
|
if (state.getBlock() == TRContent.RUBBER_LOG) {
|
||||||
|
if (state.get(BlockRubberLog.HAS_SAP)) {
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
shouldExit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
current = originPos;
|
||||||
|
shouldExit = false;
|
||||||
|
// Progress Down
|
||||||
|
while (!shouldExit) {
|
||||||
|
current = current.offset(Direction.DOWN);
|
||||||
|
|
||||||
|
BlockState state = world.getBlockState(current);
|
||||||
|
if (state.getBlock() == TRContent.RUBBER_LOG) {
|
||||||
|
if (state.get(BlockRubberLog.HAS_SAP)) {
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
shouldExit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Could not find a rubber log with sap
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPouringState(boolean value) {
|
||||||
|
if (world != null) {
|
||||||
|
world.setBlockState(pos, world.getBlockState(pos).with(ResinBasinBlock.POURING, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFullState(boolean value) {
|
||||||
|
if (world != null) {
|
||||||
|
world.setBlockState(pos, world.getBlockState(pos).with(ResinBasinBlock.FULL, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasSlotConfig() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeUpgraded() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -69,7 +69,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ItemStack currentRecipeOutput;
|
public ItemStack currentRecipeOutput;
|
||||||
public RollingMachineRecipe currentRecipe;
|
public RollingMachineRecipe currentRecipe;
|
||||||
private int outputSlot;
|
private final int outputSlot;
|
||||||
public boolean locked = false;
|
public boolean locked = false;
|
||||||
public int balanceSlot = 0;
|
public int balanceSlot = 0;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
List<Integer> possibleSlots = new ArrayList<>();
|
List<Integer> possibleSlots = new ArrayList<>();
|
||||||
for (int s = 0; s < currentRecipe.getPreviewInputs().size(); s++) {
|
for (int s = 0; s < currentRecipe.getPreviewInputs().size(); s++) {
|
||||||
ItemStack stackInSlot = inventory.getStack(s);
|
ItemStack stackInSlot = inventory.getStack(s);
|
||||||
Ingredient ingredient = (Ingredient) currentRecipe.getPreviewInputs().get(s);
|
Ingredient ingredient = currentRecipe.getPreviewInputs().get(s);
|
||||||
if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) {
|
if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) {
|
||||||
if (stackInSlot.isEmpty()) {
|
if (stackInSlot.isEmpty()) {
|
||||||
possibleSlots.add(s);
|
possibleSlots.add(s);
|
||||||
|
|
|
@ -76,8 +76,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
||||||
private void addOutputProducts(int slot) {
|
private void addOutputProducts(int slot) {
|
||||||
if (inventory.getStack(slot).isEmpty()) {
|
if (inventory.getStack(slot).isEmpty()) {
|
||||||
inventory.setStack(slot, TRContent.Parts.UU_MATTER.getStack());
|
inventory.setStack(slot, TRContent.Parts.UU_MATTER.getStack());
|
||||||
}
|
} else if (ItemUtils.isItemEqual(this.inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)) {
|
||||||
else if (ItemUtils.isItemEqual(this.inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)) {
|
|
||||||
inventory.getStack(slot).setCount((Math.min(64, 1 + inventory.getStack(slot).getCount())));
|
inventory.getStack(slot).setCount((Math.min(64, 1 + inventory.getStack(slot).getCount())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,9 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
|
||||||
// MachineBaseBlockEntity
|
// MachineBaseBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public void setFacing(Direction enumFacing) {
|
public void setFacing(Direction enumFacing) {
|
||||||
if (world == null) { return; }
|
if (world == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
world.setBlockState(pos, world.getBlockState(pos).with(EnergyStorageBlock.FACING, enumFacing));
|
world.setBlockState(pos, world.getBlockState(pos).with(EnergyStorageBlock.FACING, enumFacing));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ import techreborn.init.TRContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 14/03/2016.
|
* Created by modmuss50 on 14/03/2016.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class HighVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
|
public class HighVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ import techreborn.init.TRContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 14/03/2016.
|
* Created by modmuss50 on 14/03/2016.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class MediumVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
|
public class MediumVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ import java.util.ArrayList;
|
||||||
public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
|
public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
private int connectedBlocks = 0;
|
private int connectedBlocks = 0;
|
||||||
private ArrayList<LesuNetwork> countedNetworks = new ArrayList<>();
|
private final ArrayList<LesuNetwork> countedNetworks = new ArrayList<>();
|
||||||
|
|
||||||
public LapotronicSUBlockEntity() {
|
public LapotronicSUBlockEntity() {
|
||||||
super(TRBlockEntities.LAPOTRONIC_SU, "LESU", 2, TRContent.Machine.LAPOTRONIC_SU.block, EnergyTier.LOW, TechRebornConfig.lesuStoragePerBlock);
|
super(TRBlockEntities.LAPOTRONIC_SU, "LESU", 2, TRContent.Machine.LAPOTRONIC_SU.block, EnergyTier.LOW, TechRebornConfig.lesuStoragePerBlock);
|
||||||
|
@ -62,11 +62,9 @@ public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
maxOutput = TechRebornConfig.lesuBaseOutput + (connectedBlocks * TechRebornConfig.lesuExtraIOPerBlock);
|
maxOutput = TechRebornConfig.lesuBaseOutput + (connectedBlocks * TechRebornConfig.lesuExtraIOPerBlock);
|
||||||
if (connectedBlocks < 32) {
|
if (connectedBlocks < 32) {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (connectedBlocks < 128) {
|
||||||
else if (connectedBlocks < 128) {
|
|
||||||
maxInput = EnergyTier.MEDIUM.getMaxInput();
|
maxInput = EnergyTier.MEDIUM.getMaxInput();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
maxInput = EnergyTier.HIGH.getMaxInput();
|
maxInput = EnergyTier.HIGH.getMaxInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
package techreborn.blockentity.storage.fluid;
|
package techreborn.blockentity.storage.fluid;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
package techreborn.blockentity.storage.item;
|
package techreborn.blockentity.storage.item;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -34,6 +33,7 @@ import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.api.IListInfoProvider;
|
import reborncore.api.IListInfoProvider;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
|
@ -48,22 +48,21 @@ import reborncore.common.util.WorldUtils;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implements InventoryProvider, IToolDrop, IListInfoProvider, BuiltScreenHandlerProvider {
|
||||||
implements InventoryProvider, IToolDrop, IListInfoProvider, BuiltScreenHandlerProvider {
|
|
||||||
|
|
||||||
|
|
||||||
// Inventory constants
|
// Inventory constants
|
||||||
private static final int INPUT_SLOT = 0;
|
public static final int INPUT_SLOT = 0;
|
||||||
private static final int OUTPUT_SLOT = 1;
|
public static final int OUTPUT_SLOT = 1;
|
||||||
|
|
||||||
|
// Client sync variables for GUI, what and how much stored
|
||||||
|
public int storedAmount = 0;
|
||||||
|
|
||||||
protected RebornInventory<StorageUnitBaseBlockEntity> inventory;
|
protected RebornInventory<StorageUnitBaseBlockEntity> inventory;
|
||||||
private int maxCapacity;
|
private int maxCapacity;
|
||||||
|
|
||||||
private boolean shouldUpdate = true;
|
|
||||||
private int prevCount = -1;
|
|
||||||
|
|
||||||
private ItemStack storeItemStack;
|
private ItemStack storeItemStack;
|
||||||
|
|
||||||
private TRContent.StorageUnit type;
|
private TRContent.StorageUnit type;
|
||||||
|
@ -93,45 +92,29 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (world.isClient) {
|
if (world == null || world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If there is an item in the input AND stored is less than max capacity
|
// If there is an item in the input AND stored is less than max capacity
|
||||||
if (!inventory.getStack(INPUT_SLOT).isEmpty() && !isFull()) {
|
if (!inventory.getStack(INPUT_SLOT).isEmpty() && !isFull()) {
|
||||||
inventory.setStack(INPUT_SLOT, processInput(inventory.getStack(INPUT_SLOT)));
|
inventory.setStack(INPUT_SLOT, processInput(inventory.getStack(INPUT_SLOT)));
|
||||||
|
|
||||||
shouldUpdate = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill output slot with goodies when stored has items and output count is less than max stack size
|
// Fill output slot with goodies when stored has items and output count is less than max stack size
|
||||||
if (storeItemStack.getCount() > 0 && inventory.getStack(OUTPUT_SLOT).getCount() < getStoredStack().getMaxCount()) {
|
if (storeItemStack.getCount() > 0 && inventory.getStack(OUTPUT_SLOT).getCount() < getStoredStack().getMaxCount()) {
|
||||||
populateOutput();
|
populateOutput();
|
||||||
|
|
||||||
shouldUpdate = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == TRContent.StorageUnit.CREATIVE) {
|
if (type == TRContent.StorageUnit.CREATIVE) {
|
||||||
if (!isFull() && !isEmpty()) {
|
if (!isFull() && !isEmpty()) {
|
||||||
fillToCapacity();
|
fillToCapacity();
|
||||||
shouldUpdate = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update for locked item for clients
|
if (inventory.hasChanged()) {
|
||||||
if(isLocked() && prevCount != this.getCurrentCapacity()){
|
|
||||||
prevCount = this.getCurrentCapacity();
|
|
||||||
syncWithAll();
|
syncWithAll();
|
||||||
}
|
inventory.resetChanged();
|
||||||
|
|
||||||
|
|
||||||
if (shouldUpdate) {
|
|
||||||
inventory.setChanged();
|
|
||||||
markDirty();
|
|
||||||
syncWithAll();
|
|
||||||
|
|
||||||
shouldUpdate = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +154,10 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
||||||
return storeItemStack.isEmpty() ? inventory.getStack(OUTPUT_SLOT) : storeItemStack;
|
return storeItemStack.isEmpty() ? inventory.getStack(OUTPUT_SLOT) : storeItemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStoredStack(ItemStack itemStack) {
|
||||||
|
storeItemStack = itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the ItemStack to be displayed to the player via UI / model
|
// Returns the ItemStack to be displayed to the player via UI / model
|
||||||
public ItemStack getDisplayedStack() {
|
public ItemStack getDisplayedStack() {
|
||||||
if (!isLocked()) {
|
if (!isLocked()) {
|
||||||
|
@ -192,15 +179,11 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
||||||
return returnStack;
|
return returnStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStoredStack(ItemStack itemStack) {
|
|
||||||
storeItemStack = itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack processInput(ItemStack inputStack) {
|
public ItemStack processInput(ItemStack inputStack) {
|
||||||
|
|
||||||
boolean isSameStack = isSameType(inputStack);
|
boolean isSameStack = isSameType(inputStack);
|
||||||
|
|
||||||
if (storeItemStack == ItemStack.EMPTY && (isSameStack || getCurrentCapacity() == 0)) {
|
if (storeItemStack == ItemStack.EMPTY && (isSameStack || (getCurrentCapacity() == 0 && !isLocked()))) {
|
||||||
// Check if storage is empty, NOT including the output slot
|
// Check if storage is empty, NOT including the output slot
|
||||||
storeItemStack = inputStack.copy();
|
storeItemStack = inputStack.copy();
|
||||||
|
|
||||||
|
@ -229,6 +212,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inventory.setChanged();
|
||||||
return inputStack;
|
return inputStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +243,11 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
||||||
return getCurrentCapacity() == 0;
|
return getCurrentCapacity() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInsert(int index, ItemStack stack, @Nullable Direction direction) {
|
||||||
|
return super.canInsert(index, stack, direction) && (this.isEmpty() && !isLocked() || isSameType(stack));
|
||||||
|
}
|
||||||
|
|
||||||
public int getCurrentCapacity() {
|
public int getCurrentCapacity() {
|
||||||
return storeItemStack.getCount() + inventory.getStack(OUTPUT_SLOT).getCount();
|
return storeItemStack.getCount() + inventory.getStack(OUTPUT_SLOT).getCount();
|
||||||
}
|
}
|
||||||
|
@ -296,6 +285,11 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
||||||
storeItemStack.setCount(Math.min(tagCompound.getInt("storedQuantity"), this.maxCapacity));
|
storeItemStack.setCount(Math.min(tagCompound.getInt("storedQuantity"), this.maxCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Renderer only
|
||||||
|
if (tagCompound.contains("totalStoredAmount")) {
|
||||||
|
storedAmount = tagCompound.getInt("totalStoredAmount");
|
||||||
|
}
|
||||||
|
|
||||||
if (tagCompound.contains("lockedItem")) {
|
if (tagCompound.contains("lockedItem")) {
|
||||||
lockedItemStack = ItemStack.fromTag(tagCompound.getCompound("lockedItem"));
|
lockedItemStack = ItemStack.fromTag(tagCompound.getCompound("lockedItem"));
|
||||||
}
|
}
|
||||||
|
@ -320,6 +314,9 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
||||||
tagCompound.putInt("storedQuantity", 0);
|
tagCompound.putInt("storedQuantity", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Renderer only
|
||||||
|
tagCompound.putInt("totalStoredAmount", getCurrentCapacity());
|
||||||
|
|
||||||
if (isLocked()) {
|
if (isLocked()) {
|
||||||
tagCompound.put("lockedItem", lockedItemStack.toTag(new CompoundTag()));
|
tagCompound.put("lockedItem", lockedItemStack.toTag(new CompoundTag()));
|
||||||
}
|
}
|
||||||
|
@ -433,7 +430,9 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only set lockedItem in response to user input
|
// Only set lockedItem in response to user input
|
||||||
lockedItemStack = value ? getStoredStack().copy() : ItemStack.EMPTY;
|
ItemStack stack = getStoredStack().copy();
|
||||||
|
stack.setCount(1);
|
||||||
|
lockedItemStack = value ? stack : ItemStack.EMPTY;
|
||||||
syncWithAll();
|
syncWithAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,11 +446,37 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
||||||
return !isEmpty();
|
return !isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStoredAmount() {
|
||||||
|
return this.getCurrentCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStoredAmount(int storedAmount) {
|
||||||
|
this.storedAmount = storedAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStoredStackFromNBT(CompoundTag tag) {
|
||||||
|
storeItemStack = ItemStack.fromTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CompoundTag getStoredStackNBT() {
|
||||||
|
CompoundTag tag = new CompoundTag();
|
||||||
|
getStoredStack().toTag(tag);
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity playerEntity) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity playerEntity) {
|
||||||
return new ScreenHandlerBuilder("chest").player(playerEntity.inventory).inventory().hotbar().addInventory()
|
return new ScreenHandlerBuilder("chest").player(playerEntity.inventory).inventory().hotbar().addInventory()
|
||||||
.blockEntity(this).slot(0, 100, 53).outputSlot(1, 140, 53)
|
.blockEntity(this)
|
||||||
.sync(this::isLockedInt, this::setLockedInt).addInventory().create(this, syncID);
|
.slot(INPUT_SLOT, 100, 53)
|
||||||
|
.outputSlot(OUTPUT_SLOT, 140, 53)
|
||||||
|
.sync(this::isLockedInt, this::setLockedInt)
|
||||||
|
.sync(this::getStoredStackNBT, this::setStoredStackFromNBT)
|
||||||
|
.sync(this::getStoredAmount, this::setStoredAmount)
|
||||||
|
.addInventory().create(this, syncID);
|
||||||
|
|
||||||
|
// Note that inventory is synced, and it gets the stack from that
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,7 +30,6 @@ import techreborn.client.GuiType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author modmuss50
|
* @author modmuss50
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class DataDrivenMachineBlock extends GenericMachineBlock {
|
public class DataDrivenMachineBlock extends GenericMachineBlock {
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,10 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GenericMachineBlock extends BlockMachineBase {
|
public class GenericMachineBlock extends BlockMachineBase {
|
||||||
|
|
||||||
private IMachineGuiHandler gui;
|
private final IMachineGuiHandler gui;
|
||||||
Supplier<BlockEntity> blockEntityClass;
|
Supplier<BlockEntity> blockEntityClass;
|
||||||
|
|
||||||
public GenericMachineBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
|
public GenericMachineBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
|
||||||
|
@ -62,7 +61,6 @@ public class GenericMachineBlock extends BlockMachineBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMachineGuiHandler getGui() {
|
public IMachineGuiHandler getGui() {
|
||||||
return gui;
|
return gui;
|
||||||
|
|
|
@ -59,7 +59,8 @@ public class BlockFusionControlComputer extends BlockMachineBase {
|
||||||
if (playerIn.getStackInHand(hand).isEmpty()) {
|
if (playerIn.getStackInHand(hand).isEmpty()) {
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
if(worldIn.getBlockState(coil).canReplace(new ItemPlacementContext(new ItemUsageContext(playerIn, hand, hitResult))) && !blockEntityFusionControlComputer.isCoil(coil)){
|
if (worldIn.getBlockState(coil).canReplace(new ItemPlacementContext(new ItemUsageContext(playerIn, hand, hitResult)))
|
||||||
|
&& worldIn.getBlockState(pos).getBlock() != TRContent.Machine.FUSION_COIL.block) {
|
||||||
worldIn.setBlockState(coil, TRContent.Machine.FUSION_COIL.block.getDefaultState());
|
worldIn.setBlockState(coil, TRContent.Machine.FUSION_COIL.block.getDefaultState());
|
||||||
if (!playerIn.isCreative()) {
|
if (!playerIn.isCreative()) {
|
||||||
playerIn.getStackInHand(hand).decrement(1);
|
playerIn.getStackInHand(hand).decrement(1);
|
||||||
|
@ -72,7 +73,7 @@ public class BlockFusionControlComputer extends BlockMachineBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
blockEntityFusionControlComputer.checkCoils();
|
blockEntityFusionControlComputer.isMultiblockValid();
|
||||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ public class BlockFusionControlComputer extends BlockMachineBase {
|
||||||
super.onSteppedOn(worldIn, pos, entityIn);
|
super.onSteppedOn(worldIn, pos, entityIn);
|
||||||
if (worldIn.getBlockEntity(pos) instanceof FusionControlComputerBlockEntity) {
|
if (worldIn.getBlockEntity(pos) instanceof FusionControlComputerBlockEntity) {
|
||||||
if (((FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos)).crafingTickTime != 0
|
if (((FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos)).crafingTickTime != 0
|
||||||
&& ((FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos)).checkCoils()) {
|
&& ((FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos)).isMultiblockValid()) {
|
||||||
entityIn.damage(new FusionDamageSource(), 200F);
|
entityIn.damage(new FusionDamageSource(), 200F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,8 @@ public class BlockLamp extends BaseBlockEntityProvider {
|
||||||
public static BooleanProperty ACTIVE;
|
public static BooleanProperty ACTIVE;
|
||||||
protected final VoxelShape[] shape;
|
protected final VoxelShape[] shape;
|
||||||
|
|
||||||
private int cost;
|
private final int cost;
|
||||||
private static int brightness = 15;
|
private static final int brightness = 15;
|
||||||
|
|
||||||
public BlockLamp(int cost, double depth, double width) {
|
public BlockLamp(int cost, double depth, double width) {
|
||||||
super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(brightness));
|
super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(brightness));
|
||||||
|
@ -85,7 +85,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isActive(BlockState state) {
|
public static boolean isActive(BlockState state) {
|
||||||
return state.get(ACTIVE);
|
return state.contains(ACTIVE) && state.get(ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Direction getFacing(BlockState state) {
|
public static Direction getFacing(BlockState state) {
|
||||||
|
@ -97,7 +97,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setActive(Boolean active, World world, BlockPos pos) {
|
public static void setActive(Boolean active, World world, BlockPos pos) {
|
||||||
Direction facing = (Direction)world.getBlockState(pos).get(FACING);
|
Direction facing = world.getBlockState(pos).get(FACING);
|
||||||
BlockState state = world.getBlockState(pos).with(ACTIVE, active).with(FACING, facing);
|
BlockState state = world.getBlockState(pos).with(ACTIVE, active).with(FACING, facing);
|
||||||
world.setBlockState(pos, state, 3);
|
world.setBlockState(pos, state, 3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class IronAlloyFurnaceBlock extends GenericMachineBlock {
|
||||||
worldIn.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
|
worldIn.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Direction facing = (Direction) stateIn.get(FACING);
|
Direction facing = stateIn.get(FACING);
|
||||||
Direction.Axis facing$Axis = facing.getAxis();
|
Direction.Axis facing$Axis = facing.getAxis();
|
||||||
double double_5 = rand.nextDouble() * 0.6D - 0.3D;
|
double double_5 = rand.nextDouble() * 0.6D - 0.3D;
|
||||||
double deltaX = facing$Axis == Direction.Axis.X ? (double) facing.getOffsetX() * 0.52D : double_5;
|
double deltaX = facing$Axis == Direction.Axis.X ? (double) facing.getOffsetX() * 0.52D : double_5;
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class IronFurnaceBlock extends GenericMachineBlock {
|
||||||
worldIn.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
|
worldIn.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Direction facing = (Direction) stateIn.get(FACING);
|
Direction facing = stateIn.get(FACING);
|
||||||
Direction.Axis facing$Axis = facing.getAxis();
|
Direction.Axis facing$Axis = facing.getAxis();
|
||||||
double double_5 = rand.nextDouble() * 0.6D - 0.3D;
|
double double_5 = rand.nextDouble() * 0.6D - 0.3D;
|
||||||
double deltaX = facing$Axis == Direction.Axis.X ? (double) facing.getOffsetX() * 0.52D : double_5;
|
double deltaX = facing$Axis == Direction.Axis.X ? (double) facing.getOffsetX() * 0.52D : double_5;
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
private PlayerDetectorType(String name) {
|
PlayerDetectorType(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
package techreborn.blocks.machine.tier1;
|
||||||
|
|
||||||
|
import net.minecraft.block.*;
|
||||||
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.state.StateManager;
|
||||||
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
|
import net.minecraft.state.property.DirectionProperty;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import reborncore.common.BaseBlockEntityProvider;
|
||||||
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
|
import reborncore.common.util.WorldUtils;
|
||||||
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class ResinBasinBlock extends BaseBlockEntityProvider {
|
||||||
|
|
||||||
|
public static DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||||
|
public static BooleanProperty POURING = BooleanProperty.of("pouring");
|
||||||
|
public static BooleanProperty FULL = BooleanProperty.of("full");
|
||||||
|
Supplier<BlockEntity> blockEntityClass;
|
||||||
|
|
||||||
|
public ResinBasinBlock(Supplier<BlockEntity> blockEntityClass) {
|
||||||
|
super(Block.Settings.of(Material.WOOD).strength(2F, 2F));
|
||||||
|
this.blockEntityClass = blockEntityClass;
|
||||||
|
|
||||||
|
this.setDefaultState(
|
||||||
|
this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(POURING, false).with(FULL, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||||
|
return VoxelShapes.cuboid(0, 0, 0, 1, 15 / 16f, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFacing(Direction facing, World world, BlockPos pos) {
|
||||||
|
world.setBlockState(pos, world.getBlockState(pos).with(FACING, facing));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Block
|
||||||
|
@Override
|
||||||
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||||
|
FACING = DirectionProperty.of("facing", Direction.Type.HORIZONTAL);
|
||||||
|
POURING = BooleanProperty.of("pouring");
|
||||||
|
FULL = BooleanProperty.of("full");
|
||||||
|
builder.add(FACING, POURING, FULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Direction getFacing(BlockState state) {
|
||||||
|
return state.get(FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
||||||
|
super.onPlaced(worldIn, pos, state, placer, stack);
|
||||||
|
if (worldIn.isClient) return;
|
||||||
|
|
||||||
|
Direction facing = placer.getHorizontalFacing().getOpposite();
|
||||||
|
setFacing(facing, worldIn, pos);
|
||||||
|
|
||||||
|
// Drop item if not next to log and yell at user
|
||||||
|
if (worldIn.getBlockState(pos.offset(facing.getOpposite())).getBlock() != TRContent.RUBBER_LOG) {
|
||||||
|
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||||
|
WorldUtils.dropItem(this.asItem(), worldIn, pos);
|
||||||
|
placer.sendSystemMessage(new TranslatableText("techreborn.tooltip.invalid_basin_placement"), UUID.randomUUID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntity createBlockEntity(BlockView worldIn) {
|
||||||
|
if (blockEntityClass == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return blockEntityClass.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||||
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
|
if (blockEntity instanceof MachineBaseBlockEntity) {
|
||||||
|
((MachineBaseBlockEntity) blockEntity).onBreak(world, player, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onBreak(world, pos, state, player);
|
||||||
|
}
|
||||||
|
}
|
|
@ -84,7 +84,7 @@ public class BlockAlarm extends BaseBlockEntityProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Direction getFacing(BlockState state) {
|
public static Direction getFacing(BlockState state) {
|
||||||
return (Direction) state.get(FACING);
|
return state.get(FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFacing(Direction facing, World world, BlockPos pos) {
|
public static void setFacing(Direction facing, World world, BlockPos pos) {
|
||||||
|
|
|
@ -63,8 +63,7 @@ public class BlockComputerCube extends BlockMachineBase {
|
||||||
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
|
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
|
||||||
}
|
}
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
rotate(worldIn.getBlockState(pos), BlockRotation.CLOCKWISE_90);
|
rotate(worldIn.getBlockState(pos), BlockRotation.CLOCKWISE_90);
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,10 @@ public class BlockNuke extends BaseBlock {
|
||||||
|
|
||||||
public void ignite(World worldIn, BlockPos pos, BlockState state, LivingEntity igniter) {
|
public void ignite(World worldIn, BlockPos pos, BlockState state, LivingEntity igniter) {
|
||||||
if (!worldIn.isClient) {
|
if (!worldIn.isClient) {
|
||||||
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
|
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (float) pos.getX() + 0.5F,
|
||||||
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), igniter);
|
pos.getY(), (float) pos.getZ() + 0.5F, igniter);
|
||||||
worldIn.spawnEntity(entitynukeprimed);
|
worldIn.spawnEntity(entitynukeprimed);
|
||||||
worldIn.playSound((PlayerEntity) null, entitynukeprimed.getX(), entitynukeprimed.getY(), entitynukeprimed.getZ(),
|
worldIn.playSound(null, entitynukeprimed.getX(), entitynukeprimed.getY(), entitynukeprimed.getZ(),
|
||||||
SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,8 @@ public class BlockNuke extends BaseBlock {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) {
|
public void onDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) {
|
||||||
if (!worldIn.isClient) {
|
if (!worldIn.isClient) {
|
||||||
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
|
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (float) pos.getX() + 0.5F,
|
||||||
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), explosionIn.getCausingEntity());
|
pos.getY(), (float) pos.getZ() + 0.5F, explosionIn.getCausingEntity());
|
||||||
entitynukeprimed.setFuse(worldIn.random.nextInt(TechRebornConfig.nukeFuseTime / 4) + TechRebornConfig.nukeFuseTime / 8);
|
entitynukeprimed.setFuse(worldIn.random.nextInt(TechRebornConfig.nukeFuseTime / 4) + TechRebornConfig.nukeFuseTime / 8);
|
||||||
worldIn.spawnEntity(entitynukeprimed);
|
worldIn.spawnEntity(entitynukeprimed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
|
|
||||||
package techreborn.blocks.misc;
|
package techreborn.blocks.misc;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||||
import net.minecraft.block.LeavesBlock;
|
import net.minecraft.block.LeavesBlock;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
|
@ -33,7 +34,7 @@ import net.minecraft.sound.BlockSoundGroup;
|
||||||
public class BlockRubberLeaves extends LeavesBlock {
|
public class BlockRubberLeaves extends LeavesBlock {
|
||||||
|
|
||||||
public BlockRubberLeaves() {
|
public BlockRubberLeaves() {
|
||||||
super(FabricBlockSettings.of(Material.LEAVES).hardness(0.2F).ticksRandomly().sounds(BlockSoundGroup.GRASS).build().nonOpaque());
|
super(FabricBlockSettings.of(Material.LEAVES).hardness(0.2F).ticksRandomly().sounds(BlockSoundGroup.GRASS).nonOpaque());
|
||||||
FlammableBlockRegistry.getDefaultInstance().add(this, 30, 60);
|
FlammableBlockRegistry.getDefaultInstance().add(this, 30, 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,9 @@ public class BlockRubberLog extends PillarBlock {
|
||||||
if (Energy.valid(stack)) {
|
if (Energy.valid(stack)) {
|
||||||
Energy.of(stack).use(20);
|
Energy.of(stack).use(20);
|
||||||
} else {
|
} else {
|
||||||
stack.damage(1, playerIn, player -> { player.sendToolBreakStatus(hand); });
|
stack.damage(1, playerIn, player -> {
|
||||||
|
player.sendToolBreakStatus(hand);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
|
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
|
||||||
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));
|
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));
|
||||||
|
|
|
@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RubberButtonBlock extends WoodButtonBlock {
|
public class RubberButtonBlock extends WoodButtonBlock {
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RubberDoorBlock extends DoorBlock {
|
public class RubberDoorBlock extends DoorBlock {
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RubberPressurePlateBlock extends PressurePlateBlock {
|
public class RubberPressurePlateBlock extends PressurePlateBlock {
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RubberTrapdoorBlock extends TrapdoorBlock {
|
public class RubberTrapdoorBlock extends TrapdoorBlock {
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,24 @@
|
||||||
|
|
||||||
package techreborn.blocks.storage.fluid;
|
package techreborn.blocks.storage.fluid;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.fluid.Fluid;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import reborncore.api.blockentity.IMachineGuiHandler;
|
import reborncore.api.blockentity.IMachineGuiHandler;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
|
import reborncore.common.fluid.container.FluidInstance;
|
||||||
|
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||||
|
import reborncore.common.util.Tank;
|
||||||
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
|
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
|
||||||
import techreborn.client.GuiType;
|
import techreborn.client.GuiType;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -46,6 +60,44 @@ public class TankUnitBlock extends BlockMachineBase {
|
||||||
return new TankUnitBaseBlockEntity(unitType);
|
return new TankUnitBaseBlockEntity(unitType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||||
|
if (unitType == TRContent.TankUnit.CREATIVE || worldIn.isClient) {
|
||||||
|
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
final TankUnitBaseBlockEntity tankUnitEntity = (TankUnitBaseBlockEntity) worldIn.getBlockEntity(pos);
|
||||||
|
ItemStack stackInHand = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||||
|
Item itemInHand = stackInHand.getItem();
|
||||||
|
|
||||||
|
// Assuming ItemFluidInfo is 1 BUCKET, for now only allow exact amount or less
|
||||||
|
if (tankUnitEntity != null && itemInHand instanceof ItemFluidInfo) {
|
||||||
|
ItemFluidInfo itemFluid = (ItemFluidInfo) itemInHand;
|
||||||
|
Fluid fluid = itemFluid.getFluid(stackInHand);
|
||||||
|
int amount = stackInHand.getCount();
|
||||||
|
|
||||||
|
FluidValue fluidValue = FluidValue.BUCKET.multiply(amount);
|
||||||
|
Tank tankInstance = tankUnitEntity.getTank();
|
||||||
|
|
||||||
|
if (tankInstance.canFit(fluid, fluidValue)) {
|
||||||
|
if (tankInstance.getFluidInstance().isEmptyFluid()) {
|
||||||
|
tankInstance.setFluidInstance(new FluidInstance(fluid, fluidValue));
|
||||||
|
} else {
|
||||||
|
tankInstance.getFluidInstance().addAmount(fluidValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack returnStack = itemFluid.getEmpty();
|
||||||
|
returnStack.setCount(amount);
|
||||||
|
playerIn.setStackInHand(Hand.MAIN_HAND, returnStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMachineGuiHandler getGui() {
|
public IMachineGuiHandler getGui() {
|
||||||
return GuiType.TANK_UNIT;
|
return GuiType.TANK_UNIT;
|
||||||
|
|
|
@ -27,7 +27,10 @@ package techreborn.blocks.storage.item;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.item.ToolItem;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
|
@ -36,6 +39,8 @@ import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.api.blockentity.IMachineGuiHandler;
|
import reborncore.api.blockentity.IMachineGuiHandler;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
|
import reborncore.common.util.RebornInventory;
|
||||||
|
import reborncore.common.util.WorldUtils;
|
||||||
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
|
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
|
||||||
import techreborn.client.GuiType;
|
import techreborn.client.GuiType;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -56,19 +61,21 @@ public class StorageUnitBlock extends BlockMachineBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||||
if (unitType == TRContent.StorageUnit.CREATIVE) {
|
if (unitType == TRContent.StorageUnit.CREATIVE || worldIn.isClient) {
|
||||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
final StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) worldIn.getBlockEntity(pos);
|
final StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) worldIn.getBlockEntity(pos);
|
||||||
ItemStack stackInHand = playerIn.getStackInHand(Hand.MAIN_HAND);
|
ItemStack stackInHand = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||||
|
Item itemInHand = stackInHand.getItem();
|
||||||
|
|
||||||
if (storageEntity != null && storageEntity.isSameType(stackInHand)) {
|
if (storageEntity != null && itemInHand != Items.AIR && (storageEntity.isSameType(stackInHand) && !storageEntity.isFull() ||
|
||||||
|
(!storageEntity.isLocked() && storageEntity.isEmpty() && (!(itemInHand instanceof ToolItem))))) {
|
||||||
|
|
||||||
// Add item which is the same type (in users inventory) into storage
|
// Add item which is the same type (in users inventory) into storage
|
||||||
for (int i = 0; i < playerIn.inventory.size() && !storageEntity.isFull(); i++) {
|
for (int i = 0; i < playerIn.inventory.size() && !storageEntity.isFull(); i++) {
|
||||||
ItemStack curStack = playerIn.inventory.getStack(i);
|
ItemStack curStack = playerIn.inventory.getStack(i);
|
||||||
if (storageEntity.isSameType(curStack)) {
|
if (curStack.getItem() == itemInHand) {
|
||||||
playerIn.inventory.setStack(i, storageEntity.processInput(curStack));
|
playerIn.inventory.setStack(i, storageEntity.processInput(curStack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +85,34 @@ public class StorageUnitBlock extends BlockMachineBase {
|
||||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
|
||||||
|
super.onBlockBreakStart(state, world, pos, player);
|
||||||
|
|
||||||
|
if (world.isClient) return;
|
||||||
|
|
||||||
|
final StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) world.getBlockEntity(pos);
|
||||||
|
ItemStack stackInHand = player.getStackInHand(Hand.MAIN_HAND);
|
||||||
|
|
||||||
|
if (storageEntity != null && (stackInHand.isEmpty() || storageEntity.isSameType(stackInHand)) && !storageEntity.isEmpty()) {
|
||||||
|
RebornInventory<StorageUnitBaseBlockEntity> inventory = storageEntity.getInventory();
|
||||||
|
ItemStack out = inventory.getStack(StorageUnitBaseBlockEntity.OUTPUT_SLOT);
|
||||||
|
|
||||||
|
// Drop stack if sneaking
|
||||||
|
if (player.isSneaking()) {
|
||||||
|
WorldUtils.dropItem(new ItemStack(out.getItem()), world, player.getBlockPos());
|
||||||
|
out.decrement(1);
|
||||||
|
} else {
|
||||||
|
WorldUtils.dropItem(out, world, player.getBlockPos());
|
||||||
|
out.setCount(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
inventory.setChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMachineGuiHandler getGui() {
|
public IMachineGuiHandler getGui() {
|
||||||
return GuiType.STORAGE_UNIT;
|
return GuiType.STORAGE_UNIT;
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TechReborn
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package techreborn.client;
|
|
||||||
|
|
||||||
public class ClientEventHandler {
|
|
||||||
|
|
||||||
//TODO 1.14
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void renderPlayer(RenderPlayerEvent.Pre event) {
|
|
||||||
// PlayerEntity player = event.getEntityPlayer();
|
|
||||||
// Item chestslot = !player.getEquippedStack(EquipmentSlot.CHEST).isEmpty()
|
|
||||||
// ? player.getEquippedStack(EquipmentSlot.CHEST).getItem() : null;
|
|
||||||
// if (chestslot != null && chestslot == TRContent.CLOAKING_DEVICE) {
|
|
||||||
// event.setCanceled(true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
package techreborn.client;
|
package techreborn.client;
|
||||||
|
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
|
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
|
||||||
|
|
|
@ -25,22 +25,17 @@
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import reborncore.client.multiblock.Multiblock;
|
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import techreborn.blockentity.machine.multiblock.IndustrialBlastFurnaceBlockEntity;
|
import techreborn.blockentity.machine.multiblock.IndustrialBlastFurnaceBlockEntity;
|
||||||
import techreborn.init.TRContent;
|
|
||||||
|
|
||||||
public class GuiBlastFurnace extends GuiBase<BuiltScreenHandler> {
|
public class GuiBlastFurnace extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
public IndustrialBlastFurnaceBlockEntity blockEntity;
|
private final IndustrialBlastFurnaceBlockEntity blockEntity;
|
||||||
boolean hasMultiBlock;
|
boolean hasMultiBlock;
|
||||||
|
|
||||||
public GuiBlastFurnace(int syncID, final PlayerEntity player, final IndustrialBlastFurnaceBlockEntity blockEntity) {
|
public GuiBlastFurnace(int syncID, final PlayerEntity player, final IndustrialBlastFurnaceBlockEntity blockEntity) {
|
||||||
|
@ -94,61 +89,6 @@ public class GuiBlastFurnace extends GuiBase<BuiltScreenHandler> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
||||||
if (hideGuiElements()) return;
|
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||||
if (blockEntity.renderMultiblock == null) {
|
|
||||||
{
|
|
||||||
// This code here makes a basic multiblock and then sets to the selected one.
|
|
||||||
final Multiblock multiblock = new Multiblock();
|
|
||||||
BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
|
||||||
|
|
||||||
this.addComponent(0, 0, 0, standardCasing, multiblock);
|
|
||||||
this.addComponent(1, 0, 0, standardCasing, multiblock);
|
|
||||||
this.addComponent(0, 0, 1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 0, 0, standardCasing, multiblock);
|
|
||||||
this.addComponent(0, 0, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 0, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 0, 1, standardCasing, multiblock);
|
|
||||||
this.addComponent(1, 0, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(1, 0, 1, standardCasing, multiblock);
|
|
||||||
|
|
||||||
this.addComponent(1, 1, 0, standardCasing, multiblock);
|
|
||||||
this.addComponent(0, 1, 1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 1, 0, standardCasing, multiblock);
|
|
||||||
this.addComponent(0, 1, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 1, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 1, 1, standardCasing, multiblock);
|
|
||||||
this.addComponent(1, 1, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(1, 1, 1, standardCasing, multiblock);
|
|
||||||
|
|
||||||
this.addComponent(1, 2, 0, standardCasing, multiblock);
|
|
||||||
this.addComponent(0, 2, 1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 2, 0, standardCasing, multiblock);
|
|
||||||
this.addComponent(0, 2, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 2, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 2, 1, standardCasing, multiblock);
|
|
||||||
this.addComponent(1, 2, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(1, 2, 1, standardCasing, multiblock);
|
|
||||||
|
|
||||||
this.addComponent(0, 3, 0, standardCasing, multiblock);
|
|
||||||
this.addComponent(1, 3, 0, standardCasing, multiblock);
|
|
||||||
this.addComponent(0, 3, 1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 3, 0, standardCasing, multiblock);
|
|
||||||
this.addComponent(0, 3, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 3, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(-1, 3, 1, standardCasing, multiblock);
|
|
||||||
this.addComponent(1, 3, -1, standardCasing, multiblock);
|
|
||||||
this.addComponent(1, 3, 1, standardCasing, multiblock);
|
|
||||||
blockEntity.renderMultiblock = multiblock;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
blockEntity.renderMultiblock = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
|
||||||
multiblock.addComponent(new BlockPos(x - Direction.byId(blockEntity.getFacingInt()).getOffsetX() * 2,
|
|
||||||
y,
|
|
||||||
z - Direction.byId(blockEntity.getFacingInt()).getOffsetZ() * 2), blockState);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,22 +25,17 @@
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import reborncore.client.multiblock.Multiblock;
|
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import techreborn.blockentity.machine.multiblock.DistillationTowerBlockEntity;
|
import techreborn.blockentity.machine.multiblock.DistillationTowerBlockEntity;
|
||||||
import techreborn.init.TRContent;
|
|
||||||
|
|
||||||
public class GuiDistillationTower extends GuiBase<BuiltScreenHandler> {
|
public class GuiDistillationTower extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
public DistillationTowerBlockEntity blockEntity;
|
private final DistillationTowerBlockEntity blockEntity;
|
||||||
|
|
||||||
public GuiDistillationTower(int syncID, final PlayerEntity player, final DistillationTowerBlockEntity blockEntity) {
|
public GuiDistillationTower(int syncID, final PlayerEntity player, final DistillationTowerBlockEntity blockEntity) {
|
||||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||||
|
@ -70,7 +65,7 @@ public class GuiDistillationTower extends GuiBase<BuiltScreenHandler> {
|
||||||
final GuiBase.Layer layer = Layer.FOREGROUND;
|
final GuiBase.Layer layer = Layer.FOREGROUND;
|
||||||
|
|
||||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 55, 40, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 55, 40, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||||
if (blockEntity.getMutliBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,61 +78,6 @@ public class GuiDistillationTower extends GuiBase<BuiltScreenHandler> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
||||||
if (hideGuiElements()) return;
|
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||||
if (blockEntity.renderMultiblock == null) {
|
|
||||||
{
|
|
||||||
// This code here makes a basic multiblock and then sets to the selected one.
|
|
||||||
final Multiblock multiblock = new Multiblock();
|
|
||||||
BlockState industrialCasing = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState();
|
|
||||||
BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
|
||||||
|
|
||||||
addComponent(0, 0, 0, standardCasing, multiblock);
|
|
||||||
addComponent(1, 0, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, 0, 1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 0, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, 0, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 0, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 0, 1, standardCasing, multiblock);
|
|
||||||
addComponent(1, 0, -1, standardCasing, multiblock);
|
|
||||||
addComponent(1, 0, 1, standardCasing, multiblock);
|
|
||||||
|
|
||||||
addComponent(1, 1, 0, industrialCasing, multiblock);
|
|
||||||
addComponent(0, 1, 1, industrialCasing, multiblock);
|
|
||||||
addComponent(-1, 1, 0, industrialCasing, multiblock);
|
|
||||||
addComponent(0, 1, -1, industrialCasing, multiblock);
|
|
||||||
addComponent(-1, 1, -1, industrialCasing, multiblock);
|
|
||||||
addComponent(-1, 1, 1, industrialCasing, multiblock);
|
|
||||||
addComponent(1, 1, -1, industrialCasing, multiblock);
|
|
||||||
addComponent(1, 1, 1, industrialCasing, multiblock);
|
|
||||||
|
|
||||||
addComponent(1, 2, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, 2, 1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 2, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, 2, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 2, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 2, 1, standardCasing, multiblock);
|
|
||||||
addComponent(1, 2, -1, standardCasing, multiblock);
|
|
||||||
addComponent(1, 2, 1, standardCasing, multiblock);
|
|
||||||
|
|
||||||
addComponent(0, 3, 0, industrialCasing, multiblock);
|
|
||||||
addComponent(1, 3, 0, industrialCasing, multiblock);
|
|
||||||
addComponent(0, 3, 1, industrialCasing, multiblock);
|
|
||||||
addComponent(-1, 3, 0, industrialCasing, multiblock);
|
|
||||||
addComponent(0, 3, -1, industrialCasing, multiblock);
|
|
||||||
addComponent(-1, 3, -1, industrialCasing, multiblock);
|
|
||||||
addComponent(-1, 3, 1, industrialCasing, multiblock);
|
|
||||||
addComponent(1, 3, -1, industrialCasing, multiblock);
|
|
||||||
addComponent(1, 3, 1, industrialCasing, multiblock);
|
|
||||||
|
|
||||||
blockEntity.renderMultiblock = multiblock;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
blockEntity.renderMultiblock = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
|
||||||
multiblock.addComponent(new BlockPos(x - Direction.byId(blockEntity.getFacingInt()).getOffsetX() * 2, y, z - Direction.byId(blockEntity.getFacingInt()).getOffsetZ() * 2), blockState);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -24,26 +24,20 @@
|
||||||
|
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import reborncore.client.multiblock.Multiblock;
|
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
|
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
|
||||||
import techreborn.init.TRContent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GuiFluidReplicator extends GuiBase<BuiltScreenHandler> {
|
public class GuiFluidReplicator extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
FluidReplicatorBlockEntity blockEntity;
|
private final FluidReplicatorBlockEntity blockEntity;
|
||||||
|
|
||||||
public GuiFluidReplicator(int syncID, final PlayerEntity player, final FluidReplicatorBlockEntity blockEntity) {
|
public GuiFluidReplicator(int syncID, final PlayerEntity player, final FluidReplicatorBlockEntity blockEntity) {
|
||||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||||
|
@ -64,7 +58,7 @@ public class GuiFluidReplicator extends GuiBase<BuiltScreenHandler> {
|
||||||
drawSlot(matrixStack, 124, 55, layer);
|
drawSlot(matrixStack, 124, 55, layer);
|
||||||
// JEI button
|
// JEI button
|
||||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||||
if (blockEntity.getMultiBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +70,7 @@ public class GuiFluidReplicator extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
builder.drawTank(matrixStack, this, 99, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
builder.drawTank(matrixStack, this, 99, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||||
if (blockEntity.getMultiBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||||
} else {
|
} else {
|
||||||
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
||||||
|
@ -88,34 +82,6 @@ public class GuiFluidReplicator extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
// GuiScreen
|
// GuiScreen
|
||||||
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
||||||
if (hideGuiElements()) return;
|
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||||
if (blockEntity.renderMultiblock == null) {
|
|
||||||
{
|
|
||||||
// This code here makes a basic multiblock and then sets to the selected one.
|
|
||||||
final Multiblock multiblock = new Multiblock();
|
|
||||||
final BlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
|
||||||
|
|
||||||
addComponent(1, 0, 0, reinforcedCasing, multiblock);
|
|
||||||
addComponent(0, 0, 1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(-1, 0, 0, reinforcedCasing, multiblock);
|
|
||||||
addComponent(0, 0, -1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(-1, 0, -1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(-1, 0, 1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(1, 0, -1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(1, 0, 1, reinforcedCasing, multiblock);
|
|
||||||
|
|
||||||
blockEntity.renderMultiblock = multiblock;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
blockEntity.renderMultiblock = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
|
||||||
multiblock.addComponent(new BlockPos(
|
|
||||||
x - Direction.byId(this.blockEntity.getFacingInt()).getOffsetX() * 2,
|
|
||||||
y,
|
|
||||||
z - Direction.byId(this.blockEntity.getFacingInt()).getOffsetZ() * 2), blockState);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -24,33 +24,29 @@
|
||||||
|
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
|
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonUpDown.UpDownButtonType;
|
import reborncore.client.gui.builder.widget.GuiButtonUpDown.UpDownButtonType;
|
||||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import reborncore.client.multiblock.Multiblock;
|
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.common.network.NetworkManager;
|
import reborncore.common.network.NetworkManager;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.util.Color;
|
import reborncore.common.util.Color;
|
||||||
import reborncore.common.util.Torus;
|
import reborncore.common.util.Torus;
|
||||||
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
|
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
|
||||||
import techreborn.init.TRContent;
|
|
||||||
import techreborn.packets.ServerboundPackets;
|
import techreborn.packets.ServerboundPackets;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class GuiFusionReactor extends GuiBase<BuiltScreenHandler> {
|
public class GuiFusionReactor extends GuiBase<BuiltScreenHandler> {
|
||||||
FusionControlComputerBlockEntity blockEntity;
|
|
||||||
|
private final FusionControlComputerBlockEntity blockEntity;
|
||||||
|
|
||||||
public GuiFusionReactor(int syncID, final PlayerEntity player, final FusionControlComputerBlockEntity blockEntity) {
|
public GuiFusionReactor(int syncID, final PlayerEntity player, final FusionControlComputerBlockEntity blockEntity) {
|
||||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||||
|
@ -76,7 +72,7 @@ public class GuiFusionReactor extends GuiBase<BuiltScreenHandler> {
|
||||||
drawOutputSlot(matrixStack, 80, 47, layer);
|
drawOutputSlot(matrixStack, 80, 47, layer);
|
||||||
|
|
||||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||||
if (blockEntity.getCoilStatus() > 0) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +85,7 @@ public class GuiFusionReactor extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 105, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.LEFT, layer);
|
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 105, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.LEFT, layer);
|
||||||
if (blockEntity.getCoilStatus() > 0) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
addHologramButton(6, 4, 212, layer).clickHandler(this::hologramToggle);
|
addHologramButton(6, 4, 212, layer).clickHandler(this::hologramToggle);
|
||||||
drawCentredText(matrixStack, blockEntity.getStateText(), 20, Color.BLUE.darker().getColor(), layer);
|
drawCentredText(matrixStack, blockEntity.getStateText(), 20, Color.BLUE.darker().getColor(), layer);
|
||||||
if (blockEntity.state == 2) {
|
if (blockEntity.state == 2) {
|
||||||
|
@ -123,34 +119,11 @@ public class GuiFusionReactor extends GuiBase<BuiltScreenHandler> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hologramToggle(GuiButtonExtended button, double x, double y) {
|
public void hologramToggle(GuiButtonExtended button, double x, double y) {
|
||||||
if (hideGuiElements()) return;
|
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||||
if (blockEntity.renderMultiblock == null) {
|
|
||||||
updateMultiBlockRender();
|
|
||||||
} else {
|
|
||||||
blockEntity.renderMultiblock = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendSizeChange(int sizeDelta) {
|
private void sendSizeChange(int sizeDelta) {
|
||||||
NetworkManager.sendToServer(ServerboundPackets.createPacketFusionControlSize(sizeDelta, blockEntity.getPos()));
|
NetworkManager.sendToServer(ServerboundPackets.createPacketFusionControlSize(sizeDelta, blockEntity.getPos()));
|
||||||
//Reset the multiblock as it will be wrong now.
|
|
||||||
if(blockEntity.renderMultiblock != null){
|
|
||||||
updateMultiBlockRender();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateMultiBlockRender(){
|
|
||||||
final Multiblock multiblock = new Multiblock();
|
|
||||||
BlockState coil = TRContent.Machine.FUSION_COIL.block.getDefaultState();
|
|
||||||
|
|
||||||
List<BlockPos> coils = Torus.generate(new BlockPos(0, 0, 0), blockEntity.size);
|
|
||||||
coils.forEach(pos -> addComponent(pos.getX(), pos.getY(), pos.getZ(), coil, multiblock));
|
|
||||||
|
|
||||||
blockEntity.renderMultiblock = multiblock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
|
||||||
multiblock.addComponent(new BlockPos(x, y, z), blockState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Pair<Integer, Integer>> getCoilStackCount() {
|
public Optional<Pair<Integer, Integer>> getCoilStackCount() {
|
||||||
|
|
|
@ -25,23 +25,16 @@
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.client.resource.language.I18n;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.state.property.Properties;
|
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||||
import reborncore.client.multiblock.Multiblock;
|
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import techreborn.blockentity.machine.tier1.GreenhouseControllerBlockEntity;
|
import techreborn.blockentity.machine.tier1.GreenhouseControllerBlockEntity;
|
||||||
import techreborn.init.TRContent;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -49,7 +42,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class GuiGreenhouseController extends GuiBase<BuiltScreenHandler> {
|
public class GuiGreenhouseController extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
GreenhouseControllerBlockEntity blockEntity;
|
private final GreenhouseControllerBlockEntity blockEntity;
|
||||||
|
|
||||||
public GuiGreenhouseController(int syncID, final PlayerEntity player, final GreenhouseControllerBlockEntity blockEntity) {
|
public GuiGreenhouseController(int syncID, final PlayerEntity player, final GreenhouseControllerBlockEntity blockEntity) {
|
||||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||||
|
@ -71,7 +64,7 @@ public class GuiGreenhouseController extends GuiBase<BuiltScreenHandler> {
|
||||||
drawSlot(matrixStack, 30, gridYPos + 36, layer);
|
drawSlot(matrixStack, 30, gridYPos + 36, layer);
|
||||||
drawSlot(matrixStack, 48, gridYPos + 36, layer);
|
drawSlot(matrixStack, 48, gridYPos + 36, layer);
|
||||||
|
|
||||||
if (!blockEntity.getMultiBlock()) {
|
if (!blockEntity.isMultiblockValid()) {
|
||||||
getMinecraft().getTextureManager().bindTexture(new Identifier("techreborn", "textures/item/part/digital_display.png"));
|
getMinecraft().getTextureManager().bindTexture(new Identifier("techreborn", "textures/item/part/digital_display.png"));
|
||||||
drawTexture(matrixStack, x + 68, y + 22, 0, 0, 16, 16, 16, 16);
|
drawTexture(matrixStack, x + 68, y + 22, 0, 0, 16, 16, 16, 16);
|
||||||
if (isPointInRect(68, 22, 16, 16, mouseX, mouseY)) {
|
if (isPointInRect(68, 22, 16, 16, mouseX, mouseY)) {
|
||||||
|
@ -96,7 +89,7 @@ public class GuiGreenhouseController extends GuiBase<BuiltScreenHandler> {
|
||||||
addHologramButton(90, 24, 212, layer).clickHandler(this::onClick);
|
addHologramButton(90, 24, 212, layer).clickHandler(this::onClick);
|
||||||
builder.drawHologramButton(matrixStack, this, 90, 24, mouseX, mouseY, layer);
|
builder.drawHologramButton(matrixStack, this, 90, 24, mouseX, mouseY, layer);
|
||||||
|
|
||||||
if (!blockEntity.getMultiBlock()) {
|
if (!blockEntity.isMultiblockValid()) {
|
||||||
if (isPointInRect(68, 22, 16, 16, mouseX, mouseY)) {
|
if (isPointInRect(68, 22, 16, 16, mouseX, mouseY)) {
|
||||||
List<Text> list = Arrays.stream(I18n.translate("techreborn.tooltip.greenhouse.upgrade_available")
|
List<Text> list = Arrays.stream(I18n.translate("techreborn.tooltip.greenhouse.upgrade_available")
|
||||||
.split("\\r?\\n"))
|
.split("\\r?\\n"))
|
||||||
|
@ -113,41 +106,6 @@ public class GuiGreenhouseController extends GuiBase<BuiltScreenHandler> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
||||||
if (hideGuiElements()) return;
|
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||||
if (blockEntity.renderMultiblock == null) {
|
|
||||||
final Multiblock multiblock = new Multiblock();
|
|
||||||
BlockState lamp = TRContent.Machine.LAMP_INCANDESCENT.block.getDefaultState().with(Properties.FACING, Direction.DOWN);
|
|
||||||
BlockState crop = Blocks.CACTUS.getDefaultState();
|
|
||||||
|
|
||||||
this.addComponent(-3, 3, -3, lamp, multiblock);
|
|
||||||
this.addComponent(-3, 3, 0, lamp, multiblock);
|
|
||||||
this.addComponent(-3, 3, 3, lamp, multiblock);
|
|
||||||
this.addComponent(0, 3, -3, lamp, multiblock);
|
|
||||||
this.addComponent(0, 3, 0, lamp, multiblock);
|
|
||||||
this.addComponent(0, 3, 3, lamp, multiblock);
|
|
||||||
this.addComponent(3, 3, -3, lamp, multiblock);
|
|
||||||
this.addComponent(3, 3, 0, lamp, multiblock);
|
|
||||||
this.addComponent(3, 3, 3, lamp, multiblock);
|
|
||||||
|
|
||||||
for (int i = -4; i <= 4; i++) {
|
|
||||||
for (int j = -4; j <= 4; j++) {
|
|
||||||
this.addComponent(i, 0, j, crop, multiblock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blockEntity.renderMultiblock = multiblock;
|
|
||||||
} else {
|
|
||||||
blockEntity.renderMultiblock = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
|
||||||
multiblock.addComponent(new BlockPos(
|
|
||||||
x - Direction.byId(this.blockEntity.getFacingInt()).getOffsetX() * 5,
|
|
||||||
y,
|
|
||||||
z - Direction.byId(this.blockEntity.getFacingInt()).getOffsetZ() * 5),
|
|
||||||
blockState
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -25,21 +25,17 @@
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import reborncore.client.multiblock.Multiblock;
|
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import techreborn.blockentity.machine.multiblock.ImplosionCompressorBlockEntity;
|
import techreborn.blockentity.machine.multiblock.ImplosionCompressorBlockEntity;
|
||||||
import techreborn.init.TRContent;
|
|
||||||
|
|
||||||
public class GuiImplosionCompressor extends GuiBase<BuiltScreenHandler> {
|
public class GuiImplosionCompressor extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
ImplosionCompressorBlockEntity blockEntity;
|
private final ImplosionCompressorBlockEntity blockEntity;
|
||||||
|
|
||||||
public GuiImplosionCompressor(int syncID, final PlayerEntity player, final ImplosionCompressorBlockEntity blockEntity) {
|
public GuiImplosionCompressor(int syncID, final PlayerEntity player, final ImplosionCompressorBlockEntity blockEntity) {
|
||||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||||
|
@ -60,7 +56,7 @@ public class GuiImplosionCompressor extends GuiBase<BuiltScreenHandler> {
|
||||||
drawSlot(matrixStack, 92, 36, layer);
|
drawSlot(matrixStack, 92, 36, layer);
|
||||||
drawSlot(matrixStack, 110, 36, layer);
|
drawSlot(matrixStack, 110, 36, layer);
|
||||||
|
|
||||||
if (blockEntity.getMutliBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +69,7 @@ public class GuiImplosionCompressor extends GuiBase<BuiltScreenHandler> {
|
||||||
final GuiBase.Layer layer = Layer.FOREGROUND;
|
final GuiBase.Layer layer = Layer.FOREGROUND;
|
||||||
|
|
||||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 71, 40, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 71, 40, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||||
if (blockEntity.getMutliBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||||
} else {
|
} else {
|
||||||
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
||||||
|
@ -85,29 +81,6 @@ public class GuiImplosionCompressor extends GuiBase<BuiltScreenHandler> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY) {
|
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY) {
|
||||||
if (hideGuiElements()) return;
|
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||||
if (blockEntity.renderMultiblock == null) {
|
|
||||||
{
|
|
||||||
// This code here makes a basic multiblock and then sets to the selected one.
|
|
||||||
final Multiblock multiblock = new Multiblock();
|
|
||||||
for (int x = -1; x <= 1; x++) {
|
|
||||||
for (int y = -4; y <= -2; y++) {
|
|
||||||
for (int z = -1; z <= 1; z++) {
|
|
||||||
if (!((x == 0) && (y == -3) && (z == 0))) {
|
|
||||||
this.addComponent(x, y + 1, z, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(), multiblock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
blockEntity.renderMultiblock = multiblock;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
blockEntity.renderMultiblock = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
|
||||||
multiblock.addComponent(new BlockPos(x, y, z), blockState);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,23 +24,17 @@
|
||||||
|
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import reborncore.client.multiblock.Multiblock;
|
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity;
|
import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity;
|
||||||
import techreborn.init.TRContent;
|
|
||||||
|
|
||||||
public class GuiIndustrialGrinder extends GuiBase<BuiltScreenHandler> {
|
public class GuiIndustrialGrinder extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
IndustrialGrinderBlockEntity blockEntity;
|
private final IndustrialGrinderBlockEntity blockEntity;
|
||||||
|
|
||||||
public GuiIndustrialGrinder(int syncID, final PlayerEntity player, final IndustrialGrinderBlockEntity blockEntity) {
|
public GuiIndustrialGrinder(int syncID, final PlayerEntity player, final IndustrialGrinderBlockEntity blockEntity) {
|
||||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||||
|
@ -67,7 +61,7 @@ public class GuiIndustrialGrinder extends GuiBase<BuiltScreenHandler> {
|
||||||
drawSlot(matrixStack, 126, 72, layer);
|
drawSlot(matrixStack, 126, 72, layer);
|
||||||
|
|
||||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||||
if (blockEntity.getMultiBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +73,7 @@ public class GuiIndustrialGrinder extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||||
builder.drawTank(matrixStack, this, 53, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
builder.drawTank(matrixStack, this, 53, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||||
if (blockEntity.getMultiBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||||
} else {
|
} else {
|
||||||
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
||||||
|
@ -90,58 +84,6 @@ public class GuiIndustrialGrinder extends GuiBase<BuiltScreenHandler> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(GuiButtonExtended button, double mouseX, double mouseY) {
|
public void onClick(GuiButtonExtended button, double mouseX, double mouseY) {
|
||||||
if (hideGuiElements()) return;
|
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||||
if (blockEntity.renderMultiblock == null) {
|
|
||||||
{
|
|
||||||
// This code here makes a basic multiblock and then sets to the selected one.
|
|
||||||
final Multiblock multiblock = new Multiblock();
|
|
||||||
BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
|
||||||
BlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
|
||||||
|
|
||||||
addComponent(0, -1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(1, -1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, -1, 1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, -1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, -1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, -1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, -1, 1, standardCasing, multiblock);
|
|
||||||
addComponent(1, -1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(1, -1, 1, standardCasing, multiblock);
|
|
||||||
|
|
||||||
addComponent(0, 0, 0, Blocks.WATER.getDefaultState(), multiblock);
|
|
||||||
addComponent(1, 0, 0, reinforcedCasing, multiblock);
|
|
||||||
addComponent(0, 0, 1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(-1, 0, 0, reinforcedCasing, multiblock);
|
|
||||||
addComponent(0, 0, -1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(-1, 0, -1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(-1, 0, 1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(1, 0, -1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(1, 0, 1, reinforcedCasing, multiblock);
|
|
||||||
|
|
||||||
addComponent(0, 1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, 1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(1, 1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, 1, 1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, 1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 1, 1, standardCasing, multiblock);
|
|
||||||
addComponent(1, 1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(1, 1, 1, standardCasing, multiblock);
|
|
||||||
|
|
||||||
blockEntity.renderMultiblock = multiblock;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
blockEntity.renderMultiblock = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
|
||||||
multiblock.addComponent(new BlockPos(
|
|
||||||
x - Direction.byId(this.blockEntity.getFacingInt()).getOffsetX() * 2,
|
|
||||||
y,
|
|
||||||
z - Direction.byId(this.blockEntity.getFacingInt()).getOffsetZ() * 2),
|
|
||||||
blockState);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -24,35 +24,23 @@
|
||||||
|
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import reborncore.client.multiblock.Multiblock;
|
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity;
|
import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity;
|
||||||
import techreborn.init.TRContent;
|
|
||||||
|
|
||||||
public class GuiIndustrialSawmill extends GuiBase<BuiltScreenHandler> {
|
public class GuiIndustrialSawmill extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
IndustrialSawmillBlockEntity blockEntity;
|
private final IndustrialSawmillBlockEntity blockEntity;
|
||||||
|
|
||||||
public GuiIndustrialSawmill(int syncID, final PlayerEntity player, final IndustrialSawmillBlockEntity blockEntity) {
|
public GuiIndustrialSawmill(int syncID, final PlayerEntity player, final IndustrialSawmillBlockEntity blockEntity) {
|
||||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||||
this.blockEntity = blockEntity;
|
this.blockEntity = blockEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
super.init();
|
|
||||||
blockEntity.renderMultiblock = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawBackground(MatrixStack matrixStack, final float partialTicks, final int mouseX, final int mouseY) {
|
protected void drawBackground(MatrixStack matrixStack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||||
super.drawBackground(matrixStack, partialTicks, mouseX, mouseY);
|
super.drawBackground(matrixStack, partialTicks, mouseX, mouseY);
|
||||||
|
@ -72,7 +60,7 @@ public class GuiIndustrialSawmill extends GuiBase<BuiltScreenHandler> {
|
||||||
drawSlot(matrixStack, 126, 61, layer);
|
drawSlot(matrixStack, 126, 61, layer);
|
||||||
|
|
||||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||||
if (blockEntity.getMutliBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +72,7 @@ public class GuiIndustrialSawmill extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||||
builder.drawTank(matrixStack, this, 53, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
builder.drawTank(matrixStack, this, 53, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||||
if (blockEntity.getMutliBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||||
} else {
|
} else {
|
||||||
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
||||||
|
@ -95,56 +83,6 @@ public class GuiIndustrialSawmill extends GuiBase<BuiltScreenHandler> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY) {
|
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY) {
|
||||||
if (hideGuiElements()) return;
|
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||||
if (blockEntity.renderMultiblock == null) {
|
|
||||||
{
|
|
||||||
// This code here makes a basic multiblock and then sets to the selected one.
|
|
||||||
final Multiblock multiblock = new Multiblock();
|
|
||||||
BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
|
||||||
BlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
|
||||||
|
|
||||||
addComponent(0, -1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(1, -1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, -1, 1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, -1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, -1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, -1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, -1, 1, standardCasing, multiblock);
|
|
||||||
addComponent(1, -1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(1, -1, 1, standardCasing, multiblock);
|
|
||||||
|
|
||||||
addComponent(0, 0, 0, Blocks.WATER.getDefaultState(), multiblock);
|
|
||||||
addComponent(1, 0, 0, reinforcedCasing, multiblock);
|
|
||||||
addComponent(0, 0, 1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(-1, 0, 0, reinforcedCasing, multiblock);
|
|
||||||
addComponent(0, 0, -1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(-1, 0, -1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(-1, 0, 1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(1, 0, -1, reinforcedCasing, multiblock);
|
|
||||||
addComponent(1, 0, 1, reinforcedCasing, multiblock);
|
|
||||||
|
|
||||||
addComponent(0, 1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, 1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(1, 1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, 1, 1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 1, 0, standardCasing, multiblock);
|
|
||||||
addComponent(0, 1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(-1, 1, 1, standardCasing, multiblock);
|
|
||||||
addComponent(1, 1, -1, standardCasing, multiblock);
|
|
||||||
addComponent(1, 1, 1, standardCasing, multiblock);
|
|
||||||
|
|
||||||
blockEntity.renderMultiblock = multiblock;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
blockEntity.renderMultiblock = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
|
||||||
multiblock.addComponent(new BlockPos(
|
|
||||||
x - Direction.byId(this.blockEntity.getFacingInt()).getOffsetY() * 2,
|
|
||||||
y,
|
|
||||||
z- Direction.byId(this.blockEntity.getFacingInt()).getOffsetY() * 2).offset(blockEntity.getFacing().getOpposite(), 2), blockState);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class GuiIronFurnace extends GuiBase<BuiltScreenHandler> {
|
||||||
furnaceExp -= PlayerUtils.getLevelExperience(player.experienceLevel);
|
furnaceExp -= PlayerUtils.getLevelExperience(player.experienceLevel);
|
||||||
++levels;
|
++levels;
|
||||||
}
|
}
|
||||||
message = message + "+" + String.valueOf(levels) + "L";
|
message = message + "+" + levels + "L";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class GuiPlasmaGenerator extends GuiBase<BuiltScreenHandler> {
|
public class GuiPlasmaGenerator extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
|
@ -62,16 +62,19 @@ public class GuiStorageUnit extends GuiBase<BuiltScreenHandler> {
|
||||||
builder.drawText(matrixStack, this, new TranslatableText("gui.techreborn.unit.in"), 100, 43, 4210752);
|
builder.drawText(matrixStack, this, new TranslatableText("gui.techreborn.unit.in"), 100, 43, 4210752);
|
||||||
builder.drawText(matrixStack, this, new TranslatableText("gui.techreborn.unit.out"), 140, 43, 4210752);
|
builder.drawText(matrixStack, this, new TranslatableText("gui.techreborn.unit.out"), 140, 43, 4210752);
|
||||||
|
|
||||||
if (storageEntity.isEmpty() && !storageEntity.isLocked()) {
|
|
||||||
|
int storedAmount = storageEntity.storedAmount;
|
||||||
|
|
||||||
|
if (storedAmount == 0 && !storageEntity.isLocked()) {
|
||||||
textRenderer.draw(matrixStack, new TranslatableText("techreborn.tooltip.unit.empty"), 10, 20, 4210752);
|
textRenderer.draw(matrixStack, new TranslatableText("techreborn.tooltip.unit.empty"), 10, 20, 4210752);
|
||||||
} else {
|
} else {
|
||||||
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.storage.store"), 10, 20, 4210752);
|
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.storage.store"), 10, 20, 4210752);
|
||||||
textRenderer.draw(matrixStack, storageEntity.getDisplayedStack().getName(), 10, 30, 4210752);
|
textRenderer.draw(matrixStack, storageEntity.getDisplayedStack().getName(), 10, 30, 4210752);
|
||||||
|
|
||||||
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.storage.amount"), 10, 50, 4210752);
|
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.storage.amount"), 10, 50, 4210752);
|
||||||
textRenderer.draw(matrixStack, String.valueOf(storageEntity.getCurrentCapacity()), 10, 60, 4210752);
|
textRenderer.draw(matrixStack, String.valueOf(storedAmount), 10, 60, 4210752);
|
||||||
|
|
||||||
String percentFilled = String.valueOf((int) ((double) storageEntity.getCurrentCapacity() / (double) storageEntity.getMaxCapacity() * 100));
|
String percentFilled = String.valueOf((int) ((double) storedAmount / (double) storageEntity.getMaxCapacity() * 100));
|
||||||
|
|
||||||
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.unit.used").append(percentFilled + "%"), 10, 70, 4210752);
|
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.unit.used").append(percentFilled + "%"), 10, 70, 4210752);
|
||||||
|
|
||||||
|
|
|
@ -24,21 +24,17 @@
|
||||||
|
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import reborncore.client.multiblock.Multiblock;
|
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import techreborn.blockentity.machine.multiblock.VacuumFreezerBlockEntity;
|
import techreborn.blockentity.machine.multiblock.VacuumFreezerBlockEntity;
|
||||||
import techreborn.init.TRContent;
|
|
||||||
|
|
||||||
public class GuiVacuumFreezer extends GuiBase<BuiltScreenHandler> {
|
public class GuiVacuumFreezer extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
VacuumFreezerBlockEntity blockEntity;
|
private final VacuumFreezerBlockEntity blockEntity;
|
||||||
|
|
||||||
public GuiVacuumFreezer(int syncID, final PlayerEntity player, final VacuumFreezerBlockEntity blockEntity) {
|
public GuiVacuumFreezer(int syncID, final PlayerEntity player, final VacuumFreezerBlockEntity blockEntity) {
|
||||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||||
|
@ -59,7 +55,7 @@ public class GuiVacuumFreezer extends GuiBase<BuiltScreenHandler> {
|
||||||
drawOutputSlot(matrixStack, 101, 45, layer);
|
drawOutputSlot(matrixStack, 101, 45, layer);
|
||||||
|
|
||||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||||
if (blockEntity.getMultiBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +66,7 @@ public class GuiVacuumFreezer extends GuiBase<BuiltScreenHandler> {
|
||||||
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||||
|
|
||||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||||
if (blockEntity.getMultiBlock()) {
|
if (blockEntity.isMultiblockValid()) {
|
||||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||||
} else {
|
} else {
|
||||||
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
||||||
|
@ -81,51 +77,6 @@ public class GuiVacuumFreezer extends GuiBase<BuiltScreenHandler> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY) {
|
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY) {
|
||||||
if (hideGuiElements()) return;
|
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||||
if (blockEntity.renderMultiblock == null) {
|
|
||||||
{
|
|
||||||
// This code here makes a basic multiblock and then sets to the selected one.
|
|
||||||
final Multiblock multiblock = new Multiblock();
|
|
||||||
BlockState advancedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
|
||||||
BlockState industrialCasing = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState();
|
|
||||||
|
|
||||||
addComponent(0, -1, 0, advancedCasing, multiblock);
|
|
||||||
addComponent(1, -1, 0, advancedCasing, multiblock);
|
|
||||||
addComponent(0, -1, 1, advancedCasing, multiblock);
|
|
||||||
addComponent(-1, -1, 0, advancedCasing, multiblock);
|
|
||||||
addComponent(0, -1, -1, advancedCasing, multiblock);
|
|
||||||
addComponent(-1, -1, -1, advancedCasing, multiblock);
|
|
||||||
addComponent(-1, -1, 1, advancedCasing, multiblock);
|
|
||||||
addComponent(1, -1, -1, advancedCasing, multiblock);
|
|
||||||
addComponent(1, -1, 1, advancedCasing, multiblock);
|
|
||||||
|
|
||||||
addComponent(1, -2, 0, industrialCasing, multiblock);
|
|
||||||
addComponent(0, -2, 1, industrialCasing, multiblock);
|
|
||||||
addComponent(-1, -2, 0, industrialCasing, multiblock);
|
|
||||||
addComponent(0, -2, -1, industrialCasing, multiblock);
|
|
||||||
addComponent(-1, -2, -1, industrialCasing, multiblock);
|
|
||||||
addComponent(-1, -2, 1, industrialCasing, multiblock);
|
|
||||||
addComponent(1, -2, -1, industrialCasing, multiblock);
|
|
||||||
addComponent(1, -2, 1, industrialCasing, multiblock);
|
|
||||||
|
|
||||||
addComponent(0, -3, 0, advancedCasing, multiblock);
|
|
||||||
addComponent(1, -3, 0, advancedCasing, multiblock);
|
|
||||||
addComponent(0, -3, 1, advancedCasing, multiblock);
|
|
||||||
addComponent(-1, -3, 0, advancedCasing, multiblock);
|
|
||||||
addComponent(0, -3, -1, advancedCasing, multiblock);
|
|
||||||
addComponent(-1, -3, -1, advancedCasing, multiblock);
|
|
||||||
addComponent(-1, -3, 1, advancedCasing, multiblock);
|
|
||||||
addComponent(1, -3, -1, advancedCasing, multiblock);
|
|
||||||
addComponent(1, -3, 1, advancedCasing, multiblock);
|
|
||||||
|
|
||||||
blockEntity.renderMultiblock = multiblock;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
blockEntity.renderMultiblock = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
|
||||||
multiblock.addComponent(new BlockPos(x, y, z), blockState);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,9 @@ import java.util.function.Supplier;
|
||||||
public abstract class BaseDynamicFluidBakedModel implements BakedModel, FabricBakedModel {
|
public abstract class BaseDynamicFluidBakedModel implements BakedModel, FabricBakedModel {
|
||||||
|
|
||||||
public abstract ModelIdentifier getBaseModel();
|
public abstract ModelIdentifier getBaseModel();
|
||||||
|
|
||||||
public abstract ModelIdentifier getBackgroundModel();
|
public abstract ModelIdentifier getBackgroundModel();
|
||||||
|
|
||||||
public abstract ModelIdentifier getFluidModel();
|
public abstract ModelIdentifier getFluidModel();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
package techreborn.client.render.entitys;
|
package techreborn.client.render.entitys;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.render.OverlayTexture;
|
import net.minecraft.client.render.OverlayTexture;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.WorldRenderer;
|
import net.minecraft.client.render.WorldRenderer;
|
||||||
|
@ -54,6 +55,8 @@ public class StorageUnitRenderer extends BlockEntityRenderer<StorageUnitBaseBloc
|
||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Item rendering
|
||||||
matrices.push();
|
matrices.push();
|
||||||
Direction direction = storage.getFacing();
|
Direction direction = storage.getFacing();
|
||||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion((direction.getHorizontal() - 2) * 90F));
|
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion((direction.getHorizontal() - 2) * 90F));
|
||||||
|
@ -73,5 +76,30 @@ public class StorageUnitRenderer extends BlockEntityRenderer<StorageUnitBaseBloc
|
||||||
int lightAbove = WorldRenderer.getLightmapCoordinates(storage.getWorld(), storage.getPos().offset(storage.getFacing()));
|
int lightAbove = WorldRenderer.getLightmapCoordinates(storage.getWorld(), storage.getPos().offset(storage.getFacing()));
|
||||||
MinecraftClient.getInstance().getItemRenderer().renderItem(stack, ModelTransformation.Mode.FIXED, lightAbove, OverlayTexture.DEFAULT_UV, matrices, vertexConsumers);
|
MinecraftClient.getInstance().getItemRenderer().renderItem(stack, ModelTransformation.Mode.FIXED, lightAbove, OverlayTexture.DEFAULT_UV, matrices, vertexConsumers);
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
|
|
||||||
|
// Text rendering
|
||||||
|
matrices.push();
|
||||||
|
TextRenderer textRenderer = this.dispatcher.getTextRenderer();
|
||||||
|
Direction facing = storage.getFacing();
|
||||||
|
|
||||||
|
matrices.translate(0.5, 0.5, 0.5); // Translate center
|
||||||
|
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-facing.rotateYCounterclockwise().asRotation() + 90)); // Rotate depending on face
|
||||||
|
matrices.translate(0, 0, -0.505); // Translate forward
|
||||||
|
|
||||||
|
matrices.scale(-0.01f, -0.01F, -0.01f);
|
||||||
|
|
||||||
|
float xPosition;
|
||||||
|
|
||||||
|
// Render item count
|
||||||
|
String count = String.valueOf(storage.storedAmount);
|
||||||
|
xPosition = (float) (-textRenderer.getWidth(count) / 2);
|
||||||
|
textRenderer.draw(count, xPosition, -4f + 40, 0, false, matrices.peek().getModel(), vertexConsumers, false, 0, light);
|
||||||
|
|
||||||
|
// Render name
|
||||||
|
String item = stack.getName().asTruncatedString(18);
|
||||||
|
xPosition = (float) (-textRenderer.getWidth(item) / 2);
|
||||||
|
textRenderer.draw(item, xPosition, -4f - 40, 0, false, matrices.peek().getModel(), vertexConsumers, false, 0, light);
|
||||||
|
|
||||||
|
matrices.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ import techreborn.init.TRContent;
|
||||||
|
|
||||||
public class DestructoPackScreenHandler extends ScreenHandler {
|
public class DestructoPackScreenHandler extends ScreenHandler {
|
||||||
|
|
||||||
private PlayerEntity player;
|
private final PlayerEntity player;
|
||||||
private RebornInventory<?> inv;
|
private final RebornInventory<?> inv;
|
||||||
|
|
||||||
public DestructoPackScreenHandler(int syncID, PlayerEntity player) {
|
public DestructoPackScreenHandler(int syncID, PlayerEntity player) {
|
||||||
super(null, syncID);
|
super(null, syncID);
|
||||||
|
|
|
@ -37,19 +37,16 @@ public class FurnaceFuelSlot extends BaseSlot {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(ItemStack stack)
|
public boolean canInsert(ItemStack stack) {
|
||||||
{
|
|
||||||
return AbstractFurnaceBlockEntity.canUseAsFuel(stack) || isBucket(stack);
|
return AbstractFurnaceBlockEntity.canUseAsFuel(stack) || isBucket(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxStackAmount(ItemStack stack)
|
public int getMaxStackAmount(ItemStack stack) {
|
||||||
{
|
|
||||||
return isBucket(stack) ? 1 : super.getMaxStackAmount(stack);
|
return isBucket(stack) ? 1 : super.getMaxStackAmount(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBucket(ItemStack stack)
|
public static boolean isBucket(ItemStack stack) {
|
||||||
{
|
|
||||||
return stack.getItem() == Items.BUCKET;
|
return stack.getItem() == Items.BUCKET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,8 @@ public class TRRecipeParser {
|
||||||
}
|
}
|
||||||
return new StackIngredient(Collections.singletonList(stack), amount, tag, requireEmpty);
|
return new StackIngredient(Collections.singletonList(stack), amount, tag, requireEmpty);
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else throw new CDSyntaxError("Illegal object passed to TechReborn ingredient parser of type " + input.getClass().getName());
|
throw new CDSyntaxError("Illegal object passed to TechReborn ingredient parser of type " + input.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FluidInstance parseFluid(String fluid) {
|
public static FluidInstance parseFluid(String fluid) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ import java.util.concurrent.Executor;
|
||||||
|
|
||||||
public class TRTweaker implements Tweaker {
|
public class TRTweaker implements Tweaker {
|
||||||
public static final TRTweaker INSTANCE = new TRTweaker();
|
public static final TRTweaker INSTANCE = new TRTweaker();
|
||||||
private RecipeTweaker tweaker = RecipeTweaker.INSTANCE;
|
private final RecipeTweaker tweaker = RecipeTweaker.INSTANCE;
|
||||||
private JsonObject debug;
|
private JsonObject debug;
|
||||||
|
|
||||||
List<FluidGeneratorRecipe> added = new ArrayList<>();
|
List<FluidGeneratorRecipe> added = new ArrayList<>();
|
||||||
|
@ -112,6 +112,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a fluid ingredient
|
* Create a fluid ingredient
|
||||||
|
*
|
||||||
* @param fluid The fluid required.
|
* @param fluid The fluid required.
|
||||||
* @param holders The fluid-holding items the fluid can be in, or [] for any.
|
* @param holders The fluid-holding items the fluid can be in, or [] for any.
|
||||||
* @param amount The amount of fluid needed, or -1 for any.
|
* @param amount The amount of fluid needed, or -1 for any.
|
||||||
|
@ -136,6 +137,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a generic TechReborn recipe.
|
* Register a generic TechReborn recipe.
|
||||||
|
*
|
||||||
* @param type The type of RebornRecipe to add.
|
* @param type The type of RebornRecipe to add.
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
|
@ -169,6 +171,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to smelt in an alloy smelter.
|
* Register a recipe to smelt in an alloy smelter.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -180,6 +183,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to assemble in an assembling machine.
|
* Register a recipe to assemble in an assembling machine.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -191,6 +195,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to smelt in a TechReborn blast furnace.
|
* Register a recipe to smelt in a TechReborn blast furnace.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -216,6 +221,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in a centrifuge.
|
* Register a recipe to process in a centrifuge.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -227,6 +233,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in a chemical reactor.
|
* Register a recipe to process in a chemical reactor.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -238,6 +245,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to compress in a compressor.
|
* Register a recipe to compress in a compressor.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -249,6 +257,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to distil in a distillation tower.
|
* Register a recipe to distil in a distillation tower.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -260,6 +269,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to extract in an extractor.
|
* Register a recipe to extract in an extractor.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -271,6 +281,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in a grinder.
|
* Register a recipe to process in a grinder.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -282,6 +293,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in an implosion compressor.
|
* Register a recipe to process in an implosion compressor.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -293,6 +305,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in an industrial electrolyzer.
|
* Register a recipe to process in an industrial electrolyzer.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -304,6 +317,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in an industrial grinder.
|
* Register a recipe to process in an industrial grinder.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -328,6 +342,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in an industrial grinder.
|
* Register a recipe to process in an industrial grinder.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -354,6 +369,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in an industria sawmilll.
|
* Register a recipe to process in an industria sawmilll.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -378,6 +394,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in an industrial sawmill.
|
* Register a recipe to process in an industrial sawmill.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -404,6 +421,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in a recycler.
|
* Register a recipe to process in a recycler.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -415,6 +433,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to get from a scrapbox. Input is always a scrap box.
|
* Register a recipe to get from a scrapbox. Input is always a scrap box.
|
||||||
|
*
|
||||||
* @param output The outputs of the recipe.
|
* @param output The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
* @param time How many ticks (1/20 of a second) to process for.
|
* @param time How many ticks (1/20 of a second) to process for.
|
||||||
|
@ -425,6 +444,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in a vacuum freezer.
|
* Register a recipe to process in a vacuum freezer.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -436,6 +456,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in a fluid replicator.
|
* Register a recipe to process in a fluid replicator.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
* @param time How many ticks (1/20 of a second) to process for.
|
* @param time How many ticks (1/20 of a second) to process for.
|
||||||
|
@ -457,6 +478,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in a fusion reactor.
|
* Register a recipe to process in a fusion reactor.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -483,6 +505,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a rolling machine recipe from a 2D array of inputs, like a standard CraftTweaker recipe.
|
* Register a rolling machine recipe from a 2D array of inputs, like a standard CraftTweaker recipe.
|
||||||
|
*
|
||||||
* @param inputs the 2D array (array of arrays) of inputs to use.
|
* @param inputs the 2D array (array of arrays) of inputs to use.
|
||||||
* @param output The output of the recipe.
|
* @param output The output of the recipe.
|
||||||
*/
|
*/
|
||||||
|
@ -499,6 +522,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a rolling machine recipe from a 1D array of inputs.
|
* Register a rolling machine recipe from a 1D array of inputs.
|
||||||
|
*
|
||||||
* @param inputs The input item or tag ids required in order: left to right, top to bottom.
|
* @param inputs The input item or tag ids required in order: left to right, top to bottom.
|
||||||
* @param output The output of the recipe.
|
* @param output The output of the recipe.
|
||||||
* @param width How many rows the recipe needs.
|
* @param width How many rows the recipe needs.
|
||||||
|
@ -522,6 +546,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a rolling machine recipe from a pattern and dictionary.
|
* Register a rolling machine recipe from a pattern and dictionary.
|
||||||
|
*
|
||||||
* @param pattern A crafting pattern like one you'd find in a vanilla recipe JSON.
|
* @param pattern A crafting pattern like one you'd find in a vanilla recipe JSON.
|
||||||
* @param dictionary A map of single characters to item or tag ids.
|
* @param dictionary A map of single characters to item or tag ids.
|
||||||
* @param output The output of the recipe.
|
* @param output The output of the recipe.
|
||||||
|
@ -543,6 +568,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in a solid canning machine.
|
* Register a recipe to process in a solid canning machine.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -554,6 +580,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a recipe to process in a wire mill.
|
* Register a recipe to process in a wire mill.
|
||||||
|
*
|
||||||
* @param inputs The input ingredients for the recipe.
|
* @param inputs The input ingredients for the recipe.
|
||||||
* @param outputs The outputs of the recipe.
|
* @param outputs The outputs of the recipe.
|
||||||
* @param power How much power the recipe consumes per tick.
|
* @param power How much power the recipe consumes per tick.
|
||||||
|
@ -565,6 +592,7 @@ public class TRTweaker implements Tweaker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a fluid to process in a fluid generator.
|
* Register a fluid to process in a fluid generator.
|
||||||
|
*
|
||||||
* @param generator The type of generator: thermal, gas, diesel, semifluid, or plasma.
|
* @param generator The type of generator: thermal, gas, diesel, semifluid, or plasma.
|
||||||
* @param fluid The fluid to add a recipe for.
|
* @param fluid The fluid to add a recipe for.
|
||||||
* @param euPerMB How much EU should be generated per millibucket of fluid.
|
* @param euPerMB How much EU should be generated per millibucket of fluid.
|
||||||
|
|
|
@ -1,131 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TechReborn
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package techreborn.compat.rei;
|
|
||||||
|
|
||||||
import me.shedaniel.math.Point;
|
|
||||||
import me.shedaniel.math.Rectangle;
|
|
||||||
import me.shedaniel.rei.api.EntryStack;
|
|
||||||
import me.shedaniel.rei.api.RecipeCategory;
|
|
||||||
import me.shedaniel.rei.api.widgets.Label;
|
|
||||||
import me.shedaniel.rei.api.widgets.Widgets;
|
|
||||||
import me.shedaniel.rei.gui.entries.RecipeEntry;
|
|
||||||
import me.shedaniel.rei.gui.entries.SimpleRecipeEntry;
|
|
||||||
import me.shedaniel.rei.gui.widget.Widget;
|
|
||||||
import net.minecraft.client.resource.language.I18n;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.text.LiteralText;
|
|
||||||
import net.minecraft.text.Text;
|
|
||||||
import net.minecraft.text.TranslatableText;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCategory<MachineRecipeDisplay<R>> {
|
|
||||||
|
|
||||||
private final RebornRecipeType<R> rebornRecipeType;
|
|
||||||
private int recipeLines;
|
|
||||||
|
|
||||||
MachineRecipeCategory(RebornRecipeType<R> rebornRecipeType) {
|
|
||||||
this(rebornRecipeType, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
MachineRecipeCategory(RebornRecipeType<R> rebornRecipeType, int lines) {
|
|
||||||
this.rebornRecipeType = rebornRecipeType;
|
|
||||||
this.recipeLines = lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Identifier getIdentifier() {
|
|
||||||
return rebornRecipeType.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCategoryName() {
|
|
||||||
return I18n.translate(rebornRecipeType.getName().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntryStack getLogo() {
|
|
||||||
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RecipeEntry getSimpleRenderer(MachineRecipeDisplay<R> recipe) {
|
|
||||||
return SimpleRecipeEntry.create(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getOutputEntries());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Widget> setupDisplay(MachineRecipeDisplay<R> machineRecipe, Rectangle bounds) {
|
|
||||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - recipeLines * 12 - 1);
|
|
||||||
|
|
||||||
List<Widget> widgets = new LinkedList<>();
|
|
||||||
widgets.add(Widgets.createRecipeBase(bounds));
|
|
||||||
widgets.add(Widgets.createArrow(new Point(startPoint.x + 26, startPoint.y + 1)).animationDurationTicks(machineRecipe.getTime()));
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
|
|
||||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20))).entries(inputs).markInput());
|
|
||||||
}
|
|
||||||
|
|
||||||
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
|
|
||||||
Label costLabel;
|
|
||||||
widgets.add(costLabel = Widgets.createLabel(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)), energyPerTick));
|
|
||||||
costLabel.shadow(false);
|
|
||||||
costLabel.color(0xFF404040, 0xFFBBBBBB);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
for (EntryStack outputs : machineRecipe.getOutputEntries()) {
|
|
||||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 1 + (i++ * 20))).entry(outputs).markInput());
|
|
||||||
}
|
|
||||||
|
|
||||||
int heat = machineRecipe.getHeat();
|
|
||||||
if (heat > 0) {
|
|
||||||
Text neededHeat = new LiteralText(String.valueOf(heat)).append(" ").append(new TranslatableText("techreborn.jei.recipe.heat"));
|
|
||||||
Label heatLabel;
|
|
||||||
widgets.add(heatLabel = Widgets.createLabel(new Point(startPoint.x + 61, startPoint.y + 1 + (i++ * 20)), neededHeat));
|
|
||||||
heatLabel.shadow(false);
|
|
||||||
heatLabel.color(0xFF404040, 0xFFBBBBBB);
|
|
||||||
}
|
|
||||||
|
|
||||||
return widgets;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDisplayHeight() {
|
|
||||||
if (recipeLines == 1) {
|
|
||||||
return 37;
|
|
||||||
} else if (recipeLines == 3) {
|
|
||||||
return 80;
|
|
||||||
} else if (recipeLines == 4) {
|
|
||||||
return 105;
|
|
||||||
}
|
|
||||||
return 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -40,8 +40,8 @@ import java.util.Optional;
|
||||||
public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDisplay {
|
public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDisplay {
|
||||||
|
|
||||||
private final R recipe;
|
private final R recipe;
|
||||||
private List<List<EntryStack>> inputs;
|
private final List<List<EntryStack>> inputs;
|
||||||
private List<EntryStack> outputs;
|
private final List<EntryStack> outputs;
|
||||||
private int energy = 0;
|
private int energy = 0;
|
||||||
private int heat = 0;
|
private int heat = 0;
|
||||||
private int time = 0;
|
private int time = 0;
|
||||||
|
@ -49,8 +49,8 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
|
||||||
|
|
||||||
public MachineRecipeDisplay(R recipe) {
|
public MachineRecipeDisplay(R recipe) {
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), RebornEntryStack::create));
|
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> EntryStack.ofItemStacks(ing.getPreviewStacks()));
|
||||||
this.outputs = CollectionUtils.map(recipe.getOutputs(), RebornEntryStack::create);
|
this.outputs = EntryStack.ofItemStacks(recipe.getOutputs());
|
||||||
this.time = recipe.getTime();
|
this.time = recipe.getTime();
|
||||||
this.energy = recipe.getPower();
|
this.energy = recipe.getPower();
|
||||||
if (recipe instanceof BlastFurnaceRecipe) {
|
if (recipe instanceof BlastFurnaceRecipe) {
|
||||||
|
@ -58,7 +58,7 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
|
||||||
}
|
}
|
||||||
if (recipe instanceof RebornFluidRecipe) {
|
if (recipe instanceof RebornFluidRecipe) {
|
||||||
this.fluidInstance = ((RebornFluidRecipe) recipe).getFluidInstance();
|
this.fluidInstance = ((RebornFluidRecipe) recipe).getFluidInstance();
|
||||||
inputs.add(Collections.singletonList(RebornEntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue())));
|
inputs.add(Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue())));
|
||||||
}
|
}
|
||||||
for (List<EntryStack> entries : inputs)
|
for (List<EntryStack> entries : inputs)
|
||||||
for (EntryStack stack : entries)
|
for (EntryStack stack : entries)
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TechReborn
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package techreborn.compat.rei;
|
|
||||||
|
|
||||||
import me.shedaniel.rei.api.EntryStack;
|
|
||||||
import net.minecraft.fluid.Fluid;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import reborncore.common.fluid.container.ItemFluidInfo;
|
|
||||||
import techreborn.utils.FluidUtils;
|
|
||||||
|
|
||||||
public interface RebornEntryStack extends EntryStack {
|
|
||||||
|
|
||||||
static EntryStack create(Fluid fluid, int amount) {
|
|
||||||
return new RebornFluidEntryStack(fluid, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
static EntryStack create(ItemStack stack) {
|
|
||||||
return new RebornItemEntryStack(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean compareFluids(EntryStack a, Object obj) {
|
|
||||||
if (!(obj instanceof EntryStack)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Fluid fluid1, fluid2;
|
|
||||||
if (a.getItem() instanceof ItemFluidInfo) {
|
|
||||||
fluid1 = ((ItemFluidInfo) a.getItem()).getFluid(a.getItemStack());
|
|
||||||
} else {
|
|
||||||
fluid1 = a.getFluid();
|
|
||||||
}
|
|
||||||
|
|
||||||
EntryStack b = (EntryStack) obj;
|
|
||||||
if (b.getItem() instanceof ItemFluidInfo) {
|
|
||||||
fluid2 = ((ItemFluidInfo) b.getItem()).getFluid(b.getItemStack());
|
|
||||||
} else {
|
|
||||||
fluid2 = b.getFluid();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fluid1 != null && fluid2 != null) {
|
|
||||||
return FluidUtils.fluidEquals(fluid1, fluid2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TechReborn
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package techreborn.compat.rei;
|
|
||||||
|
|
||||||
import me.shedaniel.rei.impl.FluidEntryStack;
|
|
||||||
import net.minecraft.fluid.Fluid;
|
|
||||||
|
|
||||||
public class RebornFluidEntryStack extends FluidEntryStack {
|
|
||||||
|
|
||||||
public RebornFluidEntryStack(Fluid fluid, int amount) {
|
|
||||||
super(fluid, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (super.equals(obj)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return RebornEntryStack.compareFluids(this, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TechReborn
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package techreborn.compat.rei;
|
|
||||||
|
|
||||||
import me.shedaniel.rei.impl.ItemEntryStack;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
public class RebornItemEntryStack extends ItemEntryStack {
|
|
||||||
|
|
||||||
public RebornItemEntryStack(ItemStack itemStack) {
|
|
||||||
super(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (super.equals(obj)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return RebornEntryStack.compareFluids(this, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -24,20 +24,41 @@
|
||||||
|
|
||||||
package techreborn.compat.rei;
|
package techreborn.compat.rei;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import me.shedaniel.math.Point;
|
||||||
import me.shedaniel.math.Rectangle;
|
import me.shedaniel.math.Rectangle;
|
||||||
import me.shedaniel.rei.api.*;
|
import me.shedaniel.rei.api.*;
|
||||||
|
import me.shedaniel.rei.api.fluid.FluidSupportProvider;
|
||||||
import me.shedaniel.rei.api.plugins.REIPluginV0;
|
import me.shedaniel.rei.api.plugins.REIPluginV0;
|
||||||
|
import me.shedaniel.rei.api.widgets.Tooltip;
|
||||||
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
|
import me.shedaniel.rei.gui.widget.EntryWidget;
|
||||||
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
|
import me.shedaniel.rei.impl.RenderingEntry;
|
||||||
|
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.gui.DrawableHelper;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.texture.Sprite;
|
||||||
|
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraft.item.ItemConvertible;
|
import net.minecraft.item.ItemConvertible;
|
||||||
import net.minecraft.recipe.Recipe;
|
import net.minecraft.recipe.Recipe;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.blockentity.IUpgradeable;
|
import reborncore.api.blockentity.IUpgradeable;
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.gui.builder.slot.GuiTab;
|
import reborncore.client.gui.builder.slot.GuiTab;
|
||||||
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
import reborncore.common.crafting.RecipeManager;
|
import reborncore.common.crafting.RecipeManager;
|
||||||
|
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||||
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.api.generator.EFluidGenerator;
|
import techreborn.api.generator.EFluidGenerator;
|
||||||
import techreborn.api.generator.GeneratorRecipeHelper;
|
import techreborn.api.generator.GeneratorRecipeHelper;
|
||||||
|
@ -47,6 +68,7 @@ import techreborn.compat.rei.fluidgenerator.FluidGeneratorRecipeCategory;
|
||||||
import techreborn.compat.rei.fluidgenerator.FluidGeneratorRecipeDisplay;
|
import techreborn.compat.rei.fluidgenerator.FluidGeneratorRecipeDisplay;
|
||||||
import techreborn.compat.rei.fluidreplicator.FluidReplicatorRecipeCategory;
|
import techreborn.compat.rei.fluidreplicator.FluidReplicatorRecipeCategory;
|
||||||
import techreborn.compat.rei.fluidreplicator.FluidReplicatorRecipeDisplay;
|
import techreborn.compat.rei.fluidreplicator.FluidReplicatorRecipeDisplay;
|
||||||
|
import techreborn.compat.rei.machine.*;
|
||||||
import techreborn.compat.rei.rollingmachine.RollingMachineCategory;
|
import techreborn.compat.rei.rollingmachine.RollingMachineCategory;
|
||||||
import techreborn.compat.rei.rollingmachine.RollingMachineDisplay;
|
import techreborn.compat.rei.rollingmachine.RollingMachineDisplay;
|
||||||
import techreborn.init.ModRecipes;
|
import techreborn.init.ModRecipes;
|
||||||
|
@ -95,26 +117,26 @@ public class ReiPlugin implements REIPluginV0 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPluginCategories(RecipeHelper recipeHelper) {
|
public void registerPluginCategories(RecipeHelper recipeHelper) {
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.ALLOY_SMELTER));
|
recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.ALLOY_SMELTER));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.ASSEMBLING_MACHINE));
|
recipeHelper.registerCategory(new AssemblingMachineCategory<>(ModRecipes.ASSEMBLING_MACHINE));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.BLAST_FURNACE));
|
recipeHelper.registerCategory(new BlastFurnaceCategory<>(ModRecipes.BLAST_FURNACE));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.CENTRIFUGE, 4));
|
recipeHelper.registerCategory(new IndustrialCentrifugeCategory<>(ModRecipes.CENTRIFUGE));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.CHEMICAL_REACTOR));
|
recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.CHEMICAL_REACTOR));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.COMPRESSOR, 1));
|
recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.COMPRESSOR));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.DISTILLATION_TOWER, 3));
|
recipeHelper.registerCategory(new DistillationTowerCategory<>(ModRecipes.DISTILLATION_TOWER));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.EXTRACTOR, 1));
|
recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.EXTRACTOR));
|
||||||
recipeHelper.registerCategory(new FluidReplicatorRecipeCategory(ModRecipes.FLUID_REPLICATOR));
|
recipeHelper.registerCategory(new FluidReplicatorRecipeCategory(ModRecipes.FLUID_REPLICATOR));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.FUSION_REACTOR, 2));
|
recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.FUSION_REACTOR));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.GRINDER, 1));
|
recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.GRINDER));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.IMPLOSION_COMPRESSOR));
|
recipeHelper.registerCategory(new ImplosionCompressorCategory<>(ModRecipes.IMPLOSION_COMPRESSOR));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.INDUSTRIAL_ELECTROLYZER, 4));
|
recipeHelper.registerCategory(new ElectrolyzerCategory<>(ModRecipes.INDUSTRIAL_ELECTROLYZER));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.INDUSTRIAL_GRINDER, 3));
|
recipeHelper.registerCategory(new GrinderCategory<>(ModRecipes.INDUSTRIAL_GRINDER));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.INDUSTRIAL_SAWMILL, 3));
|
recipeHelper.registerCategory(new SawmillCategory<>(ModRecipes.INDUSTRIAL_SAWMILL));
|
||||||
recipeHelper.registerCategory(new RollingMachineCategory(ModRecipes.ROLLING_MACHINE));
|
recipeHelper.registerCategory(new RollingMachineCategory(ModRecipes.ROLLING_MACHINE));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.SCRAPBOX));
|
recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.SCRAPBOX));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.SOLID_CANNING_MACHINE));
|
recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.SOLID_CANNING_MACHINE));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.VACUUM_FREEZER, 1));
|
recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.VACUUM_FREEZER));
|
||||||
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.WIRE_MILL, 1));
|
recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.WIRE_MILL));
|
||||||
|
|
||||||
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.THERMAL_GENERATOR));
|
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.THERMAL_GENERATOR));
|
||||||
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.GAS_TURBINE));
|
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.GAS_TURBINE));
|
||||||
|
@ -160,20 +182,37 @@ public class ReiPlugin implements REIPluginV0 {
|
||||||
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.DIESEL_GENERATOR.name), EntryStack.create(Machine.DIESEL_GENERATOR));
|
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.DIESEL_GENERATOR.name), EntryStack.create(Machine.DIESEL_GENERATOR));
|
||||||
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.SEMI_FLUID_GENERATOR.name), EntryStack.create(Machine.SEMI_FLUID_GENERATOR));
|
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.SEMI_FLUID_GENERATOR.name), EntryStack.create(Machine.SEMI_FLUID_GENERATOR));
|
||||||
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.PLASMA_GENERATOR.name), EntryStack.create(Machine.PLASMA_GENERATOR));
|
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.PLASMA_GENERATOR.name), EntryStack.create(Machine.PLASMA_GENERATOR));
|
||||||
|
|
||||||
|
registerFluidSupport();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
|
private void registerFluidSupport() {
|
||||||
|
FluidSupportProvider.INSTANCE.registerFluidProvider(new FluidSupportProvider.FluidProvider() {
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public EntryStack itemToFluid(@NotNull EntryStack itemStack) {
|
||||||
|
if (itemStack.getItem() instanceof ItemFluidInfo) {
|
||||||
|
Fluid fluid = ((ItemFluidInfo) itemStack.getItem()).getFluid(itemStack.getItemStack());
|
||||||
|
if (fluid != null)
|
||||||
|
return EntryStack.create(fluid);
|
||||||
|
}
|
||||||
|
return EntryStack.empty();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postRegister() {
|
public void postRegister() {
|
||||||
// Alright we are going to apply check tags to cells, this should not take long at all.
|
// Alright we are going to apply check tags to cells, this should not take long at all.
|
||||||
// Check Tags will not check the amount of the ItemStack, but will enable checking their tags.
|
// Check Tags will not check the amount of the ItemStack, but will enable checking their tags.
|
||||||
for (EntryStack stack : EntryRegistry.getInstance().getStacksList())
|
EntryRegistry.getInstance().getEntryStacks().forEach(ReiPlugin::applyCellEntry);
|
||||||
applyCellEntry(stack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyCellEntry(EntryStack stack) {
|
public static void applyCellEntry(EntryStack stack) {
|
||||||
// getItem can be null but this works
|
// getItem can be null but this works
|
||||||
if (stack.getItem() == TRContent.CELL)
|
if (stack.getItem() == TRContent.CELL)
|
||||||
stack.addSetting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE);
|
stack.setting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerFluidGeneratorDisplays(RecipeHelper recipeHelper, EFluidGenerator generator, Machine machine) {
|
private void registerFluidGeneratorDisplays(RecipeHelper recipeHelper, EFluidGenerator generator, Machine machine) {
|
||||||
|
@ -200,7 +239,6 @@ public class ReiPlugin implements REIPluginV0 {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
recipeHelper.registerRecipes(recipeType.getName(), (Predicate<Recipe>) recipe -> {
|
recipeHelper.registerRecipes(recipeType.getName(), (Predicate<Recipe>) recipe -> {
|
||||||
if (recipe instanceof RebornRecipe) {
|
if (recipe instanceof RebornRecipe) {
|
||||||
return ((RebornRecipe) recipe).getRebornRecipeType() == recipeType;
|
return ((RebornRecipe) recipe).getRebornRecipeType() == recipeType;
|
||||||
|
@ -236,4 +274,171 @@ public class ReiPlugin implements REIPluginV0 {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Widget createProgressBar(int x, int y, double animationDuration, GuiBuilder.ProgressDirection direction) {
|
||||||
|
return Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
|
||||||
|
MinecraftClient.getInstance().getTextureManager().bindTexture(GuiBuilder.defaultTextureSheet);
|
||||||
|
helper.drawTexture(matrices, x, y, direction.x, direction.y, direction.width, direction.height);
|
||||||
|
int j = (int) ((System.currentTimeMillis() / animationDuration) % 1.0 * 16.0);
|
||||||
|
if (j < 0) {
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (direction) {
|
||||||
|
case RIGHT:
|
||||||
|
helper.drawTexture(matrices, x, y, direction.xActive, direction.yActive, j, 10);
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
helper.drawTexture(matrices, x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
helper.drawTexture(matrices, x, y + 16 - j, direction.xActive, direction.yActive + 16 - j, 10, j);
|
||||||
|
break;
|
||||||
|
case DOWN:
|
||||||
|
helper.drawTexture(matrices, x, y, direction.xActive, direction.yActive, 10, j);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Widget createEnergyDisplay(Rectangle bounds, double energy, EntryAnimation animation, Function<Point, Tooltip> tooltipBuilder) {
|
||||||
|
return new EnergyEntryWidget(bounds, animation).entry(
|
||||||
|
new RenderingEntry() {
|
||||||
|
@Override
|
||||||
|
public void render(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable Tooltip getTooltip(Point mouse) {
|
||||||
|
return tooltipBuilder.apply(mouse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).notFavoritesInteractable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Widget createFluidDisplay(Rectangle bounds, EntryStack fluid, EntryAnimation animation) {
|
||||||
|
return new FluidEntryWidget(bounds, fluid.getFluid(), animation).entry(fluid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class EnergyEntryWidget extends EntryWidget {
|
||||||
|
private EntryAnimation animation;
|
||||||
|
|
||||||
|
protected EnergyEntryWidget(Rectangle rectangle, EntryAnimation animation) {
|
||||||
|
super(rectangle.x, rectangle.y);
|
||||||
|
this.getBounds().setBounds(rectangle);
|
||||||
|
this.animation = animation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawBackground(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||||
|
if (background) {
|
||||||
|
Rectangle bounds = getBounds();
|
||||||
|
int width = bounds.width;
|
||||||
|
int height = bounds.height;
|
||||||
|
int innerHeight = height - 2;
|
||||||
|
|
||||||
|
PowerSystem.EnergySystem displayPower = PowerSystem.getDisplayPower();
|
||||||
|
MinecraftClient.getInstance().getTextureManager().bindTexture(GuiBuilder.defaultTextureSheet);
|
||||||
|
drawTexture(matrices, bounds.x, bounds.y, displayPower.xBar - 15, displayPower.yBar - 1, width, height);
|
||||||
|
int innerDisplayHeight;
|
||||||
|
if (animation.animationType != EntryAnimationType.NONE) {
|
||||||
|
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight) / 1f);
|
||||||
|
if (animation.animationType == EntryAnimationType.DOWNWARDS)
|
||||||
|
innerDisplayHeight = innerHeight - innerDisplayHeight;
|
||||||
|
} else innerDisplayHeight = innerHeight;
|
||||||
|
drawTexture(matrices, bounds.x + 1, bounds.y + 1 + innerHeight - innerDisplayHeight, displayPower.xBar, innerHeight + displayPower.yBar - innerDisplayHeight, width - 2, innerDisplayHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawCurrentEntry(MatrixStack matrices, int mouseX, int mouseY, float delta) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class FluidEntryWidget extends EntryWidget {
|
||||||
|
private Fluid fluid;
|
||||||
|
private EntryAnimation animation;
|
||||||
|
|
||||||
|
protected FluidEntryWidget(Rectangle rectangle, Fluid fluid, EntryAnimation animation) {
|
||||||
|
super(rectangle.x, rectangle.y);
|
||||||
|
this.getBounds().setBounds(rectangle);
|
||||||
|
this.fluid = fluid;
|
||||||
|
this.animation = animation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawBackground(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||||
|
if (background) {
|
||||||
|
Rectangle bounds = getBounds();
|
||||||
|
int width = bounds.width;
|
||||||
|
int height = bounds.height;
|
||||||
|
int innerHeight = height - 2;
|
||||||
|
|
||||||
|
PowerSystem.EnergySystem displayPower = PowerSystem.getDisplayPower();
|
||||||
|
MinecraftClient.getInstance().getTextureManager().bindTexture(GuiBuilder.defaultTextureSheet);
|
||||||
|
drawTexture(matrices, bounds.x - 3, bounds.y - 3, 194, 26, width + 6, height + 6);
|
||||||
|
drawTexture(matrices, bounds.x, bounds.y, 194, 82, width, height);
|
||||||
|
int innerDisplayHeight;
|
||||||
|
if (animation.animationType != EntryAnimationType.NONE) {
|
||||||
|
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight) / 1f);
|
||||||
|
if (animation.animationType == EntryAnimationType.DOWNWARDS)
|
||||||
|
innerDisplayHeight = innerHeight - innerDisplayHeight;
|
||||||
|
} else innerDisplayHeight = innerHeight;
|
||||||
|
drawFluid(matrices, fluid, innerDisplayHeight, bounds.x + 1, bounds.y + 1, width - 2, innerHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawFluid(MatrixStack matrixStack, Fluid fluid, int drawHeight, int x, int y, int width, int height) {
|
||||||
|
MinecraftClient.getInstance().getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
|
||||||
|
y += height;
|
||||||
|
final Sprite sprite = FluidRenderHandlerRegistry.INSTANCE.get(fluid).getFluidSprites(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState())[0];
|
||||||
|
int color = FluidRenderHandlerRegistry.INSTANCE.get(fluid).getFluidColor(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState());
|
||||||
|
|
||||||
|
final int iconHeight = sprite.getHeight();
|
||||||
|
int offsetHeight = drawHeight;
|
||||||
|
|
||||||
|
RenderSystem.color3f((color >> 16 & 255) / 255.0F, (float) (color >> 8 & 255) / 255.0F, (float) (color & 255) / 255.0F);
|
||||||
|
|
||||||
|
int iteration = 0;
|
||||||
|
while (offsetHeight != 0) {
|
||||||
|
final int curHeight = Math.min(offsetHeight, iconHeight);
|
||||||
|
|
||||||
|
DrawableHelper.drawSprite(matrixStack, x, y - offsetHeight, 0, width, curHeight, sprite);
|
||||||
|
offsetHeight -= curHeight;
|
||||||
|
iteration++;
|
||||||
|
if (iteration > 50) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawCurrentEntry(MatrixStack matrices, int mouseX, int mouseY, float delta) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class EntryAnimation {
|
||||||
|
private final EntryAnimationType animationType;
|
||||||
|
private final long duration;
|
||||||
|
|
||||||
|
private EntryAnimation(EntryAnimationType animationType, long duration) {
|
||||||
|
this.animationType = animationType;
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EntryAnimation upwards(long duration) {
|
||||||
|
return new EntryAnimation(EntryAnimationType.UPWARDS, duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EntryAnimation downwards(long duration) {
|
||||||
|
return new EntryAnimation(EntryAnimationType.DOWNWARDS, duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EntryAnimation none() {
|
||||||
|
return new EntryAnimation(EntryAnimationType.NONE, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum EntryAnimationType {
|
||||||
|
UPWARDS,
|
||||||
|
DOWNWARDS,
|
||||||
|
NONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,27 +24,30 @@
|
||||||
|
|
||||||
package techreborn.compat.rei.fluidgenerator;
|
package techreborn.compat.rei.fluidgenerator;
|
||||||
|
|
||||||
import me.shedaniel.math.Point;
|
import com.google.common.collect.Lists;
|
||||||
import me.shedaniel.math.Rectangle;
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.ClientHelper;
|
||||||
import me.shedaniel.rei.api.EntryStack;
|
import me.shedaniel.rei.api.EntryStack;
|
||||||
import me.shedaniel.rei.api.RecipeCategory;
|
import me.shedaniel.rei.api.RecipeCategory;
|
||||||
import me.shedaniel.rei.api.widgets.Label;
|
import me.shedaniel.rei.api.widgets.Tooltip;
|
||||||
import me.shedaniel.rei.api.widgets.Widgets;
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
import me.shedaniel.rei.gui.widget.Widget;
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.client.resource.language.I18n;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FluidGeneratorRecipeCategory implements RecipeCategory<FluidGeneratorRecipeDisplay> {
|
public class FluidGeneratorRecipeCategory implements RecipeCategory<FluidGeneratorRecipeDisplay> {
|
||||||
|
|
||||||
private TRContent.Machine generator;
|
private final TRContent.Machine generator;
|
||||||
private Identifier identifier;
|
private final Identifier identifier;
|
||||||
|
|
||||||
public FluidGeneratorRecipeCategory(TRContent.Machine generator) {
|
public FluidGeneratorRecipeCategory(TRContent.Machine generator) {
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
|
@ -67,29 +70,19 @@ public class FluidGeneratorRecipeCategory implements RecipeCategory<FluidGenerat
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Widget> setupDisplay(FluidGeneratorRecipeDisplay machineRecipe, Rectangle bounds) {
|
public List<Widget> setupDisplay(FluidGeneratorRecipeDisplay recipeDisplay, Rectangle bounds) {
|
||||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
|
List<Widget> widgets = Lists.newArrayList();
|
||||||
|
|
||||||
List<Widget> widgets = new LinkedList<>();
|
|
||||||
widgets.add(Widgets.createRecipeBase(bounds));
|
widgets.add(Widgets.createRecipeBase(bounds));
|
||||||
widgets.add(Widgets.createArrow(new Point(startPoint.x + 26, startPoint.y + 1)).animationDurationMS(1000.0));
|
widgets.add(ReiPlugin.createEnergyDisplay(new Rectangle(bounds.x + 108, bounds.y + 8, 14, 50), recipeDisplay.getTotalEnergy(), ReiPlugin.EntryAnimation.upwards(5000), point -> {
|
||||||
|
List<Text> list = Lists.newArrayList();
|
||||||
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
|
list.add(Text.method_30163("Energy"));
|
||||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputs).markInput());
|
list.add(new TranslatableText("techreborn.jei.recipe.generator.total", recipeDisplay.getTotalEnergy()).formatted(Formatting.GRAY));
|
||||||
}
|
list.add(Text.method_30163(""));
|
||||||
|
list.add(ClientHelper.getInstance().getFormattedModFromIdentifier(new Identifier("techreborn", "")));
|
||||||
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.generator.total", machineRecipe.getTotalEnergy());
|
return Tooltip.create(point, list);
|
||||||
Label costLabel;
|
}));
|
||||||
widgets.add(costLabel = Widgets.createLabel(new Point(bounds.getCenterX(), startPoint.y + 20), energyPerTick));
|
widgets.add(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 16, bounds.y + 8, 16, 50), recipeDisplay.getInputEntries().get(0).get(0), ReiPlugin.EntryAnimation.downwards(5000)));
|
||||||
costLabel.shadow(false);
|
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 16, bounds.y + 48 - 19, 5000, GuiBuilder.ProgressDirection.RIGHT));
|
||||||
costLabel.color(0xFF404040, 0xFFBBBBBB);
|
|
||||||
|
|
||||||
return widgets;
|
return widgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDisplayHeight() {
|
|
||||||
return 37;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,22 +29,21 @@ import me.shedaniel.rei.api.EntryStack;
|
||||||
import me.shedaniel.rei.api.RecipeDisplay;
|
import me.shedaniel.rei.api.RecipeDisplay;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import techreborn.api.generator.FluidGeneratorRecipe;
|
import techreborn.api.generator.FluidGeneratorRecipe;
|
||||||
import techreborn.compat.rei.RebornEntryStack;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FluidGeneratorRecipeDisplay implements RecipeDisplay {
|
public class FluidGeneratorRecipeDisplay implements RecipeDisplay {
|
||||||
|
|
||||||
private List<List<EntryStack>> inputs;
|
private final List<List<EntryStack>> inputs;
|
||||||
private Identifier category;
|
private final Identifier category;
|
||||||
private int totalEnergy;
|
private final int totalEnergy;
|
||||||
|
|
||||||
public FluidGeneratorRecipeDisplay(FluidGeneratorRecipe recipe, Identifier category) {
|
public FluidGeneratorRecipeDisplay(FluidGeneratorRecipe recipe, Identifier category) {
|
||||||
this.category = category;
|
this.category = category;
|
||||||
this.inputs = Lists.newArrayList();
|
this.inputs = Lists.newArrayList();
|
||||||
this.totalEnergy = recipe.getEnergyPerBucket();
|
this.totalEnergy = recipe.getEnergyPerBucket();
|
||||||
inputs.add(Collections.singletonList(RebornEntryStack.create(recipe.getFluid(), 1000)));
|
inputs.add(Collections.singletonList(EntryStack.create(recipe.getFluid(), 1000)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,6 +51,11 @@ public class FluidGeneratorRecipeDisplay implements RecipeDisplay {
|
||||||
return inputs;
|
return inputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<List<EntryStack>> getRequiredEntries() {
|
||||||
|
return inputs;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<EntryStack> getOutputEntries() {
|
public List<EntryStack> getOutputEntries() {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
|
@ -65,5 +69,4 @@ public class FluidGeneratorRecipeDisplay implements RecipeDisplay {
|
||||||
public int getTotalEnergy() {
|
public int getTotalEnergy() {
|
||||||
return totalEnergy;
|
return totalEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,23 +24,27 @@
|
||||||
|
|
||||||
package techreborn.compat.rei.fluidreplicator;
|
package techreborn.compat.rei.fluidreplicator;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import me.shedaniel.math.Point;
|
import me.shedaniel.math.Point;
|
||||||
import me.shedaniel.math.Rectangle;
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.ClientHelper;
|
||||||
import me.shedaniel.rei.api.EntryStack;
|
import me.shedaniel.rei.api.EntryStack;
|
||||||
import me.shedaniel.rei.api.RecipeCategory;
|
import me.shedaniel.rei.api.RecipeCategory;
|
||||||
import me.shedaniel.rei.api.widgets.Label;
|
import me.shedaniel.rei.api.widgets.Tooltip;
|
||||||
import me.shedaniel.rei.api.widgets.Widgets;
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
import me.shedaniel.rei.gui.widget.Widget;
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.client.resource.language.I18n;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
import techreborn.api.recipe.recipes.FluidReplicatorRecipe;
|
import techreborn.api.recipe.recipes.FluidReplicatorRecipe;
|
||||||
import techreborn.compat.rei.ReiPlugin;
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.text.DecimalFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplicatorRecipeDisplay> {
|
public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplicatorRecipeDisplay> {
|
||||||
|
@ -49,7 +53,6 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplic
|
||||||
|
|
||||||
public FluidReplicatorRecipeCategory(RebornRecipeType<FluidReplicatorRecipe> recipeType) {
|
public FluidReplicatorRecipeCategory(RebornRecipeType<FluidReplicatorRecipe> recipeType) {
|
||||||
this.rebornRecipeType = recipeType;
|
this.rebornRecipeType = recipeType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,26 +71,29 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplic
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Widget> setupDisplay(FluidReplicatorRecipeDisplay machineRecipe, Rectangle bounds) {
|
public List<Widget> setupDisplay(FluidReplicatorRecipeDisplay recipeDisplay, Rectangle bounds) {
|
||||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
|
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
|
||||||
|
|
||||||
List<Widget> widgets = new LinkedList<>();
|
List<Widget> widgets = Lists.newArrayList();
|
||||||
widgets.add(Widgets.createRecipeBase(bounds));
|
widgets.add(Widgets.createRecipeBase(bounds));
|
||||||
widgets.add(Widgets.createArrow(new Point(startPoint.x + 26, startPoint.y + 1)).animationDurationTicks(machineRecipe.getTime()));
|
widgets.add(ReiPlugin.createEnergyDisplay(new Rectangle(bounds.x + 8, bounds.y + 8, 14, 50), recipeDisplay.getEnergy(), ReiPlugin.EntryAnimation.downwards(5000), point -> {
|
||||||
|
List<Text> list = Lists.newArrayList();
|
||||||
|
list.add(Text.method_30163("Energy"));
|
||||||
|
list.add(new TranslatableText("techreborn.jei.recipe.running.cost", "E", recipeDisplay.getEnergy()).formatted(Formatting.GRAY));
|
||||||
|
list.add(Text.method_30163(""));
|
||||||
|
list.add(ClientHelper.getInstance().getFormattedModFromIdentifier(new Identifier("techreborn", "")));
|
||||||
|
return Tooltip.create(point, list);
|
||||||
|
}));
|
||||||
|
|
||||||
int i = 0;
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 46, bounds.y + 26)).entries(recipeDisplay.getInputEntries().get(0)).markInput());
|
||||||
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
|
widgets.add(ReiPlugin.createProgressBar(bounds.x + 46 + 21, bounds.y + 30, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
|
||||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20))).entries(inputs).markInput());
|
widgets.add(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 46 + 46, bounds.y + 8, 16, 50), recipeDisplay.getOutputEntries().get(0), ReiPlugin.EntryAnimation.upwards(5000)));
|
||||||
}
|
|
||||||
|
|
||||||
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
|
widgets.add(Widgets.createLabel(new Point(bounds.x + 24, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
|
||||||
Label costLabel;
|
.shadow(false)
|
||||||
widgets.add(costLabel = Widgets.createLabel(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)), energyPerTick));
|
.leftAligned()
|
||||||
costLabel.shadow(false);
|
.color(0xFF404040, 0xFFBBBBBB)
|
||||||
costLabel.color(0xFF404040, 0xFFBBBBBB);
|
);
|
||||||
|
|
||||||
if (!machineRecipe.getOutputEntries().isEmpty())
|
|
||||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 1)).entries(machineRecipe.getOutputEntries()).markInput());
|
|
||||||
|
|
||||||
return widgets;
|
return widgets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,13 @@ import me.shedaniel.rei.api.EntryStack;
|
||||||
import me.shedaniel.rei.api.RecipeDisplay;
|
import me.shedaniel.rei.api.RecipeDisplay;
|
||||||
import me.shedaniel.rei.utils.CollectionUtils;
|
import me.shedaniel.rei.utils.CollectionUtils;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.fluid.container.FluidInstance;
|
import reborncore.common.fluid.container.FluidInstance;
|
||||||
import techreborn.api.recipe.recipes.FluidReplicatorRecipe;
|
import techreborn.api.recipe.recipes.FluidReplicatorRecipe;
|
||||||
import techreborn.compat.rei.RebornEntryStack;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
|
@ -41,17 +42,17 @@ import java.util.List;
|
||||||
public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
||||||
|
|
||||||
private final FluidReplicatorRecipe recipe;
|
private final FluidReplicatorRecipe recipe;
|
||||||
private List<List<EntryStack>> inputs;
|
private final List<List<EntryStack>> inputs;
|
||||||
private List<EntryStack> output;
|
private final List<EntryStack> output;
|
||||||
private FluidInstance fluidInstance;
|
private final FluidInstance fluidInstance;
|
||||||
private int energy = 0;
|
private int energy = 0;
|
||||||
private int time = 0;
|
private int time = 0;
|
||||||
|
|
||||||
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
|
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), RebornEntryStack::create));
|
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> EntryStack.ofItemStacks(ing.getPreviewStacks()));
|
||||||
this.fluidInstance = recipe.getFluidInstance();
|
this.fluidInstance = recipe.getFluidInstance();
|
||||||
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(RebornEntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()));
|
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()));
|
||||||
this.energy = recipe.getPower();
|
this.energy = recipe.getPower();
|
||||||
this.time = recipe.getTime();
|
this.time = recipe.getTime();
|
||||||
}
|
}
|
||||||
|
@ -87,4 +88,9 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
||||||
public Identifier getRecipeCategory() {
|
public Identifier getRecipeCategory() {
|
||||||
return recipe.getRebornRecipeType().getName();
|
return recipe.getRebornRecipeType().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Identifier> getRecipeLocation() {
|
||||||
|
return Optional.ofNullable(recipe).map(RebornRecipe::getId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package techreborn.compat.rei.machine;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.ClientHelper;
|
||||||
|
import me.shedaniel.rei.api.widgets.Tooltip;
|
||||||
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import techreborn.compat.rei.MachineRecipeDisplay;
|
||||||
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class AbstractEnergyConsumingMachineCategory<R extends RebornRecipe> extends AbstractMachineCategory<R> {
|
||||||
|
public AbstractEnergyConsumingMachineCategory(RebornRecipeType<R> rebornRecipeType) {
|
||||||
|
super(rebornRecipeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
|
||||||
|
List<Widget> widgets = Lists.newArrayList();
|
||||||
|
widgets.add(Widgets.createRecipeBase(bounds));
|
||||||
|
widgets.add(ReiPlugin.createEnergyDisplay(new Rectangle(bounds.x + 8, bounds.y + 8, 14, 50), recipeDisplay.getEnergy(), ReiPlugin.EntryAnimation.downwards(5000), point -> {
|
||||||
|
List<Text> list = Lists.newArrayList();
|
||||||
|
list.add(Text.method_30163("Energy"));
|
||||||
|
list.add(new TranslatableText("techreborn.jei.recipe.running.cost", "E", recipeDisplay.getEnergy()).formatted(Formatting.GRAY));
|
||||||
|
list.add(Text.method_30163(""));
|
||||||
|
list.add(ClientHelper.getInstance().getFormattedModFromIdentifier(new Identifier("techreborn", "")));
|
||||||
|
return Tooltip.create(point, list);
|
||||||
|
}));
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package techreborn.compat.rei.machine;
|
||||||
|
|
||||||
|
import me.shedaniel.rei.api.EntryStack;
|
||||||
|
import me.shedaniel.rei.api.RecipeCategory;
|
||||||
|
import me.shedaniel.rei.gui.entries.RecipeEntry;
|
||||||
|
import me.shedaniel.rei.gui.entries.SimpleRecipeEntry;
|
||||||
|
import net.minecraft.client.resource.language.I18n;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import techreborn.compat.rei.MachineRecipeDisplay;
|
||||||
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class AbstractMachineCategory<R extends RebornRecipe> implements RecipeCategory<MachineRecipeDisplay<R>> {
|
||||||
|
private final RebornRecipeType<R> rebornRecipeType;
|
||||||
|
|
||||||
|
public AbstractMachineCategory(RebornRecipeType<R> rebornRecipeType) {
|
||||||
|
this.rebornRecipeType = rebornRecipeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier getIdentifier() {
|
||||||
|
return rebornRecipeType.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategoryName() {
|
||||||
|
return I18n.translate(rebornRecipeType.getName().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntryStack getLogo() {
|
||||||
|
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RecipeEntry getSimpleRenderer(MachineRecipeDisplay<R> recipe) {
|
||||||
|
return SimpleRecipeEntry.create(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getOutputEntries());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EntryStack> getInput(MachineRecipeDisplay<R> recipeDisplay, int index) {
|
||||||
|
List<List<EntryStack>> inputs = recipeDisplay.getInputEntries();
|
||||||
|
return inputs.size() > index ? inputs.get(index) : Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EntryStack> getOutput(MachineRecipeDisplay<R> recipeDisplay, int index) {
|
||||||
|
List<EntryStack> outputs = recipeDisplay.getOutputEntries();
|
||||||
|
return outputs.size() > index ? Collections.singletonList(outputs.get(index)) : Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package techreborn.compat.rei.machine;
|
||||||
|
|
||||||
|
import me.shedaniel.math.Point;
|
||||||
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import techreborn.compat.rei.MachineRecipeDisplay;
|
||||||
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AssemblingMachineCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
|
||||||
|
public AssemblingMachineCategory(RebornRecipeType<R> rebornRecipeType) {
|
||||||
|
super(rebornRecipeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
|
||||||
|
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 9, bounds.y + 35 - 19)).entries(getInput(recipeDisplay, 0)).markInput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 9, bounds.y + 55 - 19)).entries(getInput(recipeDisplay, 1)).markInput());
|
||||||
|
widgets.add(Widgets.createResultSlotBackground(new Point(bounds.x + 101 - 9, bounds.y + 45 - 19)));
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 - 9, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 0)).disableBackground().markOutput());
|
||||||
|
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 9, bounds.y + 48 - 19, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
|
||||||
|
|
||||||
|
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
|
||||||
|
.shadow(false)
|
||||||
|
.rightAligned()
|
||||||
|
.color(0xFF404040, 0xFFBBBBBB)
|
||||||
|
);
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package techreborn.compat.rei.machine;
|
||||||
|
|
||||||
|
import me.shedaniel.math.Point;
|
||||||
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import techreborn.compat.rei.MachineRecipeDisplay;
|
||||||
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BlastFurnaceCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
|
||||||
|
public BlastFurnaceCategory(RebornRecipeType<R> rebornRecipeType) {
|
||||||
|
super(rebornRecipeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
|
||||||
|
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 17, bounds.y + 35 - 19)).entries(getInput(recipeDisplay, 0)).markInput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 17, bounds.y + 55 - 19)).entries(getInput(recipeDisplay, 1)).markInput());
|
||||||
|
widgets.add(Widgets.createSlotBase(new Rectangle(bounds.x + 101 - 17 - 5, bounds.y + 45 - 19 - 5, 46, 26)));
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 - 17, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 0)).disableBackground().markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 + 20 - 17, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 1)).disableBackground().markOutput());
|
||||||
|
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 17, bounds.y + 48 - 19, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
|
||||||
|
|
||||||
|
Text neededHeat = new LiteralText(String.valueOf(recipeDisplay.getHeat())).append(" ").append(new TranslatableText("techreborn.jei.recipe.heat"));
|
||||||
|
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 5), neededHeat)
|
||||||
|
.shadow(false)
|
||||||
|
.rightAligned()
|
||||||
|
.color(0xFF404040, 0xFFBBBBBB)
|
||||||
|
);
|
||||||
|
|
||||||
|
widgets.add(Widgets.createLabel(new Point(bounds.x + 24, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
|
||||||
|
.shadow(false)
|
||||||
|
.leftAligned()
|
||||||
|
.color(0xFF404040, 0xFFBBBBBB)
|
||||||
|
);
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package techreborn.compat.rei.machine;
|
||||||
|
|
||||||
|
import me.shedaniel.math.Point;
|
||||||
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import techreborn.compat.rei.MachineRecipeDisplay;
|
||||||
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DistillationTowerCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
|
||||||
|
public DistillationTowerCategory(RebornRecipeType<R> rebornRecipeType) {
|
||||||
|
super(rebornRecipeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
|
||||||
|
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 23, bounds.y + 35 - 19)).entries(getInput(recipeDisplay, 0)).markInput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 23, bounds.y + 55 - 19)).entries(getInput(recipeDisplay, 1)).markInput());
|
||||||
|
widgets.add(Widgets.createSlotBase(new Rectangle(bounds.x + 101 - 23 - 5, bounds.y + 45 - 19 - 5, 66, 26)));
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 - 23, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 0)).disableBackground().markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 + 20 - 23, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 1)).disableBackground().markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 + 40 - 23, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 2)).disableBackground().markOutput());
|
||||||
|
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 23, bounds.y + 48 - 19, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
|
||||||
|
|
||||||
|
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
|
||||||
|
.shadow(false)
|
||||||
|
.rightAligned()
|
||||||
|
.color(0xFF404040, 0xFFBBBBBB)
|
||||||
|
);
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package techreborn.compat.rei.machine;
|
||||||
|
|
||||||
|
import me.shedaniel.math.Point;
|
||||||
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import techreborn.compat.rei.MachineRecipeDisplay;
|
||||||
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ElectrolyzerCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
|
||||||
|
public ElectrolyzerCategory(RebornRecipeType<R> rebornRecipeType) {
|
||||||
|
super(rebornRecipeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
|
||||||
|
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 20, bounds.y + 41)).entries(getInput(recipeDisplay, 0)).markInput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55, bounds.y + 41)).entries(getInput(recipeDisplay, 1)).markInput());
|
||||||
|
widgets.add(Widgets.createSlotBase(new Rectangle(bounds.x + 55 + 17 - 9 - 20 - 5, bounds.y + 36 - 22 - 5, 86, 26)));
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 17 - 9 - 20, bounds.y + 36 - 22)).entries(getOutput(recipeDisplay, 0)).disableBackground().markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 17 - 9, bounds.y + 36 - 22)).entries(getOutput(recipeDisplay, 1)).disableBackground().markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 17 - 9 + 20, bounds.y + 36 - 22)).entries(getOutput(recipeDisplay, 2)).disableBackground().markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 17 - 9 + 40, bounds.y + 36 - 22)).entries(getOutput(recipeDisplay, 3)).disableBackground().markOutput());
|
||||||
|
widgets.add(ReiPlugin.createProgressBar(bounds.x + 55 + 21, bounds.y + 36 + 4, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.UP));
|
||||||
|
|
||||||
|
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 17, bounds.getMaxY() - 13), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
|
||||||
|
.shadow(false)
|
||||||
|
.rightAligned()
|
||||||
|
.color(0xFF404040, 0xFFBBBBBB)
|
||||||
|
);
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDisplayHeight() {
|
||||||
|
return 66;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package techreborn.compat.rei.machine;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import me.shedaniel.math.Point;
|
||||||
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.ClientHelper;
|
||||||
|
import me.shedaniel.rei.api.widgets.Tooltip;
|
||||||
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import techreborn.compat.rei.MachineRecipeDisplay;
|
||||||
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GrinderCategory<R extends RebornRecipe> extends AbstractMachineCategory<R> {
|
||||||
|
public GrinderCategory(RebornRecipeType<R> rebornRecipeType) {
|
||||||
|
super(rebornRecipeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
|
||||||
|
List<Widget> widgets = Lists.newArrayList();
|
||||||
|
widgets.add(Widgets.createRecipeBase(bounds));
|
||||||
|
widgets.add(ReiPlugin.createEnergyDisplay(new Rectangle(bounds.x + 8, bounds.y + 18, 14, 50), recipeDisplay.getEnergy(), ReiPlugin.EntryAnimation.downwards(5000), point -> {
|
||||||
|
List<Text> list = Lists.newArrayList();
|
||||||
|
list.add(Text.method_30163("Energy"));
|
||||||
|
list.add(new TranslatableText("techreborn.jei.recipe.running.cost", "E", recipeDisplay.getEnergy()).formatted(Formatting.GRAY));
|
||||||
|
list.add(Text.method_30163(""));
|
||||||
|
list.add(ClientHelper.getInstance().getFormattedModFromIdentifier(new Identifier("techreborn", "")));
|
||||||
|
return Tooltip.create(point, list);
|
||||||
|
}));
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55, bounds.y + 36)).entries(getInput(recipeDisplay, 0)).markInput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 36 - 9 - 18)).entries(getOutput(recipeDisplay, 0)).markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 36 - 9)).entries(getOutput(recipeDisplay, 1)).markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 36 - 9 + 18)).entries(getOutput(recipeDisplay, 2)).markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 36 - 9 + 36)).entries(getOutput(recipeDisplay, 3)).markOutput());
|
||||||
|
widgets.add(ReiPlugin.createProgressBar(bounds.x + 55 + 21, bounds.y + 36 + 4, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
|
||||||
|
widgets.add(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 55 - 26, bounds.y + 18, 16, 50), getInput(recipeDisplay, 1).get(0), ReiPlugin.EntryAnimation.downwards(5000)));
|
||||||
|
|
||||||
|
widgets.add(Widgets.createLabel(new Point(bounds.x + 51, bounds.y + 15), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
|
||||||
|
.shadow(false)
|
||||||
|
.leftAligned()
|
||||||
|
.color(0xFF404040, 0xFFBBBBBB)
|
||||||
|
);
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDisplayHeight() {
|
||||||
|
return 88;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package techreborn.compat.rei.machine;
|
||||||
|
|
||||||
|
import me.shedaniel.math.Point;
|
||||||
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import techreborn.compat.rei.MachineRecipeDisplay;
|
||||||
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ImplosionCompressorCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
|
||||||
|
public ImplosionCompressorCategory(RebornRecipeType<R> rebornRecipeType) {
|
||||||
|
super(rebornRecipeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
|
||||||
|
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 15, bounds.y + 35 - 19)).entries(getInput(recipeDisplay, 0)).markInput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 15, bounds.y + 55 - 19)).entries(getInput(recipeDisplay, 1)).markInput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 97 - 15, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 0)).markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 97 + 18 - 15, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 1)).markOutput());
|
||||||
|
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 15, bounds.y + 48 - 19, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
|
||||||
|
|
||||||
|
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
|
||||||
|
.shadow(false)
|
||||||
|
.rightAligned()
|
||||||
|
.color(0xFF404040, 0xFFBBBBBB)
|
||||||
|
);
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package techreborn.compat.rei.machine;
|
||||||
|
|
||||||
|
import me.shedaniel.math.Point;
|
||||||
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.widgets.Widgets;
|
||||||
|
import me.shedaniel.rei.gui.widget.Widget;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import techreborn.compat.rei.MachineRecipeDisplay;
|
||||||
|
import techreborn.compat.rei.ReiPlugin;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class IndustrialCentrifugeCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
|
||||||
|
public IndustrialCentrifugeCategory(RebornRecipeType<R> rebornRecipeType) {
|
||||||
|
super(rebornRecipeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
|
||||||
|
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 17, bounds.y + 35 - 19)).entries(getInput(recipeDisplay, 0)).markInput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 17, bounds.y + 55 - 19)).entries(getInput(recipeDisplay, 1)).markInput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 97 - 17, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 0)).markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 116 - 17, bounds.y + 26 - 19)).entries(getOutput(recipeDisplay, 1)).markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 135 - 17, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 2)).markOutput());
|
||||||
|
widgets.add(Widgets.createSlot(new Point(bounds.x + 116 - 17, bounds.y + 64 - 19)).entries(getOutput(recipeDisplay, 3)).markOutput());
|
||||||
|
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 17, bounds.y + 48 - 19, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
|
||||||
|
|
||||||
|
widgets.add(Widgets.createLabel(new Point(bounds.x + 24, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
|
||||||
|
.shadow(false)
|
||||||
|
.leftAligned()
|
||||||
|
.color(0xFF404040, 0xFFBBBBBB)
|
||||||
|
);
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue