Refactor and import cleanup (Excluding network PR changed files)
This commit is contained in:
parent
a36a0e6f4a
commit
c4ef977f16
165 changed files with 1572 additions and 1625 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class FluidGeneratorRecipe {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FluidGeneratorRecipe [generatorType=" + generatorType + ", fluid=" + fluid + ", energyPerMb="
|
return "FluidGeneratorRecipe [generatorType=" + generatorType + ", fluid=" + fluid + ", energyPerMb="
|
||||||
+ energyPerMb + "]";
|
+ energyPerMb + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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;
|
||||||
|
@ -39,17 +38,17 @@ public class GeneratorRecipeHelper {
|
||||||
* FluidGeneratorRecipe.
|
* FluidGeneratorRecipe.
|
||||||
*/
|
*/
|
||||||
public static EnumMap<EFluidGenerator, FluidGeneratorRecipeList> fluidRecipes = new EnumMap<>(
|
public static EnumMap<EFluidGenerator, FluidGeneratorRecipeList> fluidRecipes = new EnumMap<>(
|
||||||
EFluidGenerator.class);
|
EFluidGenerator.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a Fluid energy recipe.
|
* Register a Fluid energy recipe.
|
||||||
*
|
*
|
||||||
* @param generatorType A value of the EFluidGenerator type in which the fluid is
|
* @param generatorType A value of the EFluidGenerator type in which the fluid is
|
||||||
* allowed to be consumed.
|
* allowed to be consumed.
|
||||||
* @param fluidType
|
* @param fluidType
|
||||||
* @param energyPerMb Represent the energy / MILLI_BUCKET the fluid will produce.
|
* @param energyPerMb Represent the energy / MILLI_BUCKET the fluid will produce.
|
||||||
* Some generators use this value to alter their fluid decay
|
* Some generators use this value to alter their fluid decay
|
||||||
* speed to match their maximum energy output.
|
* speed to match their maximum energy output.
|
||||||
*/
|
*/
|
||||||
public static void registerFluidRecipe(EFluidGenerator generatorType, Fluid fluidType, int energyPerMb) {
|
public static void registerFluidRecipe(EFluidGenerator generatorType, Fluid fluidType, int energyPerMb) {
|
||||||
fluidRecipes.putIfAbsent(generatorType, new FluidGeneratorRecipeList());
|
fluidRecipes.putIfAbsent(generatorType, new FluidGeneratorRecipeList());
|
||||||
|
@ -58,7 +57,7 @@ public class GeneratorRecipeHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param generatorType A value of the EFluidGenerator type in which the fluid is
|
* @param generatorType A value of the EFluidGenerator type in which the fluid is
|
||||||
* allowed to be consumed.
|
* allowed to be consumed.
|
||||||
* @return An object holding a set of availables recipes for this type of
|
* @return An object holding a set of availables recipes for this type of
|
||||||
* FluidGenerator.
|
* FluidGenerator.
|
||||||
*/
|
*/
|
||||||
|
@ -67,10 +66,10 @@ public class GeneratorRecipeHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes recipe
|
* Removes recipe
|
||||||
*
|
*
|
||||||
* @param generatorType A value of the EFluidGenerator type for which we should remove recipe
|
* @param generatorType A value of the EFluidGenerator type for which we should remove recipe
|
||||||
* @param fluidType Fluid to remove from generator recipes
|
* @param fluidType Fluid to remove from generator recipes
|
||||||
*/
|
*/
|
||||||
public static void removeFluidRecipe(EFluidGenerator generatorType, Fluid fluidType) {
|
public static void removeFluidRecipe(EFluidGenerator generatorType, Fluid fluidType) {
|
||||||
FluidGeneratorRecipeList recipeList = getFluidRecipesForGenerator(generatorType);
|
FluidGeneratorRecipeList recipeList = getFluidRecipesForGenerator(generatorType);
|
||||||
|
|
|
@ -34,14 +34,13 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ScrapboxRecipeCrafter extends RecipeCrafter {
|
public class ScrapboxRecipeCrafter extends RecipeCrafter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent Tile having this crafter
|
* @param parent Tile having this crafter
|
||||||
* @param inventory Inventory from parent blockEntity
|
* @param inventory Inventory from parent blockEntity
|
||||||
* @param inputSlots Slot IDs for input
|
* @param inputSlots Slot IDs for input
|
||||||
* @param outputSlots Slot IDs for output
|
* @param outputSlots Slot IDs for output
|
||||||
*/
|
*/
|
||||||
public ScrapboxRecipeCrafter(BlockEntity parent, RebornInventory<?> inventory, int[] inputSlots, int[] outputSlots) {
|
public ScrapboxRecipeCrafter(BlockEntity parent, RebornInventory<?> inventory, int[] inputSlots, int[] outputSlots) {
|
||||||
|
@ -49,9 +48,9 @@ public class ScrapboxRecipeCrafter extends RecipeCrafter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCurrentRecipe(){
|
public void updateCurrentRecipe() {
|
||||||
List<RebornRecipe> scrapboxRecipeList = ModRecipes.SCRAPBOX.getRecipes(blockEntity.getWorld());
|
List<RebornRecipe> scrapboxRecipeList = ModRecipes.SCRAPBOX.getRecipes(blockEntity.getWorld());
|
||||||
if(scrapboxRecipeList.isEmpty()){
|
if (scrapboxRecipeList.isEmpty()) {
|
||||||
setCurrentRecipe(null);
|
setCurrentRecipe(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -62,4 +61,4 @@ public class ScrapboxRecipeCrafter extends RecipeCrafter {
|
||||||
this.currentTickTime = 0;
|
this.currentTickTime = 0;
|
||||||
setIsActive();
|
setIsActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class FusionReactorRecipe extends RebornRecipe {
|
public class FusionReactorRecipe extends RebornRecipe {
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ public class FusionReactorRecipe extends RebornRecipe {
|
||||||
this.minSize = minSize;
|
this.minSize = minSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStartEnergy () {
|
public int getStartEnergy() {
|
||||||
return startE;
|
return startE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class RollingMachineRecipe extends RebornRecipe {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserialize(JsonObject jsonObject) {
|
public void deserialize(JsonObject jsonObject) {
|
||||||
if(jsonObject.has("shaped")) {
|
if (jsonObject.has("shaped")) {
|
||||||
JsonObject json = JsonHelper.getObject(jsonObject, "shaped");
|
JsonObject json = JsonHelper.getObject(jsonObject, "shaped");
|
||||||
shapedRecipe = RecipeSerializer.SHAPED.read(getId(), json);
|
shapedRecipe = RecipeSerializer.SHAPED.read(getId(), json);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -63,13 +63,13 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
|
||||||
|
|
||||||
private final List<DataDrivenSlot> slots;
|
private final List<DataDrivenSlot> slots;
|
||||||
|
|
||||||
public static DataDrivenBEProvider create(Block block, Identifier identifier){
|
public static DataDrivenBEProvider create(Block block, Identifier identifier) {
|
||||||
String location = String.format("%s/machines/%s.json", identifier.getNamespace(), identifier.getPath());
|
String location = String.format("%s/machines/%s.json", identifier.getNamespace(), identifier.getPath());
|
||||||
JsonObject jsonObject;
|
JsonObject jsonObject;
|
||||||
try {
|
try {
|
||||||
jsonObject = SerializationUtil.GSON.fromJson(IOUtils.toString(FabricLauncherBase.getLauncher().getResourceAsStream(location), StandardCharsets.UTF_8), JsonObject.class);
|
jsonObject = SerializationUtil.GSON.fromJson(IOUtils.toString(FabricLauncherBase.getLauncher().getResourceAsStream(location), StandardCharsets.UTF_8), JsonObject.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("failed to read json: " + location, e);
|
throw new RuntimeException("failed to read json: " + location, e);
|
||||||
}
|
}
|
||||||
Identifier id = new Identifier(JsonHelper.getString(jsonObject, "name"));
|
Identifier id = new Identifier(JsonHelper.getString(jsonObject, "name"));
|
||||||
DataDrivenBEProvider provider = new DataDrivenBEProvider(block, jsonObject);
|
DataDrivenBEProvider provider = new DataDrivenBEProvider(block, jsonObject);
|
||||||
|
@ -95,7 +95,7 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
|
||||||
|
|
||||||
public BuiltScreenHandler createScreenHandler(DataDrivenBlockEntity blockEntity, int syncID, PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(DataDrivenBlockEntity blockEntity, int syncID, PlayerEntity player) {
|
||||||
BlockEntityScreenHandlerBuilder builder = new ScreenHandlerBuilder(identifier.getPath()).player(player.inventory)
|
BlockEntityScreenHandlerBuilder builder = new ScreenHandlerBuilder(identifier.getPath()).player(player.inventory)
|
||||||
.inventory().hotbar().addInventory().blockEntity(blockEntity);
|
.inventory().hotbar().addInventory().blockEntity(blockEntity);
|
||||||
|
|
||||||
slots.forEach(dataDrivenSlot -> dataDrivenSlot.add(builder));
|
slots.forEach(dataDrivenSlot -> dataDrivenSlot.add(builder));
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
|
||||||
return provider.createScreenHandler(this,syncID, player);
|
return provider.createScreenHandler(this, syncID, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataDrivenBEProvider getProvider() {
|
public DataDrivenBEProvider getProvider() {
|
||||||
|
@ -139,24 +139,24 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
|
||||||
return slots.stream().filter(slot -> slot.getType() == SlotType.ENERGY).findFirst().orElse(null).getId();
|
return slots.stream().filter(slot -> slot.getType() == SlotType.ENERGY).findFirst().orElse(null).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int countOfSlotType(SlotType type){
|
private int countOfSlotType(SlotType type) {
|
||||||
return (int) slots.stream()
|
return (int) slots.stream()
|
||||||
.filter(slot -> slot.getType() == type)
|
.filter(slot -> slot.getType() == type)
|
||||||
.count();
|
.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] slotIds(SlotType type){
|
private int[] slotIds(SlotType type) {
|
||||||
return slots.stream()
|
return slots.stream()
|
||||||
.filter(slot -> slot.getType() == type)
|
.filter(slot -> slot.getType() == type)
|
||||||
.mapToInt(DataDrivenSlot::getId)
|
.mapToInt(DataDrivenSlot::getId)
|
||||||
.toArray();
|
.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DataDrivenSlot> getSlots() {
|
public List<DataDrivenSlot> getSlots() {
|
||||||
return Collections.unmodifiableList(slots);
|
return Collections.unmodifiableList(slots);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSimpleName(){
|
private String getSimpleName() {
|
||||||
return WordUtils.capitalize(identifier.getPath());
|
return WordUtils.capitalize(identifier.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,12 +41,12 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DataDrivenSlot {
|
public class DataDrivenSlot {
|
||||||
|
|
||||||
public static List<DataDrivenSlot> read(JsonArray jsonArray){
|
public static List<DataDrivenSlot> read(JsonArray jsonArray) {
|
||||||
AtomicInteger idCount = new AtomicInteger();
|
AtomicInteger idCount = new AtomicInteger();
|
||||||
return SerializationUtil.stream(jsonArray)
|
return SerializationUtil.stream(jsonArray)
|
||||||
.map(JsonElement::getAsJsonObject)
|
.map(JsonElement::getAsJsonObject)
|
||||||
.map(json -> new DataDrivenSlot(idCount.getAndIncrement(), JsonHelper.getInt(json, "x"), JsonHelper.getInt(json, "y"), SlotType.fromString(JsonHelper.getString(json, "type"))))
|
.map(json -> new DataDrivenSlot(idCount.getAndIncrement(), JsonHelper.getInt(json, "x"), JsonHelper.getInt(json, "y"), SlotType.fromString(JsonHelper.getString(json, "type"))))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
|
@ -78,14 +78,14 @@ public class DataDrivenSlot {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(BlockEntityScreenHandlerBuilder inventoryBuilder){
|
public void add(BlockEntityScreenHandlerBuilder inventoryBuilder) {
|
||||||
type.getSlotBiConsumer().accept(inventoryBuilder, this);
|
type.getSlotBiConsumer().accept(inventoryBuilder, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void draw(MatrixStack matrixStack, GuiBase<?> guiBase, GuiBase.Layer layer){
|
public void draw(MatrixStack matrixStack, GuiBase<?> guiBase, GuiBase.Layer layer) {
|
||||||
//TODO find a better way to do this
|
//TODO find a better way to do this
|
||||||
if(getType() == SlotType.OUTPUT){
|
if (getType() == SlotType.OUTPUT) {
|
||||||
guiBase.drawOutputSlot(matrixStack, getX(), getY(), layer);
|
guiBase.drawOutputSlot(matrixStack, getX(), getY(), layer);
|
||||||
} else {
|
} else {
|
||||||
guiBase.drawSlot(matrixStack, getX(), getY(), layer);
|
guiBase.drawSlot(matrixStack, getX(), getY(), layer);
|
||||||
|
|
|
@ -41,14 +41,14 @@ public enum SlotType {
|
||||||
builder.energySlot(slot.getId(), slot.getX(), slot.getY());
|
builder.energySlot(slot.getId(), slot.getX(), slot.getY());
|
||||||
});
|
});
|
||||||
|
|
||||||
public static SlotType fromString(String string){
|
public static SlotType fromString(String string) {
|
||||||
return Arrays.stream(values())
|
return Arrays.stream(values())
|
||||||
.filter(slotType -> slotType.name().equalsIgnoreCase(string))
|
.filter(slotType -> slotType.name().equalsIgnoreCase(string))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.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;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
||||||
super.tick();
|
super.tick();
|
||||||
ticksSinceLastChange++;
|
ticksSinceLastChange++;
|
||||||
|
|
||||||
if(world.isClient){
|
if (world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,14 +117,13 @@ 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgressScaled(int scale) {
|
public int getProgressScaled(int scale) {
|
||||||
if (isActive()){
|
if (isActive()) {
|
||||||
return ticksSinceLastChange * scale;
|
return ticksSinceLastChange * scale;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -207,11 +205,11 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
||||||
this.ticksSinceLastChange = ticksSinceLastChange;
|
this.ticksSinceLastChange = ticksSinceLastChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FluidValue getTankAmount(){
|
public FluidValue getTankAmount() {
|
||||||
return tank.getFluidAmount();
|
return tank.getFluidAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTankAmount(FluidValue amount){
|
public void setTankAmount(FluidValue amount) {
|
||||||
tank.setFluidAmount(amount);
|
tank.setFluidAmount(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,10 +54,12 @@ 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)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
|
@ -60,10 +60,10 @@ public class PlasmaGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity im
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("plasmagenerator").player(player.inventory).inventory().hotbar().addInventory()
|
return new ScreenHandlerBuilder("plasmagenerator").player(player.inventory).inventory().hotbar().addInventory()
|
||||||
.blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
.blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
||||||
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
||||||
.sync(this::getTankAmount, this::setTankAmount)
|
.sync(this::getTankAmount, this::setTankAmount)
|
||||||
.sync(tank)
|
.sync(tank)
|
||||||
.addInventory().create(this, syncID);
|
.addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -151,7 +150,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
if (world == null){
|
if (world == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +190,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
if (getPanel() == TRContent.SolarPanels.CREATIVE){
|
if (getPanel() == TRContent.SolarPanels.CREATIVE) {
|
||||||
return EnergyTier.INSANE.getMaxOutput();
|
return EnergyTier.INSANE.getMaxOutput();
|
||||||
}
|
}
|
||||||
// Solar panel output will only be limited by the cables the users use
|
// Solar panel output will only be limited by the cables the users use
|
||||||
|
@ -231,22 +230,22 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
||||||
|
|
||||||
info.add(
|
info.add(
|
||||||
new TranslatableText("reborncore.tooltip.energy.maxEnergy")
|
new TranslatableText("reborncore.tooltip.energy.maxEnergy")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(": ")
|
.append(": ")
|
||||||
.append(
|
.append(
|
||||||
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(getMaxPower()))
|
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(getMaxPower()))
|
||||||
.formatted(Formatting.GOLD)
|
.formatted(Formatting.GOLD)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
info.add(
|
info.add(
|
||||||
new TranslatableText("techreborn.tooltip.generationRate.day")
|
new TranslatableText("techreborn.tooltip.generationRate.day")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(": ")
|
.append(": ")
|
||||||
.append(
|
.append(
|
||||||
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD))
|
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD))
|
||||||
.formatted(Formatting.GOLD)
|
.formatted(Formatting.GOLD)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
info.add(
|
info.add(
|
||||||
|
|
|
@ -60,10 +60,10 @@ public class DieselGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity im
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("dieselgenerator").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("dieselgenerator").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
||||||
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
||||||
.sync(this::getTankAmount, this::setTankAmount)
|
.sync(this::getTankAmount, this::setTankAmount)
|
||||||
.sync(tank)
|
.sync(tank)
|
||||||
.addInventory().create(this, syncID);
|
.addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
|
public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
|
||||||
implements IToolDrop, InventoryProvider {
|
implements IToolDrop, InventoryProvider {
|
||||||
|
|
||||||
public RebornInventory<DragonEggSyphonBlockEntity> inventory = new RebornInventory<>(3, "DragonEggSyphonBlockEntity", 64, this);
|
public RebornInventory<DragonEggSyphonBlockEntity> inventory = new RebornInventory<>(3, "DragonEggSyphonBlockEntity", 64, this);
|
||||||
private long lastOutput = 0;
|
private long lastOutput = 0;
|
||||||
|
|
|
@ -60,10 +60,10 @@ public class GasTurbineBlockEntity extends BaseFluidGeneratorBlockEntity impleme
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("gasturbine").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("gasturbine").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
||||||
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
||||||
.sync(this::getTankAmount, this::setTankAmount)
|
.sync(this::getTankAmount, this::setTankAmount)
|
||||||
.sync(tank)
|
.sync(tank)
|
||||||
.addInventory().create(this, syncID);
|
.addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,10 +60,10 @@ public class SemiFluidGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("semifluidgenerator").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("semifluidgenerator").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
||||||
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
||||||
.sync(this::getTankAmount, this::setTankAmount)
|
.sync(this::getTankAmount, this::setTankAmount)
|
||||||
.sync(tank)
|
.sync(tank)
|
||||||
.addInventory().create(this, syncID);
|
.addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,10 +60,10 @@ public class ThermalGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity i
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("thermalgenerator").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("thermalgenerator").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
||||||
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
||||||
.sync(this::getTankAmount, this::setTankAmount)
|
.sync(this::getTankAmount, this::setTankAmount)
|
||||||
.sync(tank)
|
.sync(tank)
|
||||||
.addInventory().create(this, syncID);
|
.addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,11 +64,11 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getItemBurnTime(@Nonnull ItemStack stack) {
|
public static int getItemBurnTime(@Nonnull ItemStack stack) {
|
||||||
if (stack.isEmpty()){
|
if (stack.isEmpty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Map<Item, Integer> burnMap = AbstractFurnaceBlockEntity.createFuelTimeMap();
|
Map<Item, Integer> burnMap = AbstractFurnaceBlockEntity.createFuelTimeMap();
|
||||||
if(burnMap.containsKey(stack.getItem())){
|
if (burnMap.containsKey(stack.getItem())) {
|
||||||
return burnMap.get(stack.getItem()) / 4;
|
return burnMap.get(stack.getItem()) / 4;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -183,9 +183,9 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("generator").player(player.inventory).inventory().hotbar().addInventory()
|
return new ScreenHandlerBuilder("generator").player(player.inventory).inventory().hotbar().addInventory()
|
||||||
.blockEntity(this).fuelSlot(0, 80, 54).energySlot(1, 8, 72).syncEnergyValue()
|
.blockEntity(this).fuelSlot(0, 80, 54).energySlot(1, 8, 72).syncEnergyValue()
|
||||||
.sync(this::getBurnTime, this::setBurnTime)
|
.sync(this::getBurnTime, this::setBurnTime)
|
||||||
.sync(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(this, syncID);
|
.sync(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class WindMillBlockEntity extends PowerAcceptorBlockEntity implements ITo
|
||||||
|
|
||||||
boolean generating = pos.getY() > 64;
|
boolean generating = pos.getY() > 64;
|
||||||
|
|
||||||
if(world.isClient) {
|
if (world.isClient) {
|
||||||
bladeAngle += spinSpeed;
|
bladeAngle += spinSpeed;
|
||||||
|
|
||||||
if (generating) {
|
if (generating) {
|
||||||
|
|
|
@ -35,9 +35,9 @@ import techreborn.blocks.lighting.BlockLamp;
|
||||||
import techreborn.init.TRBlockEntities;
|
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,10 +38,9 @@ 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 {
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public int maxInput;
|
public int maxInput;
|
||||||
|
@ -52,10 +51,10 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
public RecipeCrafter crafter;
|
public RecipeCrafter crafter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name String Name for a blockEntity. Do we need it at all?
|
* @param name String Name for a blockEntity. Do we need it at all?
|
||||||
* @param maxInput int Maximum energy input, value in EU
|
* @param maxInput int Maximum energy input, value in EU
|
||||||
* @param maxEnergy int Maximum energy buffer, value in EU
|
* @param maxEnergy int Maximum energy buffer, value in EU
|
||||||
* @param toolDrop Block Block to drop with wrench
|
* @param toolDrop Block Block to drop with wrench
|
||||||
* @param energySlot int Energy slot to use to charge machine from battery
|
* @param energySlot int Energy slot to use to charge machine from battery
|
||||||
*/
|
*/
|
||||||
public GenericMachineBlockEntity(BlockEntityType<?> blockEntityType, String name, int maxInput, int maxEnergy, Block toolDrop, int energySlot) {
|
public GenericMachineBlockEntity(BlockEntityType<?> blockEntityType, String name, int maxInput, int maxEnergy, Block toolDrop, int 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() {
|
||||||
|
@ -136,17 +141,17 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag toTag(CompoundTag compoundTag) {
|
public CompoundTag toTag(CompoundTag compoundTag) {
|
||||||
super.toTag(compoundTag);
|
super.toTag(compoundTag);
|
||||||
compoundTag.putInt("BurnTime", burnTime);
|
compoundTag.putInt("BurnTime", burnTime);
|
||||||
compoundTag.putInt("TotalBurnTime", totalBurnTime);
|
compoundTag.putInt("TotalBurnTime", totalBurnTime);
|
||||||
compoundTag.putInt("Progress", progress);
|
compoundTag.putInt("Progress", progress);
|
||||||
return compoundTag;
|
return compoundTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if(world.isClient){
|
if (world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean isBurning = isBurning();
|
boolean isBurning = isBurning();
|
||||||
|
@ -175,7 +180,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
||||||
progress = 0;
|
progress = 0;
|
||||||
smelt();
|
smelt();
|
||||||
}
|
}
|
||||||
} else if(!canSmelt()) {
|
} else if (!canSmelt()) {
|
||||||
progress = 0;
|
progress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import techreborn.init.ModRecipes;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity implements BuiltScreenHandlerProvider {
|
public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
int input1 = 0;
|
int input1 = 0;
|
||||||
int input2 = 1;
|
int input2 = 1;
|
||||||
|
@ -127,22 +127,22 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("alloyfurnace").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("alloyfurnace").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this)
|
.addInventory().blockEntity(this)
|
||||||
.slot(0, 47, 17)
|
.slot(0, 47, 17)
|
||||||
.slot(1, 65, 17)
|
.slot(1, 65, 17)
|
||||||
.outputSlot(2, 116, 35).fuelSlot(3, 56, 53)
|
.outputSlot(2, 116, 35).fuelSlot(3, 56, 53)
|
||||||
.sync(this::getBurnTime, this::setBurnTime)
|
.sync(this::getBurnTime, this::setBurnTime)
|
||||||
.sync(this::getProgress, this::setProgress)
|
.sync(this::getProgress, this::setProgress)
|
||||||
.sync(this::getTotalBurnTime, this::setTotalBurnTime)
|
.sync(this::getTotalBurnTime, this::setTotalBurnTime)
|
||||||
.addInventory().create(this, syncID);
|
.addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStackValid(int slotID, ItemStack stack) {
|
public boolean isStackValid(int slotID, ItemStack stack) {
|
||||||
return ModRecipes.ALLOY_SMELTER.getRecipes(world).stream()
|
return ModRecipes.ALLOY_SMELTER.getRecipes(world).stream()
|
||||||
.anyMatch(rebornRecipe -> rebornRecipe.getRebornIngredients().stream()
|
.anyMatch(rebornRecipe -> rebornRecipe.getRebornIngredients().stream()
|
||||||
.anyMatch(rebornIngredient -> rebornIngredient.test(stack))
|
.anyMatch(rebornIngredient -> rebornIngredient.test(stack))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -133,9 +133,9 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag toTag(CompoundTag compoundTag) {
|
public CompoundTag toTag(CompoundTag compoundTag) {
|
||||||
super.toTag(compoundTag);
|
super.toTag(compoundTag);
|
||||||
compoundTag.putFloat("Experience", experience);
|
compoundTag.putFloat("Experience", experience);
|
||||||
return compoundTag;
|
return compoundTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IContainerProvider
|
// IContainerProvider
|
||||||
|
|
|
@ -42,29 +42,29 @@ import techreborn.init.TRContent;
|
||||||
import techreborn.utils.MessageIDs;
|
import techreborn.utils.MessageIDs;
|
||||||
|
|
||||||
public class AlarmBlockEntity extends BlockEntity
|
public class AlarmBlockEntity extends BlockEntity
|
||||||
implements Tickable, IToolDrop {
|
implements Tickable, IToolDrop {
|
||||||
private int selectedSound = 1;
|
private int selectedSound = 1;
|
||||||
|
|
||||||
public AlarmBlockEntity() {
|
public AlarmBlockEntity() {
|
||||||
super(TRBlockEntities.ALARM);
|
super(TRBlockEntities.ALARM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rightClick() {
|
public void rightClick() {
|
||||||
if (world.isClient) {
|
if (world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedSound < 3) {
|
if (selectedSound < 3) {
|
||||||
selectedSound++;
|
selectedSound++;
|
||||||
} else {
|
} else {
|
||||||
selectedSound = 1;
|
selectedSound = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new TranslatableText("techreborn.message.alarm")
|
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new TranslatableText("techreborn.message.alarm")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(" Alarm ")
|
.append(" Alarm ")
|
||||||
.append(String.valueOf(selectedSound)));
|
.append(String.valueOf(selectedSound)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockEntity
|
// BlockEntity
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,12 +87,12 @@ public class AlarmBlockEntity extends BlockEntity
|
||||||
// ITickable
|
// ITickable
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (world.isClient()){
|
if (world.isClient()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (world.getTime() % 25 != 0) {
|
if (world.getTime() % 25 != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (world.isReceivingRedstonePower(getPos())) {
|
if (world.isReceivingRedstonePower(getPos())) {
|
||||||
BlockAlarm.setActive(true, world, pos);
|
BlockAlarm.setActive(true, world, pos);
|
||||||
switch (selectedSound) {
|
switch (selectedSound) {
|
||||||
|
@ -106,7 +106,7 @@ public class AlarmBlockEntity extends BlockEntity
|
||||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
|
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BlockAlarm.setActive(false, world, pos);
|
BlockAlarm.setActive(false, world, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
||||||
implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
|
implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
public RebornInventory<ChargeOMatBlockEntity> inventory = new RebornInventory<>(6, "ChargeOMatBlockEntity", 64, this);
|
public RebornInventory<ChargeOMatBlockEntity> inventory = new RebornInventory<>(6, "ChargeOMatBlockEntity", 64, this);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
if(world.isClient){
|
if (world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
|
@ -61,11 +61,11 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
||||||
|
|
||||||
if (Energy.valid(stack)) {
|
if (Energy.valid(stack)) {
|
||||||
Energy.of(this)
|
Energy.of(this)
|
||||||
.into(
|
.into(
|
||||||
Energy
|
Energy
|
||||||
.of(stack)
|
.of(stack)
|
||||||
)
|
)
|
||||||
.move();
|
.move();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("chargebench").player(player.inventory).inventory().hotbar().addInventory()
|
return new ScreenHandlerBuilder("chargebench").player(player.inventory).inventory().hotbar().addInventory()
|
||||||
.blockEntity(this).energySlot(0, 62, 25).energySlot(1, 98, 25).energySlot(2, 62, 45).energySlot(3, 98, 45)
|
.blockEntity(this).energySlot(0, 62, 25).energySlot(1, 98, 25).energySlot(2, 62, 45).energySlot(3, 98, 45)
|
||||||
.energySlot(4, 62, 65).energySlot(5, 98, 65).syncEnergyValue().addInventory().create(this, syncID);
|
.energySlot(4, 62, 65).energySlot(5, 98, 65).syncEnergyValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class DrainBlockEntity extends MachineBaseBlockEntity {
|
||||||
|
|
||||||
protected Tank internalTank = new Tank("tank", FluidValue.BUCKET, this);
|
protected Tank internalTank = new Tank("tank", FluidValue.BUCKET, this);
|
||||||
|
|
||||||
public DrainBlockEntity(){
|
public DrainBlockEntity() {
|
||||||
this(TRBlockEntities.DRAIN);
|
this(TRBlockEntities.DRAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,13 +54,13 @@ public class DrainBlockEntity extends MachineBaseBlockEntity {
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if(world.isClient){
|
if (world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.getTime() % 10 == 0) {
|
if (world.getTime() % 10 == 0) {
|
||||||
|
|
||||||
if(internalTank.isEmpty()) {
|
if (internalTank.isEmpty()) {
|
||||||
tryDrain();
|
tryDrain();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class DrainBlockEntity extends MachineBaseBlockEntity {
|
||||||
return internalTank;
|
return internalTank;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryDrain(){
|
private void tryDrain() {
|
||||||
// Position above drain
|
// Position above drain
|
||||||
BlockPos above = this.getPos().up();
|
BlockPos above = this.getPos().up();
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class DistillationTowerBlockEntity extends GenericMachineBlockEntity impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeMultiblock(MultiblockWriter writer) {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
writer .translate(1, 0, -1)
|
writer.translate(1, 0, -1)
|
||||||
.fill(0, 0, 0, 3, 1, 3, TRContent.MachineBlocks.BASIC.getCasing().getDefaultState())
|
.fill(0, 0, 0, 3, 1, 3, TRContent.MachineBlocks.BASIC.getCasing().getDefaultState())
|
||||||
.ringWithAir(Direction.Axis.Y, 3, 1, 3, TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState())
|
.ringWithAir(Direction.Axis.Y, 3, 1, 3, TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState())
|
||||||
.ringWithAir(Direction.Axis.Y, 3, 2, 3, TRContent.MachineBlocks.BASIC.getCasing().getDefaultState())
|
.ringWithAir(Direction.Axis.Y, 3, 2, 3, TRContent.MachineBlocks.BASIC.getCasing().getDefaultState())
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
|
||||||
@Override
|
@Override
|
||||||
public void writeMultiblock(MultiblockWriter writer) {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
BlockState state = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
BlockState state = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||||
writer .translate(1, 0, -1)
|
writer.translate(1, 0, -1)
|
||||||
.ring(Direction.Axis.Y, 3, 0, 3, (v, p) -> v.getBlockState(p) == state, state, null, null);
|
.ring(Direction.Axis.Y, 3, 0, 3, (v, p) -> v.getBlockState(p) == state, state, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecipeCrafter getRecipeCrafter() {
|
public RecipeCrafter getRecipeCrafter() {
|
||||||
return (RecipeCrafter) crafter;
|
return crafter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TilePowerAcceptor
|
// TilePowerAcceptor
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity im
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeMultiblock(MultiblockWriter writer) {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
writer .translate(-1, -3, -1)
|
writer.translate(-1, -3, -1)
|
||||||
.fill(0, 0, 0, 3, 1, 3, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState())
|
.fill(0, 0, 0, 3, 1, 3, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState())
|
||||||
.ringWithAir(Direction.Axis.Y, 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());
|
.fill(0, 2, 0, 3, 3, 3, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState());
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class IndustrialBlastFurnaceBlockEntity extends GenericMachineBlockEntity
|
||||||
return state == lava || state.getBlock() == Blocks.AIR;
|
return state == lava || state.getBlock() == Blocks.AIR;
|
||||||
};
|
};
|
||||||
|
|
||||||
writer .translate(1, 0, -1)
|
writer.translate(1, 0, -1)
|
||||||
.fill(0, 0, 0, 3, 1, 3, casing, basic)
|
.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, 1, 3, casing, basic, maybeLava, lava)
|
||||||
.ring(Direction.Axis.Y, 3, 2, 3, casing, basic, maybeLava, lava)
|
.ring(Direction.Axis.Y, 3, 2, 3, casing, basic, maybeLava, lava)
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
|
||||||
public void writeMultiblock(MultiblockWriter writer) {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
BlockState basic = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
BlockState basic = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||||
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||||
writer .translate(1, -1, -1)
|
writer.translate(1, -1, -1)
|
||||||
.fill(0, 0, 0, 3, 1, 3, basic)
|
.fill(0, 0, 0, 3, 1, 3, basic)
|
||||||
.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())
|
.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())
|
||||||
.fill(0, 2, 0, 3, 3, 3, basic);
|
.fill(0, 2, 0, 3, 3, 3, basic);
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
|
||||||
public void writeMultiblock(MultiblockWriter writer) {
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
BlockState basic = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
BlockState basic = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||||
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||||
writer .translate(1, -1, -1)
|
writer.translate(1, -1, -1)
|
||||||
.fill(0, 0, 0, 3, 1, 3, basic)
|
.fill(0, 0, 0, 3, 1, 3, basic)
|
||||||
.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())
|
.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())
|
||||||
.fill(0, 2, 0, 3, 3, 3, basic);
|
.fill(0, 2, 0, 3, 3, 3, basic);
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
package techreborn.blockentity.machine.multiblock;
|
package techreborn.blockentity.machine.multiblock;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -56,7 +55,7 @@ public class VacuumFreezerBlockEntity extends GenericMachineBlockEntity implemen
|
||||||
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||||
BlockState industrial = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState();
|
BlockState industrial = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState();
|
||||||
|
|
||||||
writer .translate(-1, -3, -1)
|
writer.translate(-1, -3, -1)
|
||||||
.fill(0, 0, 0, 3, 1, 3, advanced)
|
.fill(0, 0, 0, 3, 1, 3, advanced)
|
||||||
.ringWithAir(Direction.Axis.Y, 3, 1, 3, industrial)
|
.ringWithAir(Direction.Axis.Y, 3, 1, 3, industrial)
|
||||||
.fill(0, 2, 0, 3, 3, 3, advanced);
|
.fill(0, 2, 0, 3, 3, 3, advanced);
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class AlloySmelterBlockEntity extends GenericMachineBlockEntity implement
|
||||||
|
|
||||||
public AlloySmelterBlockEntity() {
|
public AlloySmelterBlockEntity() {
|
||||||
super(TRBlockEntities.ALLOY_SMELTER, "AlloySmelter", TechRebornConfig.alloySmelterMaxInput, TechRebornConfig.alloySmelterMaxEnergy, TRContent.Machine.ALLOY_SMELTER.block, 3);
|
super(TRBlockEntities.ALLOY_SMELTER, "AlloySmelter", TechRebornConfig.alloySmelterMaxInput, TechRebornConfig.alloySmelterMaxEnergy, TRContent.Machine.ALLOY_SMELTER.block, 3);
|
||||||
final int[] inputs = new int[] { 0, 1 };
|
final int[] inputs = new int[]{0, 1};
|
||||||
final int[] outputs = new int[] { 2 };
|
final int[] outputs = new int[]{2};
|
||||||
this.inventory = new RebornInventory<>(4, "AlloySmelterBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(4, "AlloySmelterBlockEntity", 64, this);
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.ALLOY_SMELTER, this, 2, 1, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.ALLOY_SMELTER, this, 2, 1, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ public class AlloySmelterBlockEntity extends GenericMachineBlockEntity implement
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("alloysmelter").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("alloysmelter").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this)
|
.addInventory().blockEntity(this)
|
||||||
.slot(0, 34, 47)
|
.slot(0, 34, 47)
|
||||||
.slot(1, 126, 47)
|
.slot(1, 126, 47)
|
||||||
.outputSlot(2, 80, 47).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory()
|
.outputSlot(2, 80, 47).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory()
|
||||||
.create(this, syncID);
|
.create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class AssemblingMachineBlockEntity extends GenericMachineBlockEntity impl
|
||||||
|
|
||||||
public AssemblingMachineBlockEntity() {
|
public AssemblingMachineBlockEntity() {
|
||||||
super(TRBlockEntities.ASSEMBLY_MACHINE, "AssemblingMachine", TechRebornConfig.assemblingMachineMaxInput, TechRebornConfig.assemblingMachineMaxEnergy, TRContent.Machine.ASSEMBLY_MACHINE.block, 3);
|
super(TRBlockEntities.ASSEMBLY_MACHINE, "AssemblingMachine", TechRebornConfig.assemblingMachineMaxInput, TechRebornConfig.assemblingMachineMaxEnergy, TRContent.Machine.ASSEMBLY_MACHINE.block, 3);
|
||||||
final int[] inputs = new int[] { 0, 1 };
|
final int[] inputs = new int[]{0, 1};
|
||||||
final int[] outputs = new int[] { 2 };
|
final int[] outputs = new int[]{2};
|
||||||
this.inventory = new RebornInventory<>(4, "AssemblingMachineBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(4, "AssemblingMachineBlockEntity", 64, this);
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.ASSEMBLING_MACHINE, this, 2, 2, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.ASSEMBLING_MACHINE, this, 2, 2, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class AssemblingMachineBlockEntity extends GenericMachineBlockEntity impl
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("assemblingmachine").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("assemblingmachine").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this).slot(0, 55, 35).slot(1, 55, 55).outputSlot(2, 101, 45).energySlot(3, 8, 72)
|
.addInventory().blockEntity(this).slot(0, 55, 35).slot(1, 55, 55).outputSlot(2, 101, 45).energySlot(3, 8, 72)
|
||||||
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
if (ingredient != Ingredient.EMPTY) {
|
if (ingredient != Ingredient.EMPTY) {
|
||||||
boolean foundIngredient = false;
|
boolean foundIngredient = false;
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
if(checkedSlots.contains(i)) {
|
if (checkedSlots.contains(i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ItemStack stack = inventory.getStack(i);
|
ItemStack stack = inventory.getStack(i);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +187,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
ItemStack bestSlot = inventory.getStack(i);
|
ItemStack bestSlot = inventory.getStack(i);
|
||||||
if (ingredient.test(bestSlot)) {
|
if (ingredient.test(bestSlot)) {
|
||||||
ItemStack remainderStack = getRemainderItem(bestSlot);
|
ItemStack remainderStack = getRemainderItem(bestSlot);
|
||||||
if(remainderStack.isEmpty()) {
|
if (remainderStack.isEmpty()) {
|
||||||
bestSlot.decrement(1);
|
bestSlot.decrement(1);
|
||||||
} else {
|
} else {
|
||||||
inventory.setStack(i, remainderStack);
|
inventory.setStack(i, remainderStack);
|
||||||
|
@ -202,7 +198,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
ItemStack stack = inventory.getStack(j);
|
ItemStack stack = inventory.getStack(j);
|
||||||
if (ingredient.test(stack)) {
|
if (ingredient.test(stack)) {
|
||||||
ItemStack remainderStack = getRemainderItem(stack);
|
ItemStack remainderStack = getRemainderItem(stack);
|
||||||
if(remainderStack.isEmpty()) {
|
if (remainderStack.isEmpty()) {
|
||||||
stack.decrement(1);
|
stack.decrement(1);
|
||||||
} else {
|
} else {
|
||||||
inventory.setStack(j, remainderStack);
|
inventory.setStack(j, remainderStack);
|
||||||
|
@ -223,7 +219,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack getRemainderItem(ItemStack stack) {
|
private ItemStack getRemainderItem(ItemStack stack) {
|
||||||
if(stack.getItem() instanceof ExtendedRecipeRemainder) {
|
if (stack.getItem() instanceof ExtendedRecipeRemainder) {
|
||||||
return ((ExtendedRecipeRemainder) stack.getItem()).getRemainderStack(stack);
|
return ((ExtendedRecipeRemainder) stack.getItem()).getRemainderStack(stack);
|
||||||
|
|
||||||
} else if (stack.getItem().hasRecipeRemainder()) {
|
} else if (stack.getItem().hasRecipeRemainder()) {
|
||||||
|
@ -310,7 +306,7 @@ public class AutoCraftingTableBlockEntity 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++) {
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
if(possibleSlots.contains(i)) {
|
if (possibleSlots.contains(i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ItemStack stackInSlot = inventory.getStack(i);
|
ItemStack stackInSlot = inventory.getStack(i);
|
||||||
|
@ -325,8 +321,8 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!possibleSlots.isEmpty()){
|
if (!possibleSlots.isEmpty()) {
|
||||||
int totalItems = possibleSlots.stream()
|
int totalItems = possibleSlots.stream()
|
||||||
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
|
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
|
||||||
int slots = possibleSlots.size();
|
int slots = possibleSlots.size();
|
||||||
|
|
||||||
|
@ -334,11 +330,11 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
int[] split = new int[slots];
|
int[] split = new int[slots];
|
||||||
int remainder = totalItems % slots;
|
int remainder = totalItems % slots;
|
||||||
Arrays.fill(split, totalItems / slots);
|
Arrays.fill(split, totalItems / slots);
|
||||||
while (remainder > 0){
|
while (remainder > 0) {
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
if(remainder > 0){
|
if (remainder > 0) {
|
||||||
split[i] +=1;
|
split[i] += 1;
|
||||||
remainder --;
|
remainder--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +346,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
boolean needsBalance = false;
|
boolean needsBalance = false;
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
int required = split[i];
|
int required = split[i];
|
||||||
if(slotEnvTyperubution.contains(required)){
|
if (slotEnvTyperubution.contains(required)) {
|
||||||
//We need to remove the int, not at the int, this seems to work around that
|
//We need to remove the int, not at the int, this seems to work around that
|
||||||
slotEnvTyperubution.remove(new Integer(required));
|
slotEnvTyperubution.remove(new Integer(required));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class ChemicalReactorBlockEntity extends GenericMachineBlockEntity implem
|
||||||
|
|
||||||
public ChemicalReactorBlockEntity() {
|
public ChemicalReactorBlockEntity() {
|
||||||
super(TRBlockEntities.CHEMICAL_REACTOR, "ChemicalReactor", TechRebornConfig.chemicalReactorMaxInput, TechRebornConfig.chemicalReactorMaxEnergy, TRContent.Machine.CHEMICAL_REACTOR.block, 3);
|
super(TRBlockEntities.CHEMICAL_REACTOR, "ChemicalReactor", TechRebornConfig.chemicalReactorMaxInput, TechRebornConfig.chemicalReactorMaxEnergy, TRContent.Machine.CHEMICAL_REACTOR.block, 3);
|
||||||
final int[] inputs = new int[] { 0, 1 };
|
final int[] inputs = new int[]{0, 1};
|
||||||
final int[] outputs = new int[] { 2 };
|
final int[] outputs = new int[]{2};
|
||||||
this.inventory = new RebornInventory<>(4, "ChemicalReactorBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(4, "ChemicalReactorBlockEntity", 64, this);
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.CHEMICAL_REACTOR, this, 2, 2, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.CHEMICAL_REACTOR, this, 2, 2, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class ChemicalReactorBlockEntity extends GenericMachineBlockEntity implem
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("chemicalreactor").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("chemicalreactor").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).energySlot(3, 8, 72)
|
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).energySlot(3, 8, 72)
|
||||||
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -40,8 +40,8 @@ public class CompressorBlockEntity extends GenericMachineBlockEntity implements
|
||||||
|
|
||||||
public CompressorBlockEntity() {
|
public CompressorBlockEntity() {
|
||||||
super(TRBlockEntities.COMPRESSOR, "Compressor", TechRebornConfig.compressorMaxInput, TechRebornConfig.compressorMaxEnergy, TRContent.Machine.COMPRESSOR.block, 2);
|
super(TRBlockEntities.COMPRESSOR, "Compressor", TechRebornConfig.compressorMaxInput, TechRebornConfig.compressorMaxEnergy, TRContent.Machine.COMPRESSOR.block, 2);
|
||||||
final int[] inputs = new int[] { 0 };
|
final int[] inputs = new int[]{0};
|
||||||
final int[] outputs = new int[] { 1 };
|
final int[] outputs = new int[]{1};
|
||||||
this.inventory = new RebornInventory<>(3, "CompressorBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(3, "CompressorBlockEntity", 64, this);
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.COMPRESSOR, this, 2, 1, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.COMPRESSOR, this, 2, 1, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
final int EnergyPerTick = 1;
|
final int EnergyPerTick = 1;
|
||||||
|
|
||||||
public ElectricFurnaceBlockEntity() {
|
public ElectricFurnaceBlockEntity() {
|
||||||
super(TRBlockEntities.ELECTRIC_FURNACE );
|
super(TRBlockEntities.ELECTRIC_FURNACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setInvDirty(boolean isDirty) {
|
private void setInvDirty(boolean isDirty) {
|
||||||
|
@ -99,7 +99,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ItemUtils.isItemEqual(inventory.getStack(slot), recipeOutput, true, true)) {
|
if (ItemUtils.isItemEqual(inventory.getStack(slot), recipeOutput, true, true)) {
|
||||||
return recipeOutput.getCount() + inventory.getStack(slot).getCount() <= recipeOutput.getMaxCount();
|
return recipeOutput.getCount() + inventory.getStack(slot).getCount() <= recipeOutput.getMaxCount();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,8 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
if (!canAcceptOutput(currentRecipe, outputSlot)) {
|
if (!canAcceptOutput(currentRecipe, outputSlot)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !(getEnergy() < currentRecipe.getCookTime() * getEuPerTick(EnergyPerTick));
|
return !(getEnergy() < currentRecipe.getCookTime() * getEuPerTick(EnergyPerTick));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetCrafter() {
|
private void resetCrafter() {
|
||||||
currentRecipe = null;
|
currentRecipe = null;
|
||||||
|
@ -143,8 +143,8 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return recipe.matches(inventory, world);
|
return recipe.matches(inventory, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void craftRecipe(SmeltingRecipe recipe) {
|
private void craftRecipe(SmeltingRecipe recipe) {
|
||||||
if (recipe == null) {
|
if (recipe == null) {
|
||||||
|
@ -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() {
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class ExtractorBlockEntity extends GenericMachineBlockEntity implements B
|
||||||
|
|
||||||
public ExtractorBlockEntity() {
|
public ExtractorBlockEntity() {
|
||||||
super(TRBlockEntities.EXTRACTOR, "Extractor", TechRebornConfig.extractorMaxInput, TechRebornConfig.extractorMaxEnergy, TRContent.Machine.EXTRACTOR.block, 2);
|
super(TRBlockEntities.EXTRACTOR, "Extractor", TechRebornConfig.extractorMaxInput, TechRebornConfig.extractorMaxEnergy, TRContent.Machine.EXTRACTOR.block, 2);
|
||||||
final int[] inputs = new int[] { 0 };
|
final int[] inputs = new int[]{0};
|
||||||
final int[] outputs = new int[] { 1 };
|
final int[] outputs = new int[]{1};
|
||||||
this.inventory = new RebornInventory<>(3, "ExtractorBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(3, "ExtractorBlockEntity", 64, this);
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.EXTRACTOR, this, 2, 1, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.EXTRACTOR, this, 2, 1, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ public class IndustrialElectrolyzerBlockEntity extends GenericMachineBlockEntity
|
||||||
|
|
||||||
public IndustrialElectrolyzerBlockEntity() {
|
public IndustrialElectrolyzerBlockEntity() {
|
||||||
super(TRBlockEntities.INDUSTRIAL_ELECTROLYZER, "IndustrialElectrolyzer", TechRebornConfig.industrialElectrolyzerMaxInput, TechRebornConfig.industrialElectrolyzerMaxEnergy, TRContent.Machine.INDUSTRIAL_ELECTROLYZER.block, 6);
|
super(TRBlockEntities.INDUSTRIAL_ELECTROLYZER, "IndustrialElectrolyzer", TechRebornConfig.industrialElectrolyzerMaxInput, TechRebornConfig.industrialElectrolyzerMaxEnergy, TRContent.Machine.INDUSTRIAL_ELECTROLYZER.block, 6);
|
||||||
final int[] inputs = new int[] { 0, 1 };
|
final int[] inputs = new int[]{0, 1};
|
||||||
final int[] outputs = new int[] { 2, 3, 4, 5 };
|
final int[] outputs = new int[]{2, 3, 4, 5};
|
||||||
this.inventory = new RebornInventory<>(7, "IndustrialElectrolyzerBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(7, "IndustrialElectrolyzerBlockEntity", 64, this);
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.INDUSTRIAL_ELECTROLYZER, this, 2, 4, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.INDUSTRIAL_ELECTROLYZER, this, 2, 4, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
@ -52,10 +52,10 @@ public class IndustrialElectrolyzerBlockEntity extends GenericMachineBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("industrialelectrolyzer").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("industrialelectrolyzer").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this)
|
.addInventory().blockEntity(this)
|
||||||
.filterSlot(1, 47, 72, stack -> ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
.filterSlot(1, 47, 72, stack -> ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||||
.filterSlot(0, 81, 72, stack -> !ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
.filterSlot(0, 81, 72, stack -> !ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||||
.outputSlot(2, 51, 24).outputSlot(3, 71, 24).outputSlot(4, 91, 24).outputSlot(5, 111, 24)
|
.outputSlot(2, 51, 24).outputSlot(3, 71, 24).outputSlot(4, 91, 24).outputSlot(5, 111, 24)
|
||||||
.energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
.energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -60,7 +60,7 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
|
||||||
boolean lastRedstone = redstone;
|
boolean lastRedstone = redstone;
|
||||||
redstone = false;
|
redstone = false;
|
||||||
if (canUseEnergy(TechRebornConfig.playerDetectorEuPerTick)) {
|
if (canUseEnergy(TechRebornConfig.playerDetectorEuPerTick)) {
|
||||||
for(PlayerEntity player : world.getPlayers()){
|
for (PlayerEntity player : world.getPlayers()) {
|
||||||
if (player.distanceTo(player) <= 256.0D) {
|
if (player.distanceTo(player) <= 256.0D) {
|
||||||
PlayerDetectorType type = world.getBlockState(pos).get(BlockPlayerDetector.TYPE);
|
PlayerDetectorType type = world.getBlockState(pos).get(BlockPlayerDetector.TYPE);
|
||||||
if (type == PlayerDetectorType.ALL) {// ALL
|
if (type == PlayerDetectorType.ALL) {// ALL
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,16 +85,13 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRecycle() {
|
public boolean canRecycle() {
|
||||||
return !inventory.getStack(0) .isEmpty() && hasSlotGotSpace(1);
|
return !inventory.getStack(0).isEmpty() && hasSlotGotSpace(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
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,13 +125,12 @@ 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);
|
||||||
}
|
}
|
||||||
progress++;
|
progress++;
|
||||||
if (progress >= Math.max((int) (time* (1.0 - getSpeedMultiplier())), 1)) {
|
if (progress >= Math.max((int) (time * (1.0 - getSpeedMultiplier())), 1)) {
|
||||||
progress = 0;
|
progress = 0;
|
||||||
recycleItems();
|
recycleItems();
|
||||||
updateInventory = true;
|
updateInventory = true;
|
||||||
|
|
|
@ -153,7 +153,7 @@ public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
|
||||||
|
|
||||||
this.isFull = blockState.get(ResinBasinBlock.FULL);
|
this.isFull = blockState.get(ResinBasinBlock.FULL);
|
||||||
|
|
||||||
if(blockState.get(ResinBasinBlock.POURING)){
|
if (blockState.get(ResinBasinBlock.POURING)) {
|
||||||
this.isPouring = true;
|
this.isPouring = true;
|
||||||
pouringTimer = TechRebornConfig.sapTimeTicks;
|
pouringTimer = TechRebornConfig.sapTimeTicks;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,9 @@ import java.util.stream.Collectors;
|
||||||
//TODO add tick and power bars.
|
//TODO add tick and power bars.
|
||||||
|
|
||||||
public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
|
implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
public int[] craftingSlots = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
|
public int[] craftingSlots = new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8};
|
||||||
private CraftingInventory craftCache;
|
private CraftingInventory craftCache;
|
||||||
public RebornInventory<RollingMachineBlockEntity> inventory = new RebornInventory<>(12, "RollingMachineBlockEntity", 64, this);
|
public RebornInventory<RollingMachineBlockEntity> inventory = new RebornInventory<>(12, "RollingMachineBlockEntity", 64, this);
|
||||||
public boolean isRunning;
|
public boolean isRunning;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -177,12 +177,12 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsActive(boolean active) {
|
public void setIsActive(boolean active) {
|
||||||
if (active == isRunning){
|
if (active == isRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isRunning = active;
|
isRunning = active;
|
||||||
if (this.getWorld().getBlockState(this.getPos()).getBlock() instanceof BlockMachineBase) {
|
if (this.getWorld().getBlockState(this.getPos()).getBlock() instanceof BlockMachineBase) {
|
||||||
BlockMachineBase blockMachineBase = (BlockMachineBase)this.getWorld().getBlockState(this.getPos()).getBlock();
|
BlockMachineBase blockMachineBase = (BlockMachineBase) this.getWorld().getBlockState(this.getPos()).getBlock();
|
||||||
blockMachineBase.setActive(active, this.getWorld(), this.getPos());
|
blockMachineBase.setActive(active, this.getWorld(), this.getPos());
|
||||||
}
|
}
|
||||||
this.getWorld().updateListeners(this.getPos(), this.getWorld().getBlockState(this.getPos()), this.getWorld().getBlockState(this.getPos()), 3);
|
this.getWorld().updateListeners(this.getPos(), this.getWorld().getBlockState(this.getPos()), this.getWorld().getBlockState(this.getPos()), 3);
|
||||||
|
@ -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);
|
||||||
|
@ -223,32 +223,32 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!possibleSlots.isEmpty()){
|
if (!possibleSlots.isEmpty()) {
|
||||||
int totalItems = possibleSlots.stream()
|
int totalItems = possibleSlots.stream()
|
||||||
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
|
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
|
||||||
int slots = possibleSlots.size();
|
int slots = possibleSlots.size();
|
||||||
|
|
||||||
//This makes an array of ints with the best possible slot EnvTyperibution
|
//This makes an array of ints with the best possible slot EnvTyperibution
|
||||||
int[] split = new int[slots];
|
int[] split = new int[slots];
|
||||||
int remainder = totalItems % slots;
|
int remainder = totalItems % slots;
|
||||||
Arrays.fill(split, totalItems / slots);
|
Arrays.fill(split, totalItems / slots);
|
||||||
while (remainder > 0){
|
while (remainder > 0) {
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
if(remainder > 0){
|
if (remainder > 0) {
|
||||||
split[i] +=1;
|
split[i] += 1;
|
||||||
remainder --;
|
remainder--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> slotEnvTyperubution = possibleSlots.stream()
|
List<Integer> slotEnvTyperubution = possibleSlots.stream()
|
||||||
.mapToInt(value -> inventory.getStack(value).getCount())
|
.mapToInt(value -> inventory.getStack(value).getCount())
|
||||||
.boxed().collect(Collectors.toList());
|
.boxed().collect(Collectors.toList());
|
||||||
|
|
||||||
boolean needsBalance = false;
|
boolean needsBalance = false;
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
int required = split[i];
|
int required = split[i];
|
||||||
if(slotEnvTyperubution.contains(required)){
|
if (slotEnvTyperubution.contains(required)) {
|
||||||
//We need to remove the int, not at the int, this seems to work around that
|
//We need to remove the int, not at the int, this seems to work around that
|
||||||
slotEnvTyperubution.remove(new Integer(required));
|
slotEnvTyperubution.remove(new Integer(required));
|
||||||
} else {
|
} else {
|
||||||
|
@ -276,10 +276,10 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bestSlot == null
|
if (bestSlot == null
|
||||||
|| bestSlot.getLeft() == balanceSlot
|
|| bestSlot.getLeft() == balanceSlot
|
||||||
|| bestSlot.getRight() == sourceStack.getCount()
|
|| bestSlot.getRight() == sourceStack.getCount()
|
||||||
|| inventory.getStack(bestSlot.getLeft()).isEmpty()
|
|| inventory.getStack(bestSlot.getLeft()).isEmpty()
|
||||||
|| !ItemUtils.isItemEqual(sourceStack, inventory.getStack(bestSlot.getLeft()), true, true)) {
|
|| !ItemUtils.isItemEqual(sourceStack, inventory.getStack(bestSlot.getLeft()), true, true)) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
sourceStack.decrement(1);
|
sourceStack.decrement(1);
|
||||||
|
@ -322,13 +322,13 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return ItemUtils.isItemEqual(stack, output, true, true);
|
return ItemUtils.isItemEqual(stack, output, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RollingMachineRecipe> getAllRecipe(World world){
|
public List<RollingMachineRecipe> getAllRecipe(World world) {
|
||||||
return ModRecipes.ROLLING_MACHINE.getRecipes(world);
|
return ModRecipes.ROLLING_MACHINE.getRecipes(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack findMatchingRecipeOutput(CraftingInventory inv, World world) {
|
public ItemStack findMatchingRecipeOutput(CraftingInventory inv, World world) {
|
||||||
RollingMachineRecipe recipe = findMatchingRecipe(inv, world);
|
RollingMachineRecipe recipe = findMatchingRecipe(inv, world);
|
||||||
if(recipe == null){
|
if (recipe == null) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
return recipe.getOutput();
|
return recipe.getOutput();
|
||||||
|
@ -379,24 +379,24 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBurnTimeRemainingScaled(final int scale) {
|
public int getBurnTimeRemainingScaled(final int scale) {
|
||||||
if (tickTime == 0 || Math.max((int) (TechRebornConfig.rollingMachineRunTime* (1.0 - getSpeedMultiplier())), 1) == 0) {
|
if (tickTime == 0 || Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1) == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime* (1.0 - getSpeedMultiplier())), 1);
|
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("rollingmachine").player(player.inventory)
|
return new ScreenHandlerBuilder("rollingmachine").player(player.inventory)
|
||||||
.inventory().hotbar()
|
.inventory().hotbar()
|
||||||
.addInventory().blockEntity(this)
|
.addInventory().blockEntity(this)
|
||||||
.slot(0, 30, 22).slot(1, 48, 22).slot(2, 66, 22)
|
.slot(0, 30, 22).slot(1, 48, 22).slot(2, 66, 22)
|
||||||
.slot(3, 30, 40).slot(4, 48, 40).slot(5, 66, 40)
|
.slot(3, 30, 40).slot(4, 48, 40).slot(5, 66, 40)
|
||||||
.slot(6, 30, 58).slot(7, 48, 58).slot(8, 66, 58)
|
.slot(6, 30, 58).slot(7, 48, 58).slot(8, 66, 58)
|
||||||
.onCraft(inv -> this.inventory.setStack(1, findMatchingRecipeOutput(getCraftingMatrix(), this.world)))
|
.onCraft(inv -> this.inventory.setStack(1, findMatchingRecipeOutput(getCraftingMatrix(), this.world)))
|
||||||
.outputSlot(9, 124, 40)
|
.outputSlot(9, 124, 40)
|
||||||
.energySlot(10, 8, 70)
|
.energySlot(10, 8, 70)
|
||||||
.syncEnergyValue().sync(this::getBurnTime, this::setBurnTime).sync(this::getLockedInt, this::setLockedInt).addInventory().create(this, syncID);
|
.syncEnergyValue().sync(this::getBurnTime, this::setBurnTime).sync(this::getLockedInt, this::setLockedInt).addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Easyest way to sync back to the client
|
//Easyest way to sync back to the client
|
||||||
|
@ -409,8 +409,8 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgressScaled(final int scale) {
|
public int getProgressScaled(final int scale) {
|
||||||
if (tickTime != 0 && Math.max((int) (TechRebornConfig.rollingMachineRunTime* (1.0 - getSpeedMultiplier())), 1) != 0) {
|
if (tickTime != 0 && Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1) != 0) {
|
||||||
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime* (1.0 - getSpeedMultiplier())), 1);
|
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class ScrapboxinatorBlockEntity extends GenericMachineBlockEntity impleme
|
||||||
|
|
||||||
public ScrapboxinatorBlockEntity() {
|
public ScrapboxinatorBlockEntity() {
|
||||||
super(TRBlockEntities.SCRAPBOXINATOR, "Scrapboxinator", TechRebornConfig.scrapboxinatorMaxInput, TechRebornConfig.scrapboxinatorMaxEnergy, TRContent.Machine.SCRAPBOXINATOR.block, 2);
|
super(TRBlockEntities.SCRAPBOXINATOR, "Scrapboxinator", TechRebornConfig.scrapboxinatorMaxInput, TechRebornConfig.scrapboxinatorMaxEnergy, TRContent.Machine.SCRAPBOXINATOR.block, 2);
|
||||||
final int[] inputs = new int[] { 0 };
|
final int[] inputs = new int[]{0};
|
||||||
final int[] outputs = new int[] { 1 };
|
final int[] outputs = new int[]{1};
|
||||||
this.inventory = new RebornInventory<>(3, "ScrapboxinatorBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(3, "ScrapboxinatorBlockEntity", 64, this);
|
||||||
this.crafter = new ScrapboxRecipeCrafter(this, this.inventory, inputs, outputs);
|
this.crafter = new ScrapboxRecipeCrafter(this, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class SoildCanningMachineBlockEntity extends GenericMachineBlockEntity im
|
||||||
|
|
||||||
public SoildCanningMachineBlockEntity() {
|
public SoildCanningMachineBlockEntity() {
|
||||||
super(TRBlockEntities.SOLID_CANNING_MACHINE, "SolidCanningMachine", TechRebornConfig.solidCanningMachineMaxInput, TechRebornConfig.solidCanningMachineMaxEnergy, TRContent.Machine.SOLID_CANNING_MACHINE.block, 3);
|
super(TRBlockEntities.SOLID_CANNING_MACHINE, "SolidCanningMachine", TechRebornConfig.solidCanningMachineMaxInput, TechRebornConfig.solidCanningMachineMaxEnergy, TRContent.Machine.SOLID_CANNING_MACHINE.block, 3);
|
||||||
final int[] inputs = new int[] { 0, 1 };
|
final int[] inputs = new int[]{0, 1};
|
||||||
final int[] outputs = new int[] { 2 };
|
final int[] outputs = new int[]{2};
|
||||||
this.inventory = new RebornInventory<>(4, "SolidCanningMachineBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(4, "SolidCanningMachineBlockEntity", 64, this);
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.SOLID_CANNING_MACHINE, this, 2, 1, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.SOLID_CANNING_MACHINE, this, 2, 1, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ public class SoildCanningMachineBlockEntity extends GenericMachineBlockEntity im
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("solidcanningmachine").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("solidcanningmachine").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this)
|
.addInventory().blockEntity(this)
|
||||||
.slot(0, 34, 47)
|
.slot(0, 34, 47)
|
||||||
.slot(1, 126, 47)
|
.slot(1, 126, 47)
|
||||||
.outputSlot(2, 80, 47).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory()
|
.outputSlot(2, 80, 47).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory()
|
||||||
.create(this, syncID);
|
.create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class WireMillBlockEntity extends GenericMachineBlockEntity implements Bu
|
||||||
|
|
||||||
public WireMillBlockEntity() {
|
public WireMillBlockEntity() {
|
||||||
super(TRBlockEntities.WIRE_MILL, "WireMill", 32, 1000, TRContent.Machine.WIRE_MILL.block, 2);
|
super(TRBlockEntities.WIRE_MILL, "WireMill", 32, 1000, TRContent.Machine.WIRE_MILL.block, 2);
|
||||||
final int[] inputs = new int[] { 0 };
|
final int[] inputs = new int[]{0};
|
||||||
final int[] outputs = new int[] { 1 };
|
final int[] outputs = new int[]{1};
|
||||||
this.inventory = new RebornInventory<>(3, "WireMillBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(3, "WireMillBlockEntity", 64, this);
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.WIRE_MILL, this, 1, 1, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.WIRE_MILL, this, 1, 1, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
@ -49,13 +49,13 @@ public class WireMillBlockEntity extends GenericMachineBlockEntity implements Bu
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("wiremill").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("wiremill").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this)
|
.addInventory().blockEntity(this)
|
||||||
.slot(0, 55, 45)
|
.slot(0, 55, 45)
|
||||||
.outputSlot(1, 101, 45)
|
.outputSlot(1, 101, 45)
|
||||||
.energySlot(2, 8, 72)
|
.energySlot(2, 8, 72)
|
||||||
.syncEnergyValue()
|
.syncEnergyValue()
|
||||||
.syncCrafterValue()
|
.syncCrafterValue()
|
||||||
.addInventory()
|
.addInventory()
|
||||||
.create(this, syncID);
|
.create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
||||||
private String ownerUdid;
|
private String ownerUdid;
|
||||||
|
|
||||||
public ChunkLoaderBlockEntity() {
|
public ChunkLoaderBlockEntity() {
|
||||||
super(TRBlockEntities.CHUNK_LOADER );
|
super(TRBlockEntities.CHUNK_LOADER);
|
||||||
this.radius = 1;
|
this.radius = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
if(playerEntity != null){
|
if (playerEntity != null) {
|
||||||
ChunkLoaderManager manager = ChunkLoaderManager.get(getWorld());
|
ChunkLoaderManager manager = ChunkLoaderManager.get(getWorld());
|
||||||
manager.syncChunkLoaderToClient((ServerPlayerEntity) playerEntity, getPos());
|
manager.syncChunkLoaderToClient((ServerPlayerEntity) playerEntity, getPos());
|
||||||
}
|
}
|
||||||
|
@ -82,20 +82,20 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
||||||
return TRContent.Machine.CHUNK_LOADER.getStack();
|
return TRContent.Machine.CHUNK_LOADER.getStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reload(){
|
private void reload() {
|
||||||
unloadAll();
|
unloadAll();
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load(){
|
private void load() {
|
||||||
ChunkLoaderManager manager = ChunkLoaderManager.get(getWorld());
|
ChunkLoaderManager manager = ChunkLoaderManager.get(getWorld());
|
||||||
ChunkPos rootPos = getChunkPos();
|
ChunkPos rootPos = getChunkPos();
|
||||||
int loadRadius = radius -1;
|
int loadRadius = radius - 1;
|
||||||
for (int i = -loadRadius; i <= loadRadius; i++) {
|
for (int i = -loadRadius; i <= loadRadius; i++) {
|
||||||
for (int j = -loadRadius; j <= loadRadius; j++) {
|
for (int j = -loadRadius; j <= loadRadius; j++) {
|
||||||
ChunkPos loadPos = new ChunkPos(rootPos.x + i, rootPos.z + j);
|
ChunkPos loadPos = new ChunkPos(rootPos.x + i, rootPos.z + j);
|
||||||
|
|
||||||
if(!manager.isChunkLoaded(getWorld(), loadPos, getPos())){
|
if (!manager.isChunkLoaded(getWorld(), loadPos, getPos())) {
|
||||||
manager.loadChunk(getWorld(), loadPos, getPos(), ownerUdid);
|
manager.loadChunk(getWorld(), loadPos, getPos(), ownerUdid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
|
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
|
||||||
if(world.isClient){
|
if (world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unloadAll();
|
unloadAll();
|
||||||
|
@ -114,19 +114,19 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlace(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
public void onPlace(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
||||||
if(world.isClient){
|
if (world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ownerUdid = placer.getUuidAsString();
|
ownerUdid = placer.getUuidAsString();
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unloadAll(){
|
private void unloadAll() {
|
||||||
ChunkLoaderManager manager = ChunkLoaderManager.get(world);
|
ChunkLoaderManager manager = ChunkLoaderManager.get(world);
|
||||||
manager.unloadChunkLoader(world, getPos());
|
manager.unloadChunkLoader(world, getPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkPos getChunkPos(){
|
public ChunkPos getChunkPos() {
|
||||||
return new ChunkPos(getPos());
|
return new ChunkPos(getPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
||||||
super.fromTag(blockState, nbttagcompound);
|
super.fromTag(blockState, nbttagcompound);
|
||||||
this.radius = nbttagcompound.getInt("radius");
|
this.radius = nbttagcompound.getInt("radius");
|
||||||
this.ownerUdid = nbttagcompound.getString("ownerUdid");
|
this.ownerUdid = nbttagcompound.getString("ownerUdid");
|
||||||
if(!StringUtils.isBlank(ownerUdid)){
|
if (!StringUtils.isBlank(ownerUdid)) {
|
||||||
nbttagcompound.putString("ownerUdid", this.ownerUdid);
|
nbttagcompound.putString("ownerUdid", this.ownerUdid);
|
||||||
}
|
}
|
||||||
inventory.read(nbttagcompound);
|
inventory.read(nbttagcompound);
|
||||||
|
|
|
@ -48,8 +48,8 @@ public class IndustrialCentrifugeBlockEntity extends GenericMachineBlockEntity i
|
||||||
|
|
||||||
public IndustrialCentrifugeBlockEntity() {
|
public IndustrialCentrifugeBlockEntity() {
|
||||||
super(TRBlockEntities.INDUSTRIAL_CENTRIFUGE, "IndustrialCentrifuge", TechRebornConfig.industrialCentrifugeMaxInput, TechRebornConfig.industrialCentrifugeMaxEnergy, TRContent.Machine.INDUSTRIAL_CENTRIFUGE.block, 6);
|
super(TRBlockEntities.INDUSTRIAL_CENTRIFUGE, "IndustrialCentrifuge", TechRebornConfig.industrialCentrifugeMaxInput, TechRebornConfig.industrialCentrifugeMaxEnergy, TRContent.Machine.INDUSTRIAL_CENTRIFUGE.block, 6);
|
||||||
final int[] inputs = new int[] { 0, 1 };
|
final int[] inputs = new int[]{0, 1};
|
||||||
final int[] outputs = new int[] { 2, 3, 4, 5 };
|
final int[] outputs = new int[]{2, 3, 4, 5};
|
||||||
this.inventory = new RebornInventory<>(7, "IndustrialCentrifugeBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(7, "IndustrialCentrifugeBlockEntity", 64, this);
|
||||||
this.crafter = new RecipeCrafter(ModRecipes.CENTRIFUGE, this, 2, 4, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(ModRecipes.CENTRIFUGE, this, 2, 4, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
@ -58,19 +58,19 @@ public class IndustrialCentrifugeBlockEntity extends GenericMachineBlockEntity i
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("centrifuge").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("centrifuge").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this)
|
.addInventory().blockEntity(this)
|
||||||
.filterSlot(1, 40, 54, stack -> ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
.filterSlot(1, 40, 54, stack -> ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||||
.filterSlot(0, 40, 34, stack -> !ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
.filterSlot(0, 40, 34, stack -> !ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||||
.outputSlot(2, 82, 44).outputSlot(3, 101, 25)
|
.outputSlot(2, 82, 44).outputSlot(3, 101, 25)
|
||||||
.outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue()
|
.outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue()
|
||||||
.syncCrafterValue().addInventory().create(this, syncID);
|
.syncCrafterValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IListInfoProvider
|
// IListInfoProvider
|
||||||
@Override
|
@Override
|
||||||
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
|
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
|
||||||
super.addInfo(info, isReal, hasData);
|
super.addInfo(info, isReal, hasData);
|
||||||
if(Screen.hasControlDown()) {
|
if (Screen.hasControlDown()) {
|
||||||
info.add(new LiteralText("Round and round it goes"));
|
info.add(new LiteralText("Round and round it goes"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
||||||
private int amplifier = 0;
|
private int amplifier = 0;
|
||||||
|
|
||||||
public MatterFabricatorBlockEntity() {
|
public MatterFabricatorBlockEntity() {
|
||||||
super(TRBlockEntities.MATTER_FABRICATOR );
|
super(TRBlockEntities.MATTER_FABRICATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean spaceForOutput() {
|
private boolean spaceForOutput() {
|
||||||
|
@ -61,7 +61,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
||||||
private boolean spaceForOutput(int slot) {
|
private boolean spaceForOutput(int slot) {
|
||||||
return inventory.getStack(slot).isEmpty()
|
return inventory.getStack(slot).isEmpty()
|
||||||
|| ItemUtils.isItemEqual(inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)
|
|| ItemUtils.isItemEqual(inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)
|
||||||
&& inventory.getStack(slot).getCount() < 64;
|
&& inventory.getStack(slot).getCount() < 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOutputProducts() {
|
private void addOutputProducts() {
|
||||||
|
@ -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())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,19 +49,19 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
super(TRBlockEntities.ADJUSTABLE_SU, "ADJUSTABLE_SU", 4, TRContent.Machine.ADJUSTABLE_SU.block, EnergyTier.INSANE, TechRebornConfig.aesuMaxEnergy);
|
super(TRBlockEntities.ADJUSTABLE_SU, "ADJUSTABLE_SU", 4, TRContent.Machine.ADJUSTABLE_SU.block, EnergyTier.INSANE, TechRebornConfig.aesuMaxEnergy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxConfigOutput(){
|
public int getMaxConfigOutput() {
|
||||||
int extra = 0;
|
int extra = 0;
|
||||||
if(superconductors > 0){
|
if (superconductors > 0) {
|
||||||
extra = (int) Math.pow(2, (superconductors + 2)) * maxOutput;
|
extra = (int) Math.pow(2, (superconductors + 2)) * maxOutput;
|
||||||
}
|
}
|
||||||
return maxOutput + extra;
|
return maxOutput + extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleGuiInputFromClient(int id, boolean shift, boolean ctrl) {
|
public void handleGuiInputFromClient(int id, boolean shift, boolean ctrl) {
|
||||||
if(shift){
|
if (shift) {
|
||||||
id *= 4;
|
id *= 4;
|
||||||
}
|
}
|
||||||
if(ctrl){
|
if (ctrl) {
|
||||||
id *= 8;
|
id *= 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,14 +88,14 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (world == null){
|
if (world == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OUTPUT > getMaxConfigOutput()) {
|
if (OUTPUT > getMaxConfigOutput()) {
|
||||||
OUTPUT = getMaxConfigOutput();
|
OUTPUT = getMaxConfigOutput();
|
||||||
}
|
}
|
||||||
if(world.getTime() % 20 == 0){
|
if (world.getTime() % 20 == 0) {
|
||||||
checkTier();
|
checkTier();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public double getBaseMaxInput() {
|
||||||
//If we have super conductors increase the max input of the machine
|
//If we have super conductors increase the max input of the machine
|
||||||
if(getMaxConfigOutput() > maxOutput){
|
if (getMaxConfigOutput() > maxOutput) {
|
||||||
return getMaxConfigOutput();
|
return getMaxConfigOutput();
|
||||||
}
|
}
|
||||||
return maxInput;
|
return maxInput;
|
||||||
|
|
|
@ -113,13 +113,15 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Direction getFacingEnum() {
|
public Direction getFacingEnum() {
|
||||||
if(world == null){
|
if (world == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Block block = world.getBlockState(pos).getBlock();
|
Block block = world.getBlockState(pos).getBlock();
|
||||||
|
|
|
@ -34,12 +34,11 @@ 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 {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MFSU should store 4M Energy with 512 E/t I/O
|
* MFSU should store 4M Energy with 512 E/t I/O
|
||||||
*/
|
*/
|
||||||
public HighVoltageSUBlockEntity() {
|
public HighVoltageSUBlockEntity() {
|
||||||
super(TRBlockEntities.HIGH_VOLTAGE_SU, "HIGH_VOLTAGE_SU", 2, TRContent.Machine.HIGH_VOLTAGE_SU.block, EnergyTier.HIGH, 4_000_000);
|
super(TRBlockEntities.HIGH_VOLTAGE_SU, "HIGH_VOLTAGE_SU", 2, TRContent.Machine.HIGH_VOLTAGE_SU.block, EnergyTier.HIGH, 4_000_000);
|
||||||
|
@ -48,7 +47,7 @@ public class HighVoltageSUBlockEntity extends EnergyStorageBlockEntity implement
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("mfsu").player(player.inventory).inventory().hotbar().armor()
|
return new ScreenHandlerBuilder("mfsu").player(player.inventory).inventory().hotbar().armor()
|
||||||
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
|
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
|
||||||
.syncEnergyValue().addInventory().create(this, syncID);
|
.syncEnergyValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -44,6 +44,6 @@ public class LowVoltageSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("batbox").player(player.inventory).inventory().hotbar().addInventory()
|
return new ScreenHandlerBuilder("batbox").player(player.inventory).inventory().hotbar().addInventory()
|
||||||
.blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create(this, syncID);
|
.blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,11 @@ 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 {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MFE should store 300k energy with 128 E/t I/O
|
* MFE should store 300k energy with 128 E/t I/O
|
||||||
*/
|
*/
|
||||||
public MediumVoltageSUBlockEntity() {
|
public MediumVoltageSUBlockEntity() {
|
||||||
super(TRBlockEntities.MEDIUM_VOLTAGE_SU, "MEDIUM_VOLTAGE_SU", 2, TRContent.Machine.MEDIUM_VOLTAGE_SU.block, EnergyTier.MEDIUM, 300_000);
|
super(TRBlockEntities.MEDIUM_VOLTAGE_SU, "MEDIUM_VOLTAGE_SU", 2, TRContent.Machine.MEDIUM_VOLTAGE_SU.block, EnergyTier.MEDIUM, 300_000);
|
||||||
|
@ -48,8 +47,8 @@ public class MediumVoltageSUBlockEntity extends EnergyStorageBlockEntity impleme
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("mfe").player(player.inventory).inventory().hotbar().armor()
|
return new ScreenHandlerBuilder("mfe").player(player.inventory).inventory().hotbar().armor()
|
||||||
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
|
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
|
||||||
.syncEnergyValue().addInventory().create(this, syncID);
|
.syncEnergyValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -42,11 +42,11 @@ public class IDSUManager extends PersistentState {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static IDSUPlayer getPlayer(World world, String uuid){
|
public static IDSUPlayer getPlayer(World world, String uuid) {
|
||||||
return get(world).getPlayer(uuid);
|
return get(world).getPlayer(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDSUManager get(World world){
|
public static IDSUManager get(World world) {
|
||||||
ServerWorld serverWorld = (ServerWorld) world;
|
ServerWorld serverWorld = (ServerWorld) world;
|
||||||
return serverWorld.getPersistentStateManager().getOrCreate(IDSUManager::new, KEY);
|
return serverWorld.getPersistentStateManager().getOrCreate(IDSUManager::new, KEY);
|
||||||
}
|
}
|
||||||
|
@ -54,13 +54,13 @@ public class IDSUManager extends PersistentState {
|
||||||
private final HashMap<String, IDSUPlayer> playerHashMap = new HashMap<>();
|
private final HashMap<String, IDSUPlayer> playerHashMap = new HashMap<>();
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public IDSUPlayer getPlayer(String uuid){
|
public IDSUPlayer getPlayer(String uuid) {
|
||||||
return playerHashMap.computeIfAbsent(uuid, s -> new IDSUPlayer());
|
return playerHashMap.computeIfAbsent(uuid, s -> new IDSUPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromTag(CompoundTag tag) {
|
public void fromTag(CompoundTag tag) {
|
||||||
for(String uuid : tag.getKeys()){
|
for (String uuid : tag.getKeys()) {
|
||||||
playerHashMap.put(uuid, new IDSUPlayer(tag.getCompound(uuid)));
|
playerHashMap.put(uuid, new IDSUPlayer(tag.getCompound(uuid)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class IDSUManager extends PersistentState {
|
||||||
private IDSUPlayer() {
|
private IDSUPlayer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDSUPlayer(CompoundTag compoundTag){
|
private IDSUPlayer(CompoundTag compoundTag) {
|
||||||
read(compoundTag);
|
read(compoundTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
||||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if(world.isClient){
|
if (world.isClient) {
|
||||||
return clientEnergy;
|
return clientEnergy;
|
||||||
}
|
}
|
||||||
return IDSUManager.getPlayer(world, ownerUdid).getEnergy();
|
return IDSUManager.getPlayer(world, ownerUdid).getEnergy();
|
||||||
|
@ -65,7 +65,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
||||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(world.isClient){
|
if (world.isClient) {
|
||||||
clientEnergy = energy;
|
clientEnergy = energy;
|
||||||
} else {
|
} else {
|
||||||
IDSUManager.getPlayer(world, ownerUdid).setEnergy(energy);
|
IDSUManager.getPlayer(world, ownerUdid).setEnergy(energy);
|
||||||
|
@ -77,7 +77,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
||||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if(world.isClient){
|
if (world.isClient) {
|
||||||
throw new UnsupportedOperationException("cannot set energy on the client!");
|
throw new UnsupportedOperationException("cannot set energy on the client!");
|
||||||
}
|
}
|
||||||
double energy = IDSUManager.getPlayer(world, ownerUdid).getEnergy();
|
double energy = IDSUManager.getPlayer(world, ownerUdid).getEnergy();
|
||||||
|
@ -95,7 +95,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
||||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(world.isClient){
|
if (world.isClient) {
|
||||||
throw new UnsupportedOperationException("cannot set energy on the client!");
|
throw new UnsupportedOperationException("cannot set energy on the client!");
|
||||||
}
|
}
|
||||||
return input <= IDSUManager.getPlayer(world, ownerUdid).getEnergy();
|
return input <= IDSUManager.getPlayer(world, ownerUdid).getEnergy();
|
||||||
|
@ -120,8 +120,8 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("idsu").player(player.inventory).inventory().hotbar().armor()
|
return new ScreenHandlerBuilder("idsu").player(player.inventory).inventory().hotbar().armor()
|
||||||
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
|
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
|
||||||
.syncEnergyValue().addInventory().create(this, syncID);
|
.syncEnergyValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,7 +36,7 @@ import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
public class LSUStorageBlockEntity extends MachineBaseBlockEntity
|
public class LSUStorageBlockEntity extends MachineBaseBlockEntity
|
||||||
implements IToolDrop {
|
implements IToolDrop {
|
||||||
|
|
||||||
public LesuNetwork network;
|
public LesuNetwork network;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class LSUStorageBlockEntity extends MachineBaseBlockEntity
|
||||||
} else {
|
} else {
|
||||||
if (network.master != null
|
if (network.master != null
|
||||||
&& network.master.getWorld().getBlockEntity(new BlockPos(network.master.getPos().getX(),
|
&& network.master.getWorld().getBlockEntity(new BlockPos(network.master.getPos().getX(),
|
||||||
network.master.getPos().getY(), network.master.getPos().getZ())) != network.master) {
|
network.master.getPos().getY(), network.master.getPos().getZ())) != network.master) {
|
||||||
network.master = null;
|
network.master = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -51,22 +51,20 @@ public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
this.maxOutput = TechRebornConfig.lesuBaseOutput;
|
this.maxOutput = TechRebornConfig.lesuBaseOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMaxStorage(){
|
private void setMaxStorage() {
|
||||||
maxStorage = (connectedBlocks + 1) * TechRebornConfig.lesuStoragePerBlock;
|
maxStorage = (connectedBlocks + 1) * TechRebornConfig.lesuStoragePerBlock;
|
||||||
if (maxStorage < 0 || maxStorage > Integer.MAX_VALUE) {
|
if (maxStorage < 0 || maxStorage > Integer.MAX_VALUE) {
|
||||||
maxStorage = Integer.MAX_VALUE;
|
maxStorage = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setIORate(){
|
private void setIORate() {
|
||||||
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;
|
||||||
|
@ -81,7 +80,7 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FluidUtils.drainContainers(tank, inventory, 0, 1)
|
if (FluidUtils.drainContainers(tank, inventory, 0, 1)
|
||||||
|| FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid())) {
|
|| FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid())) {
|
||||||
|
|
||||||
if (type == TRContent.TankUnit.CREATIVE) {
|
if (type == TRContent.TankUnit.CREATIVE) {
|
||||||
if (!tank.isEmpty() && !tank.isFull()) {
|
if (!tank.isEmpty() && !tank.isFull()) {
|
||||||
|
@ -137,8 +136,8 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
|
||||||
if (!this.tank.getFluidInstance().isEmpty()) {
|
if (!this.tank.getFluidInstance().isEmpty()) {
|
||||||
info.add(
|
info.add(
|
||||||
new LiteralText(String.valueOf(this.tank.getFluidAmount()))
|
new LiteralText(String.valueOf(this.tank.getFluidAmount()))
|
||||||
.append(new TranslatableText("techreborn.tooltip.unit.divider"))
|
.append(new TranslatableText("techreborn.tooltip.unit.divider"))
|
||||||
.append(WordUtils.capitalize(FluidUtil.getFluidName(this.tank.getFluid())))
|
.append(WordUtils.capitalize(FluidUtil.getFluidName(this.tank.getFluid())))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
info.add(new TranslatableText("techreborn.tooltip.unit.empty"));
|
info.add(new TranslatableText("techreborn.tooltip.unit.empty"));
|
||||||
|
@ -146,14 +145,14 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
|
||||||
}
|
}
|
||||||
info.add(
|
info.add(
|
||||||
new TranslatableText("techreborn.tooltip.unit.capacity")
|
new TranslatableText("techreborn.tooltip.unit.capacity")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(
|
.append(
|
||||||
new LiteralText(String.valueOf(this.tank.getCapacity()))
|
new LiteralText(String.valueOf(this.tank.getCapacity()))
|
||||||
.formatted(Formatting.GOLD)
|
.formatted(Formatting.GOLD)
|
||||||
.append(" (")
|
.append(" (")
|
||||||
.append(String.valueOf(this.tank.getCapacity().getRawValue() / 1000))
|
.append(String.valueOf(this.tank.getCapacity().getRawValue() / 1000))
|
||||||
.append(")")
|
.append(")")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,8 +160,8 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("tank").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("tank").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this).fluidSlot(0, 100, 53).outputSlot(1, 140, 53)
|
.addInventory().blockEntity(this).fluidSlot(0, 100, 53).outputSlot(1, 140, 53)
|
||||||
.sync(tank).addInventory().create(this, syncID);
|
.sync(tank).addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|
|
@ -32,10 +32,8 @@ import net.minecraft.text.LiteralText;
|
||||||
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.Formatting;
|
||||||
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 net.minecraft.util.registry.Registry;
|
|
||||||
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;
|
||||||
|
@ -247,7 +245,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int index, ItemStack stack, @Nullable Direction direction) {
|
public boolean canInsert(int index, ItemStack stack, @Nullable Direction direction) {
|
||||||
return super.canInsert(index, stack, direction) && (this.isEmpty() && !isLocked() || isSameType(stack));
|
return super.canInsert(index, stack, direction) && (this.isEmpty() && !isLocked() || isSameType(stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentCapacity() {
|
public int getCurrentCapacity() {
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
public boolean canAcceptEnergy(Direction direction) {
|
||||||
if (TechRebornConfig.IC2TransformersStyle){
|
if (TechRebornConfig.IC2TransformersStyle) {
|
||||||
return getFacingEnum() == direction;
|
return getFacingEnum() == direction;
|
||||||
}
|
}
|
||||||
return getFacingEnum() != direction;
|
return getFacingEnum() != direction;
|
||||||
|
@ -93,7 +93,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
public boolean canProvideEnergy(Direction direction) {
|
||||||
if (TechRebornConfig.IC2TransformersStyle){
|
if (TechRebornConfig.IC2TransformersStyle) {
|
||||||
return getFacingEnum() != direction;
|
return getFacingEnum() != direction;
|
||||||
}
|
}
|
||||||
return getFacing() == direction;
|
return getFacing() == direction;
|
||||||
|
@ -122,7 +122,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
// TileMachineBase
|
// TileMachineBase
|
||||||
@Override
|
@Override
|
||||||
public Direction getFacingEnum() {
|
public Direction getFacingEnum() {
|
||||||
if(world == null){
|
if (world == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Block block = world.getBlockState(pos).getBlock();
|
Block block = world.getBlockState(pos).getBlock();
|
||||||
|
|
|
@ -30,13 +30,12 @@ import techreborn.client.GuiType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author modmuss50
|
* @author modmuss50
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class DataDrivenMachineBlock extends GenericMachineBlock {
|
public class DataDrivenMachineBlock extends GenericMachineBlock {
|
||||||
|
|
||||||
private final DataDrivenBEProvider provider;
|
private final DataDrivenBEProvider provider;
|
||||||
|
|
||||||
public DataDrivenMachineBlock(String ident){
|
public DataDrivenMachineBlock(String ident) {
|
||||||
super(GuiType.DATA_DRIVEN, null);
|
super(GuiType.DATA_DRIVEN, null);
|
||||||
provider = DataDrivenBEProvider.create(this, new Identifier(ident));
|
provider = DataDrivenBEProvider.create(this, new Identifier(ident));
|
||||||
blockEntityClass = provider;
|
blockEntityClass = provider;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -52,12 +52,12 @@ public final class CableShapeUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private VoxelShape getStateShape(BlockState state) {
|
private VoxelShape getStateShape(BlockState state) {
|
||||||
final double size = cableBlock.type != null ? cableBlock.type.cableThickness : 6;
|
final double size = cableBlock.type != null ? cableBlock.type.cableThickness : 6;
|
||||||
final VoxelShape baseShape = Block.createCuboidShape(size, size, size, 16.0D - size, 16.0D - size, 16.0D - size);
|
final VoxelShape baseShape = Block.createCuboidShape(size, size, size, 16.0D - size, 16.0D - size, 16.0D - size);
|
||||||
|
|
||||||
final List<VoxelShape> connections = new ArrayList<>();
|
final List<VoxelShape> connections = new ArrayList<>();
|
||||||
for(Direction dir : Direction.values()){
|
for (Direction dir : Direction.values()) {
|
||||||
if(state.get(CableBlock.PROPERTY_MAP.get(dir))) {
|
if (state.get(CableBlock.PROPERTY_MAP.get(dir))) {
|
||||||
double x = dir == Direction.WEST ? 0 : dir == Direction.EAST ? 16D : size;
|
double x = dir == Direction.WEST ? 0 : dir == Direction.EAST ? 16D : size;
|
||||||
double z = dir == Direction.NORTH ? 0 : dir == Direction.SOUTH ? 16D : size;
|
double z = dir == Direction.NORTH ? 0 : dir == Direction.SOUTH ? 16D : size;
|
||||||
double y = dir == Direction.DOWN ? 0 : dir == Direction.UP ? 16D : size;
|
double y = dir == Direction.DOWN ? 0 : dir == Direction.UP ? 16D : size;
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class BlockFusionCoil extends Block {
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void buildTooltip(ItemStack stack, @Nullable BlockView worldIn, List<Text> tooltip,
|
public void buildTooltip(ItemStack stack, @Nullable BlockView worldIn, List<Text> tooltip,
|
||||||
TooltipContext flagIn) {
|
TooltipContext flagIn) {
|
||||||
super.buildTooltip(stack, worldIn, tooltip, flagIn);
|
super.buildTooltip(stack, worldIn, tooltip, flagIn);
|
||||||
// TODO: Translate
|
// TODO: Translate
|
||||||
tooltip.add(new LiteralText("Right click Fusion Control computer to auto place"));
|
tooltip.add(new LiteralText("Right click Fusion Control computer to auto place"));
|
||||||
|
|
|
@ -52,23 +52,23 @@ public class BlockFusionControlComputer extends BlockMachineBase {
|
||||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
|
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
|
||||||
Hand hand, BlockHitResult hitResult) {
|
Hand hand, BlockHitResult hitResult) {
|
||||||
final FusionControlComputerBlockEntity blockEntityFusionControlComputer = (FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos);
|
final FusionControlComputerBlockEntity blockEntityFusionControlComputer = (FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos);
|
||||||
if(!playerIn.getStackInHand(hand).isEmpty() && (playerIn.getStackInHand(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())){
|
if (!playerIn.getStackInHand(hand).isEmpty() && (playerIn.getStackInHand(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())) {
|
||||||
List<BlockPos> coils = Torus.generate(blockEntityFusionControlComputer.getPos(), blockEntityFusionControlComputer.size);
|
List<BlockPos> coils = Torus.generate(blockEntityFusionControlComputer.getPos(), blockEntityFusionControlComputer.size);
|
||||||
boolean placed = false;
|
boolean placed = false;
|
||||||
for(BlockPos coil : coils){
|
for (BlockPos coil : coils) {
|
||||||
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)))
|
if (worldIn.getBlockState(coil).canReplace(new ItemPlacementContext(new ItemUsageContext(playerIn, hand, hitResult)))
|
||||||
&& worldIn.getBlockState(pos).getBlock() != TRContent.Machine.FUSION_COIL.block) {
|
&& 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);
|
||||||
}
|
}
|
||||||
placed = true;
|
placed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(placed){
|
if (placed) {
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class BlockSolarPanel extends BlockMachineBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMachineGuiHandler getGui() {
|
public IMachineGuiHandler getGui() {
|
||||||
if(this.panelType == SolarPanels.CREATIVE){
|
if (this.panelType == SolarPanels.CREATIVE) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return GuiType.SOLAR_PANEL;
|
return GuiType.SOLAR_PANEL;
|
||||||
|
|
|
@ -39,17 +39,17 @@ import java.util.function.Supplier;
|
||||||
* for generators, like comparator output based on energy.
|
* for generators, like comparator output based on energy.
|
||||||
*/
|
*/
|
||||||
public class GenericGeneratorBlock extends GenericMachineBlock {
|
public class GenericGeneratorBlock extends GenericMachineBlock {
|
||||||
public GenericGeneratorBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
|
public GenericGeneratorBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
|
||||||
super(gui, blockEntityClass);
|
super(gui, blockEntityClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasComparatorOutput(BlockState state) {
|
public boolean hasComparatorOutput(BlockState state) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||||
return PowerAcceptorBlockEntity.calculateComparatorOutputFromEnergy(world.getBlockEntity(pos));
|
return PowerAcceptorBlockEntity.calculateComparatorOutputFromEnergy(world.getBlockEntity(pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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));
|
||||||
|
@ -68,7 +68,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private VoxelShape[] genCuboidShapes(double depth, double width) {
|
private VoxelShape[] genCuboidShapes(double depth, double width) {
|
||||||
double culling = (16.0D - width) / 2 ;
|
double culling = (16.0D - width) / 2;
|
||||||
return new VoxelShape[]{
|
return new VoxelShape[]{
|
||||||
createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
|
createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
|
||||||
createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
|
createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
|
||||||
|
@ -76,7 +76,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
|
||||||
createCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
|
createCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
|
||||||
createCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
|
createCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
|
||||||
createCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
|
createCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
|
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
|
||||||
ItemStack stack) {
|
ItemStack stack) {
|
||||||
super.onPlaced(worldIn, pos, state, placer, stack);
|
super.onPlaced(worldIn, pos, state, placer, stack);
|
||||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||||
if (blockEntity instanceof PlayerDectectorBlockEntity) {
|
if (blockEntity instanceof PlayerDectectorBlockEntity) {
|
||||||
|
@ -126,12 +126,12 @@ public class BlockPlayerDetector extends BlockMachineBase {
|
||||||
if (worldIn.isClient) {
|
if (worldIn.isClient) {
|
||||||
ChatUtils.sendNoSpamMessages(MessageIDs.playerDetectorID,
|
ChatUtils.sendNoSpamMessages(MessageIDs.playerDetectorID,
|
||||||
new TranslatableText("techreborn.message.detects")
|
new TranslatableText("techreborn.message.detects")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(
|
.append(
|
||||||
new LiteralText(StringUtils.toFirstCapital(newType.asString()))
|
new LiteralText(StringUtils.toFirstCapital(newType.asString()))
|
||||||
.formatted(color)
|
.formatted(color)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockAlarm extends BaseBlockEntityProvider {
|
public class BlockAlarm extends BaseBlockEntityProvider {
|
||||||
public static DirectionProperty FACING = Properties.FACING;
|
public static DirectionProperty FACING = Properties.FACING;
|
||||||
public static BooleanProperty ACTIVE;
|
public static BooleanProperty ACTIVE;
|
||||||
protected final VoxelShape[] shape;
|
protected final VoxelShape[] shape;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class BlockAlarm extends BaseBlockEntityProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private VoxelShape[] GenCuboidShapes(double depth, double width) {
|
private VoxelShape[] GenCuboidShapes(double depth, double width) {
|
||||||
double culling = (16.0D - width) / 2 ;
|
double culling = (16.0D - width) / 2;
|
||||||
VoxelShape[] shapes = {
|
VoxelShape[] shapes = {
|
||||||
Block.createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
|
Block.createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
|
||||||
Block.createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
|
Block.createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,8 @@ 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.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraft.item.BucketItem;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
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;
|
||||||
|
@ -41,12 +39,10 @@ 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.FluidValue;
|
||||||
import reborncore.common.fluid.RebornBucketItem;
|
|
||||||
import reborncore.common.fluid.container.FluidInstance;
|
import reborncore.common.fluid.container.FluidInstance;
|
||||||
import reborncore.common.fluid.container.ItemFluidInfo;
|
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
|
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
|
||||||
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
|
|
||||||
import techreborn.client.GuiType;
|
import techreborn.client.GuiType;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
@ -76,17 +72,17 @@ public class TankUnitBlock extends BlockMachineBase {
|
||||||
|
|
||||||
// Assuming ItemFluidInfo is 1 BUCKET, for now only allow exact amount or less
|
// Assuming ItemFluidInfo is 1 BUCKET, for now only allow exact amount or less
|
||||||
if (tankUnitEntity != null && itemInHand instanceof ItemFluidInfo) {
|
if (tankUnitEntity != null && itemInHand instanceof ItemFluidInfo) {
|
||||||
ItemFluidInfo itemFluid = (ItemFluidInfo)itemInHand;
|
ItemFluidInfo itemFluid = (ItemFluidInfo) itemInHand;
|
||||||
Fluid fluid = itemFluid.getFluid(stackInHand);
|
Fluid fluid = itemFluid.getFluid(stackInHand);
|
||||||
int amount = stackInHand.getCount();
|
int amount = stackInHand.getCount();
|
||||||
|
|
||||||
FluidValue fluidValue = FluidValue.BUCKET.multiply(amount);
|
FluidValue fluidValue = FluidValue.BUCKET.multiply(amount);
|
||||||
Tank tankInstance = tankUnitEntity.getTank();
|
Tank tankInstance = tankUnitEntity.getTank();
|
||||||
|
|
||||||
if(tankInstance.canFit(fluid, fluidValue)){
|
if (tankInstance.canFit(fluid, fluidValue)) {
|
||||||
if(tankInstance.getFluidInstance().isEmptyFluid()){
|
if (tankInstance.getFluidInstance().isEmptyFluid()) {
|
||||||
tankInstance.setFluidInstance(new FluidInstance(fluid, fluidValue));
|
tankInstance.setFluidInstance(new FluidInstance(fluid, fluidValue));
|
||||||
}else{
|
} else {
|
||||||
tankInstance.getFluidInstance().addAmount(fluidValue);
|
tankInstance.getFluidInstance().addAmount(fluidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
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.api.items.InventoryBase;
|
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import reborncore.common.util.WorldUtils;
|
import reborncore.common.util.WorldUtils;
|
||||||
|
@ -90,7 +89,7 @@ public class StorageUnitBlock extends BlockMachineBase {
|
||||||
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
|
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
|
||||||
super.onBlockBreakStart(state, world, pos, player);
|
super.onBlockBreakStart(state, world, pos, player);
|
||||||
|
|
||||||
if(world.isClient) return;
|
if (world.isClient) return;
|
||||||
|
|
||||||
final StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) world.getBlockEntity(pos);
|
final StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) world.getBlockEntity(pos);
|
||||||
ItemStack stackInHand = player.getStackInHand(Hand.MAIN_HAND);
|
ItemStack stackInHand = player.getStackInHand(Hand.MAIN_HAND);
|
||||||
|
@ -100,10 +99,10 @@ public class StorageUnitBlock extends BlockMachineBase {
|
||||||
ItemStack out = inventory.getStack(StorageUnitBaseBlockEntity.OUTPUT_SLOT);
|
ItemStack out = inventory.getStack(StorageUnitBaseBlockEntity.OUTPUT_SLOT);
|
||||||
|
|
||||||
// Drop stack if sneaking
|
// Drop stack if sneaking
|
||||||
if(player.isSneaking()){
|
if (player.isSneaking()) {
|
||||||
WorldUtils.dropItem(new ItemStack(out.getItem()), world, player.getBlockPos());
|
WorldUtils.dropItem(new ItemStack(out.getItem()), world, player.getBlockPos());
|
||||||
out.decrement(1);
|
out.decrement(1);
|
||||||
}else {
|
} else {
|
||||||
WorldUtils.dropItem(out, world, player.getBlockPos());
|
WorldUtils.dropItem(out, world, player.getBlockPos());
|
||||||
out.setCount(0);
|
out.setCount(0);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +113,6 @@ public class StorageUnitBlock extends BlockMachineBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMachineGuiHandler getGui() {
|
public IMachineGuiHandler getGui() {
|
||||||
return GuiType.STORAGE_UNIT;
|
return GuiType.STORAGE_UNIT;
|
||||||
|
|
|
@ -72,7 +72,7 @@ public abstract class BlockTransformer extends BaseBlockEntityProvider {
|
||||||
// BaseTileBlock
|
// BaseTileBlock
|
||||||
@Override
|
@Override
|
||||||
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
|
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
|
||||||
ItemStack stack) {
|
ItemStack stack) {
|
||||||
super.onPlaced(worldIn, pos, state, placer, stack);
|
super.onPlaced(worldIn, pos, state, placer, stack);
|
||||||
Direction facing = placer.getHorizontalFacing().getOpposite();
|
Direction facing = placer.getHorizontalFacing().getOpposite();
|
||||||
if (placer.pitch < -50) {
|
if (placer.pitch < -50) {
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -172,7 +171,7 @@ public final class GuiType<T extends BlockEntity> implements IMachineGuiHandler
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void open(PlayerEntity player, BlockPos pos, World world) {
|
public void open(PlayerEntity player, BlockPos pos, World world) {
|
||||||
if(!world.isClient){
|
if (!world.isClient) {
|
||||||
//This is awful
|
//This is awful
|
||||||
player.openHandledScreen(new ExtendedScreenHandlerFactory() {
|
player.openHandledScreen(new ExtendedScreenHandlerFactory() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class GuiAESU extends GuiBase<BuiltScreenHandler> {
|
||||||
super.drawForeground(matrixStack, mouseX, mouseY);
|
super.drawForeground(matrixStack, mouseX, mouseY);
|
||||||
final Layer layer = Layer.FOREGROUND;
|
final Layer layer = Layer.FOREGROUND;
|
||||||
|
|
||||||
if(!hideGuiElements()){
|
if (!hideGuiElements()) {
|
||||||
RenderSystem.pushMatrix();
|
RenderSystem.pushMatrix();
|
||||||
RenderSystem.scaled(0.6, 0.6, 1);
|
RenderSystem.scaled(0.6, 0.6, 1);
|
||||||
Text text = new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) blockEntity.getEnergy()))
|
Text text = new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) blockEntity.getEnergy()))
|
||||||
|
@ -89,7 +89,7 @@ public class GuiAESU extends GuiBase<BuiltScreenHandler> {
|
||||||
builder.drawMultiEnergyBar(matrixStack, this, 81, 28, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
builder.drawMultiEnergyBar(matrixStack, this, 81, 28, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(int amount){
|
public void onClick(int amount) {
|
||||||
NetworkManager.sendToServer(ServerboundPackets.createPacketAesu(amount, Screen.hasShiftDown(), Screen.hasControlDown(), blockEntity));
|
NetworkManager.sendToServer(ServerboundPackets.createPacketAesu(amount, Screen.hasShiftDown(), Screen.hasControlDown(), blockEntity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class GuiBatbox extends GuiBase<BuiltScreenHandler> {
|
||||||
super.drawForeground(matrixStack, mouseX, mouseY);
|
super.drawForeground(matrixStack, mouseX, mouseY);
|
||||||
final Layer layer = Layer.FOREGROUND;
|
final Layer layer = Layer.FOREGROUND;
|
||||||
|
|
||||||
if(!hideGuiElements()){
|
if (!hideGuiElements()) {
|
||||||
RenderSystem.pushMatrix();
|
RenderSystem.pushMatrix();
|
||||||
RenderSystem.scaled(0.6, 0.6, 5);
|
RenderSystem.scaled(0.6, 0.6, 5);
|
||||||
Text text = new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) blockEntity.getEnergy()))
|
Text text = new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) blockEntity.getEnergy()))
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class GuiChunkLoader extends GuiBase<BuiltScreenHandler> {
|
||||||
drawCentredText(matrixStack, text, 25, 4210752, layer);
|
drawCentredText(matrixStack, text, 25, 4210752, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(int amount){
|
public void onClick(int amount) {
|
||||||
NetworkManager.sendToServer(ServerboundPackets.createPacketChunkloader(amount, blockEntity, ClientChunkManager.hasChunksForLoader(blockEntity.getPos())));
|
NetworkManager.sendToServer(ServerboundPackets.createPacketChunkloader(amount, blockEntity, ClientChunkManager.hasChunksForLoader(blockEntity.getPos())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class GuiDistillationTower extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(GuiButtonExtended button, Double x, Double y){
|
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
||||||
blockEntity.renderMultiblock ^= !hideGuiElements();
|
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,11 +49,11 @@ public class GuiIronFurnace extends GuiBase<BuiltScreenHandler> {
|
||||||
IronFurnaceBlockEntity blockEntity;
|
IronFurnaceBlockEntity blockEntity;
|
||||||
|
|
||||||
public GuiIronFurnace(int syncID, PlayerEntity player, IronFurnaceBlockEntity furnace) {
|
public GuiIronFurnace(int syncID, PlayerEntity player, IronFurnaceBlockEntity furnace) {
|
||||||
super(player, furnace, furnace.createScreenHandler(syncID, player));
|
super(player, furnace, furnace.createScreenHandler(syncID, player));
|
||||||
this.blockEntity = furnace;
|
this.blockEntity = furnace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(){
|
public void onClick() {
|
||||||
NetworkManager.sendToServer(ServerboundPackets.createPacketExperience(blockEntity));
|
NetworkManager.sendToServer(ServerboundPackets.createPacketExperience(blockEntity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,15 +57,15 @@ public class GuiMFE extends GuiBase<BuiltScreenHandler> {
|
||||||
super.drawForeground(matrixStack, mouseX, mouseY);
|
super.drawForeground(matrixStack, mouseX, mouseY);
|
||||||
final Layer layer = Layer.FOREGROUND;
|
final Layer layer = Layer.FOREGROUND;
|
||||||
|
|
||||||
if(!hideGuiElements()){
|
if (!hideGuiElements()) {
|
||||||
RenderSystem.pushMatrix();
|
RenderSystem.pushMatrix();
|
||||||
RenderSystem.scaled(0.6, 0.6, 1);
|
RenderSystem.scaled(0.6, 0.6, 1);
|
||||||
|
|
||||||
drawCentredText(matrixStack, new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfe.getEnergy()))
|
drawCentredText(matrixStack, new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfe.getEnergy()))
|
||||||
.append("/")
|
.append("/")
|
||||||
.append(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfe.getMaxPower()))
|
.append(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfe.getMaxPower()))
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(PowerSystem.getDisplayPower().abbreviation)
|
.append(PowerSystem.getDisplayPower().abbreviation)
|
||||||
, 35, 0, 58, layer);
|
, 35, 0, 58, layer);
|
||||||
|
|
||||||
RenderSystem.popMatrix();
|
RenderSystem.popMatrix();
|
||||||
|
|
|
@ -59,9 +59,9 @@ public class GuiManual extends Screen {
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
int y = (height / 2) - guiHeight / 2;
|
int y = (height / 2) - guiHeight / 2;
|
||||||
y+= 40;
|
y += 40;
|
||||||
addButton(new GuiButtonExtended((width / 2 - 30), y + 10, 60, 20, new TranslatableText("techreborn.manual.wikibtn"), var1 -> client.openScreen(new ConfirmChatLinkScreen(t -> {
|
addButton(new GuiButtonExtended((width / 2 - 30), y + 10, 60, 20, new TranslatableText("techreborn.manual.wikibtn"), var1 -> client.openScreen(new ConfirmChatLinkScreen(t -> {
|
||||||
if(t){
|
if (t) {
|
||||||
Util.getOperatingSystem().open("http://wiki.techreborn.ovh");
|
Util.getOperatingSystem().open("http://wiki.techreborn.ovh");
|
||||||
this.client.openScreen(this);
|
this.client.openScreen(this);
|
||||||
} else {
|
} else {
|
||||||
|
@ -69,14 +69,14 @@ public class GuiManual extends Screen {
|
||||||
}
|
}
|
||||||
}, "http://wiki.techreborn.ovh", false))));
|
}, "http://wiki.techreborn.ovh", false))));
|
||||||
addButton(new GuiButtonExtended((width / 2 - 30), y + 60, 60, 20, new TranslatableText("techreborn.manual.discordbtn"), var1 -> client.openScreen(new ConfirmChatLinkScreen(t -> {
|
addButton(new GuiButtonExtended((width / 2 - 30), y + 60, 60, 20, new TranslatableText("techreborn.manual.discordbtn"), var1 -> client.openScreen(new ConfirmChatLinkScreen(t -> {
|
||||||
if(t){
|
if (t) {
|
||||||
Util.getOperatingSystem().open("https://discord.gg/teamreborn");
|
Util.getOperatingSystem().open("https://discord.gg/teamreborn");
|
||||||
this.client.openScreen(this);
|
this.client.openScreen(this);
|
||||||
}else {
|
} else {
|
||||||
this.client.openScreen(this);
|
this.client.openScreen(this);
|
||||||
}
|
}
|
||||||
}, "https://discord.gg/teamreborn", false))));
|
}, "https://discord.gg/teamreborn", false))));
|
||||||
if(TechRebornConfig.allowManualRefund){
|
if (TechRebornConfig.allowManualRefund) {
|
||||||
addButton(new GuiButtonExtended((width / 2 - 30), y + 110, 60, 20, new TranslatableText("techreborn.manual.refundbtn"), var1 -> {
|
addButton(new GuiButtonExtended((width / 2 - 30), y + 110, 60, 20, new TranslatableText("techreborn.manual.refundbtn"), var1 -> {
|
||||||
NetworkManager.sendToServer(ServerboundPackets.createRefundPacket());
|
NetworkManager.sendToServer(ServerboundPackets.createRefundPacket());
|
||||||
this.client.openScreen(null);
|
this.client.openScreen(null);
|
||||||
|
|
|
@ -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> {
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class GuiRollingMachine extends GuiBase<BuiltScreenHandler> {
|
||||||
RollingMachineBlockEntity rollingMachine;
|
RollingMachineBlockEntity rollingMachine;
|
||||||
|
|
||||||
public GuiRollingMachine(int syncID, final PlayerEntity player, final RollingMachineBlockEntity blockEntityRollingmachine) {
|
public GuiRollingMachine(int syncID, final PlayerEntity player, final RollingMachineBlockEntity blockEntityRollingmachine) {
|
||||||
super(player, blockEntityRollingmachine, blockEntityRollingmachine.createScreenHandler(syncID, player));
|
super(player, blockEntityRollingmachine, blockEntityRollingmachine.createScreenHandler(syncID, player));
|
||||||
this.rollingMachine = blockEntityRollingmachine;
|
this.rollingMachine = blockEntityRollingmachine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class GuiRollingMachine extends GuiBase<BuiltScreenHandler> {
|
||||||
drawOutputSlot(matrixStack, 124, gridYPos + 18, layer);
|
drawOutputSlot(matrixStack, 124, gridYPos + 18, layer);
|
||||||
|
|
||||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||||
builder.drawLockButton(matrixStack, this, 130, 4, mouseX, mouseY, layer,rollingMachine.locked);
|
builder.drawLockButton(matrixStack, this, 130, 4, mouseX, mouseY, layer, rollingMachine.locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,7 +76,7 @@ public class GuiRollingMachine extends GuiBase<BuiltScreenHandler> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||||
if(isPointInRect(130, 4, 20, 12, mouseX, mouseY)){
|
if (isPointInRect(130, 4, 20, 12, mouseX, mouseY)) {
|
||||||
NetworkManager.sendToServer(ServerboundPackets.createPacketRollingMachineLock(rollingMachine, !rollingMachine.locked));
|
NetworkManager.sendToServer(ServerboundPackets.createPacketRollingMachineLock(rollingMachine, !rollingMachine.locked));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
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