Initial migration to V2 Energy API (#2474)
* Initial Energy API refactor * Allow charging in energy storage BEs * Remove maven for experimental fabric Co-authored-by: modmuss50 <modmuss50@gmail.com>
This commit is contained in:
parent
2bc4886cc0
commit
3e2b0e11ae
75 changed files with 764 additions and 694 deletions
|
@ -46,11 +46,12 @@ import reborncore.common.misc.ModSounds;
|
||||||
import reborncore.common.misc.RebornCoreTags;
|
import reborncore.common.misc.RebornCoreTags;
|
||||||
import reborncore.common.multiblock.MultiblockRegistry;
|
import reborncore.common.multiblock.MultiblockRegistry;
|
||||||
import reborncore.common.network.ServerBoundPackets;
|
import reborncore.common.network.ServerBoundPackets;
|
||||||
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.recipes.PaddedShapedRecipe;
|
import reborncore.common.recipes.PaddedShapedRecipe;
|
||||||
import reborncore.common.util.CalenderUtils;
|
import reborncore.common.util.CalenderUtils;
|
||||||
import reborncore.common.util.GenericWrenchHelper;
|
import reborncore.common.util.GenericWrenchHelper;
|
||||||
import reborncore.common.util.Tank;
|
import team.reborn.energy.api.EnergyStorage;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
@ -124,6 +125,12 @@ public class RebornCore implements ModInitializer {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
EnergyStorage.SIDED.registerFallback((world, pos, state, be, direction) -> {
|
||||||
|
if (be instanceof PowerAcceptorBlockEntity powerAcceptor) {
|
||||||
|
return powerAcceptor.getSideEnergyStorage(direction);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
LOGGER.info("Reborn core is done for now, now to let other mods have their turn...");
|
LOGGER.info("Reborn core is done for now, now to let other mods have their turn...");
|
||||||
LOADED = true;
|
LOADED = true;
|
||||||
|
|
|
@ -43,10 +43,8 @@ import reborncore.RebornCore;
|
||||||
import reborncore.api.IListInfoProvider;
|
import reborncore.api.IListInfoProvider;
|
||||||
import reborncore.common.BaseBlockEntityProvider;
|
import reborncore.common.BaseBlockEntityProvider;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.util.StringUtils;
|
import reborncore.common.util.StringUtils;
|
||||||
import team.reborn.energy.Energy;
|
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -60,24 +58,24 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
||||||
if (item instanceof IListInfoProvider) {
|
if (item instanceof IListInfoProvider) {
|
||||||
((IListInfoProvider) item).addInfo(tooltipLines, false, false);
|
((IListInfoProvider) item).addInfo(tooltipLines, false, false);
|
||||||
}
|
}
|
||||||
else if (item instanceof EnergyHolder) {
|
else if (item instanceof RcEnergyItem energyItem) {
|
||||||
LiteralText line1 = new LiteralText(PowerSystem.getLocalizedPowerNoSuffix(Energy.of(itemStack).getEnergy()));
|
LiteralText line1 = new LiteralText(PowerSystem.getLocalizedPowerNoSuffix(energyItem.getStoredEnergy(itemStack)));
|
||||||
line1.append("/");
|
line1.append("/");
|
||||||
line1.append(PowerSystem.getLocalizedPower(Energy.of(itemStack).getMaxStored()));
|
line1.append(PowerSystem.getLocalizedPower(energyItem.getEnergyCapacity()));
|
||||||
line1.formatted(Formatting.GOLD);
|
line1.formatted(Formatting.GOLD);
|
||||||
|
|
||||||
tooltipLines.add(1, line1);
|
tooltipLines.add(1, line1);
|
||||||
|
|
||||||
if (Screen.hasShiftDown()) {
|
if (Screen.hasShiftDown()) {
|
||||||
int percentage = percentage(Energy.of(itemStack).getEnergy(), Energy.of(itemStack).getMaxStored());
|
int percentage = percentage(energyItem.getStoredEnergy(itemStack), energyItem.getEnergyCapacity());
|
||||||
MutableText line2 = StringUtils.getPercentageText(percentage);
|
MutableText line2 = StringUtils.getPercentageText(percentage);
|
||||||
line2.append(" ");
|
line2.append(" ");
|
||||||
line2.formatted(Formatting.GRAY);
|
line2.formatted(Formatting.GRAY);
|
||||||
line2.append(I18n.translate("reborncore.gui.tooltip.power_charged"));
|
line2.append(I18n.translate("reborncore.gui.tooltip.power_charged"));
|
||||||
tooltipLines.add(2, line2);
|
tooltipLines.add(2, line2);
|
||||||
|
|
||||||
double inputRate = ((EnergyHolder) item).getMaxInput(EnergySide.UNKNOWN);
|
double inputRate = energyItem.getEnergyMaxInput();
|
||||||
double outputRate = ((EnergyHolder) item).getMaxOutput(EnergySide.UNKNOWN);
|
double outputRate = energyItem.getEnergyMaxOutput();
|
||||||
LiteralText line3 = new LiteralText("");
|
LiteralText line3 = new LiteralText("");
|
||||||
if (inputRate != 0 && inputRate == outputRate){
|
if (inputRate != 0 && inputRate == outputRate){
|
||||||
line3.append(I18n.translate("techreborn.tooltip.transferRate"));
|
line3.append(I18n.translate("techreborn.tooltip.transferRate"));
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of RebornCore, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021 TeamReborn
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package reborncore.client.gui.slots;
|
|
||||||
|
|
||||||
import net.minecraft.inventory.Inventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import team.reborn.energy.Energy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rushmead
|
|
||||||
*/
|
|
||||||
public class SlotCharge extends BaseSlot {
|
|
||||||
public SlotCharge(Inventory inventoryIn, int index, int xPosition, int yPosition) {
|
|
||||||
super(inventoryIn, index, xPosition, yPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInsert(ItemStack stack) {
|
|
||||||
return Energy.valid(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canWorldBlockRemove() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,6 +26,9 @@ package reborncore.client.screen.builder;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.DataResult;
|
import com.mojang.serialization.DataResult;
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.item.base.SingleStackStorage;
|
||||||
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.inventory.CraftingInventory;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
|
@ -48,7 +51,7 @@ import reborncore.client.screen.builder.slot.UpgradeSlot;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.fluid.container.ItemFluidInfo;
|
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import team.reborn.energy.Energy;
|
import team.reborn.energy.api.EnergyStorageUtil;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
@ -106,7 +109,7 @@ public class BlockEntityScreenHandlerBuilder {
|
||||||
|
|
||||||
public BlockEntityScreenHandlerBuilder energySlot(final int index, final int x, final int y) {
|
public BlockEntityScreenHandlerBuilder energySlot(final int index, final int x, final int y) {
|
||||||
this.parent.slots.add(new FilteredSlot(this.inventory, index, x, y)
|
this.parent.slots.add(new FilteredSlot(this.inventory, index, x, y)
|
||||||
.setFilter(Energy::valid));
|
.setFilter(EnergyStorageUtil::isEnergyStorage));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import reborncore.client.gui.slots.BaseSlot;
|
import reborncore.client.gui.slots.BaseSlot;
|
||||||
|
|
||||||
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class FilteredSlot extends BaseSlot {
|
public class FilteredSlot extends BaseSlot {
|
||||||
|
|
|
@ -327,8 +327,8 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getEuPerTick(double baseEu) {
|
public long getEuPerTick(long baseEu) {
|
||||||
return baseEu * powerMultiplier;
|
return (long) (baseEu * powerMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,9 +24,14 @@
|
||||||
|
|
||||||
package reborncore.common.powerSystem;
|
package reborncore.common.powerSystem;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.item.InventoryStorage;
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
@ -41,23 +46,37 @@ import reborncore.api.IListInfoProvider;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.blockentity.RedstoneConfiguration;
|
import reborncore.common.blockentity.RedstoneConfiguration;
|
||||||
import reborncore.common.util.StringUtils;
|
import reborncore.common.util.StringUtils;
|
||||||
import team.reborn.energy.Energy;
|
import team.reborn.energy.api.EnergyStorage;
|
||||||
import team.reborn.energy.EnergySide;
|
import team.reborn.energy.api.EnergyStorageUtil;
|
||||||
import team.reborn.energy.EnergyStorage;
|
import team.reborn.energy.api.base.SimpleSidedEnergyContainer;
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity implements EnergyStorage, IListInfoProvider // TechReborn
|
public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity implements IListInfoProvider {
|
||||||
{
|
public final SimpleSidedEnergyContainer energyContainer = new SimpleSidedEnergyContainer() {
|
||||||
private EnergyTier blockEntityPowerTier;
|
@Override
|
||||||
private double energy;
|
public long getCapacity() {
|
||||||
|
return PowerAcceptorBlockEntity.this.getMaxStoredPower();
|
||||||
|
}
|
||||||
|
|
||||||
public double extraPowerStorage;
|
@Override
|
||||||
public double extraPowerInput;
|
public long getMaxInsert(@Nullable Direction side) {
|
||||||
|
return PowerAcceptorBlockEntity.this.getMaxInput(side);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getMaxExtract(@Nullable Direction side) {
|
||||||
|
return PowerAcceptorBlockEntity.this.getMaxOutput(side);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private RcEnergyTier blockEntityPowerTier;
|
||||||
|
|
||||||
|
public long extraPowerStorage;
|
||||||
|
public long extraPowerInput;
|
||||||
public int extraTier;
|
public int extraTier;
|
||||||
public double powerChange;
|
public long powerChange;
|
||||||
public double powerLastTick;
|
public long powerLastTick;
|
||||||
public boolean checkOverfill = true; // Set to false to disable the overfill check.
|
public boolean checkOverfill = true; // Set to false to disable the overfill check.
|
||||||
|
|
||||||
public PowerAcceptorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
public PowerAcceptorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||||
|
@ -65,22 +84,16 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
checkTier();
|
checkTier();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkTier() {
|
public EnergyStorage getSideEnergyStorage(@Nullable Direction side) {
|
||||||
if (this.getMaxInput(EnergySide.UNKNOWN) == 0) {
|
return energyContainer.getSideStorage(side);
|
||||||
blockEntityPowerTier = getTier((int) this.getBaseMaxOutput());
|
|
||||||
} else {
|
|
||||||
blockEntityPowerTier = getTier((int) this.getBaseMaxInput());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TO-DO: Move to Energy API probably. Cables use this method.
|
public void checkTier() {
|
||||||
public static EnergyTier getTier(int power) {
|
if (this.getMaxInput(null) == 0) {
|
||||||
for (EnergyTier tier : EnergyTier.values()) {
|
blockEntityPowerTier = RcEnergyTier.getTier(this.getBaseMaxOutput());
|
||||||
if (tier.getMaxInput() >= power) {
|
} else {
|
||||||
return tier;
|
blockEntityPowerTier = RcEnergyTier.getTier(this.getBaseMaxInput());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return EnergyTier.INFINITE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,8 +101,8 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
*
|
*
|
||||||
* @return double Free space for energy in internal buffer
|
* @return double Free space for energy in internal buffer
|
||||||
*/
|
*/
|
||||||
public double getFreeSpace() {
|
public long getFreeSpace() {
|
||||||
return getMaxStoredPower() - getStored(EnergySide.UNKNOWN);
|
return getMaxStoredPower() - getStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,8 +110,18 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
*
|
*
|
||||||
* @param amount double Amount to add
|
* @param amount double Amount to add
|
||||||
*/
|
*/
|
||||||
public void addEnergy(double amount){
|
public void addEnergy(long amount){
|
||||||
setStored(energy + amount);
|
setStored(getEnergy() + amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEnergyProbabilistic(double amount) {
|
||||||
|
long integerPart = (long) Math.floor(amount);
|
||||||
|
addEnergy(integerPart);
|
||||||
|
|
||||||
|
double fractionalPart = amount - integerPart;
|
||||||
|
if (ThreadLocalRandom.current().nextDouble() <= fractionalPart) {
|
||||||
|
addEnergy(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,9 +129,9 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
*
|
*
|
||||||
* @param amount double Amount of energy to use
|
* @param amount double Amount of energy to use
|
||||||
*/
|
*/
|
||||||
public void useEnergy(double amount){
|
public void useEnergy(long amount){
|
||||||
if (energy > amount) {
|
if (getEnergy() > amount) {
|
||||||
setStored(energy - amount);
|
setStored(getEnergy() - amount);
|
||||||
} else {
|
} else {
|
||||||
setStored(0);
|
setStored(0);
|
||||||
}
|
}
|
||||||
|
@ -127,21 +150,21 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double chargeEnergy = Math.min(getFreeSpace(), getMaxInput(EnergySide.UNKNOWN));
|
long chargeEnergy = Math.min(getFreeSpace(), getMaxInput(null));
|
||||||
if (chargeEnergy <= 0.0) {
|
if (chargeEnergy <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!getOptionalInventory().isPresent()) {
|
if (getOptionalInventory().isEmpty()) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
ItemStack batteryStack = getOptionalInventory().get().getStack(slot);
|
|
||||||
if (batteryStack.isEmpty()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Inventory inventory = getOptionalInventory().get();
|
||||||
|
|
||||||
if (Energy.valid(batteryStack)) {
|
EnergyStorageUtil.move(
|
||||||
Energy.of(batteryStack).into(Energy.of(this)).move();
|
ContainerItemContext.ofSingleSlot(InventoryStorage.of(inventory, null).getSlots().get(slot)).find(EnergyStorage.ITEM),
|
||||||
}
|
energyContainer.getSideStorage(null),
|
||||||
|
Long.MAX_VALUE,
|
||||||
|
null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,30 +181,30 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getOptionalInventory().isPresent()){
|
if (getOptionalInventory().isEmpty()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack batteryStack = getOptionalInventory().get().getStack(slot);
|
Inventory inventory = getOptionalInventory().get();
|
||||||
if (batteryStack.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Energy.valid(batteryStack)) {
|
EnergyStorageUtil.move(
|
||||||
Energy.of(this).into(Energy.of(batteryStack)).move(getTier().getMaxOutput());
|
energyContainer.getSideStorage(null),
|
||||||
}
|
ContainerItemContext.ofSingleSlot(InventoryStorage.of(inventory, null).getSlots().get(slot)).find(EnergyStorage.ITEM),
|
||||||
|
Long.MAX_VALUE,
|
||||||
|
null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the comparator output of a powered BE with the formula
|
* Calculates the comparator output of a powered BE with the formula
|
||||||
* {@code ceil(blockEntity.getStored(EnergySide.UNKNOWN) * 15.0 / storage.getMaxPower())}.
|
* {@code ceil(blockEntity.getStored() * 15.0 / storage.getMaxPower())}.
|
||||||
*
|
*
|
||||||
* @param blockEntity the powered BE
|
* @param blockEntity the powered BE
|
||||||
* @return the calculated comparator output or 0 if {@code blockEntity} is not a {@code PowerAcceptorBlockEntity}
|
* @return the calculated comparator output or 0 if {@code blockEntity} is not a {@code PowerAcceptorBlockEntity}
|
||||||
*/
|
*/
|
||||||
public static int calculateComparatorOutputFromEnergy(@Nullable BlockEntity blockEntity) {
|
public static int calculateComparatorOutputFromEnergy(@Nullable BlockEntity blockEntity) {
|
||||||
if (blockEntity instanceof PowerAcceptorBlockEntity storage) {
|
if (blockEntity instanceof PowerAcceptorBlockEntity storage) {
|
||||||
return MathHelper.ceil(storage.getStored(EnergySide.UNKNOWN) * 15.0 / storage.getMaxStoredPower());
|
return MathHelper.ceil(storage.getStored() * 15.0 / storage.getMaxStoredPower());
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +225,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
* @param side EnergySide Machine side
|
* @param side EnergySide Machine side
|
||||||
* @return boolean Returns true if machine can accept energy from side provided
|
* @return boolean Returns true if machine can accept energy from side provided
|
||||||
*/
|
*/
|
||||||
protected boolean canAcceptEnergy(EnergySide side){
|
protected boolean canAcceptEnergy(@Nullable Direction side){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,17 +235,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
* @param side EnergySide Machine side
|
* @param side EnergySide Machine side
|
||||||
* @return boolean Returns true if machine can provide energy via particular side
|
* @return boolean Returns true if machine can provide energy via particular side
|
||||||
*/
|
*/
|
||||||
protected boolean canProvideEnergy(EnergySide side){
|
protected boolean canProvideEnergy(@Nullable Direction side){
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +244,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
*
|
*
|
||||||
* @return double Size of additional energy buffer
|
* @return double Size of additional energy buffer
|
||||||
*/
|
*/
|
||||||
public double getExtraPowerStorage(){
|
public long getExtraPowerStorage(){
|
||||||
return extraPowerStorage;
|
return extraPowerStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +253,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
*
|
*
|
||||||
* @param extraPowerStorage double Size of additional energy buffer
|
* @param extraPowerStorage double Size of additional energy buffer
|
||||||
*/
|
*/
|
||||||
public void setExtraPowerStorage(double extraPowerStorage) {
|
public void setExtraPowerStorage(long extraPowerStorage) {
|
||||||
this.extraPowerStorage = extraPowerStorage;
|
this.extraPowerStorage = extraPowerStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +262,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
*
|
*
|
||||||
* @return double Energy change per tick
|
* @return double Energy change per tick
|
||||||
*/
|
*/
|
||||||
public double getPowerChange() {
|
public long getPowerChange() {
|
||||||
return powerChange;
|
return powerChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +271,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
*
|
*
|
||||||
* @param powerChange double Energy change per tick
|
* @param powerChange double Energy change per tick
|
||||||
*/
|
*/
|
||||||
public void setPowerChange(double powerChange) {
|
public void setPowerChange(long powerChange) {
|
||||||
this.powerChange = powerChange;
|
this.powerChange = powerChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,15 +281,15 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
* @return double Energy stored in block entity
|
* @return double Energy stored in block entity
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public double getEnergy() {
|
public long getEnergy() {
|
||||||
return getStored(EnergySide.UNKNOWN);
|
return getStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper method used to sync energy values with client via BlockEntityScreenHandlerBuilder
|
* Wrapper method used to sync energy values with client via BlockEntityScreenHandlerBuilder
|
||||||
* @param energy double Energy stored in block entity
|
* @param energy double Energy stored in block entity
|
||||||
*/
|
*/
|
||||||
public void setEnergy(double energy) {
|
public void setEnergy(long energy) {
|
||||||
setStored(energy);
|
setStored(energy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,21 +298,21 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
*
|
*
|
||||||
* @return double Size of internal Energy buffer
|
* @return double Size of internal Energy buffer
|
||||||
*/
|
*/
|
||||||
public abstract double getBaseMaxPower();
|
public abstract long getBaseMaxPower();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns base output rate or zero if machine doesn't output energy
|
* Returns base output rate or zero if machine doesn't output energy
|
||||||
*
|
*
|
||||||
* @return double Output rate, E\t
|
* @return double Output rate, E\t
|
||||||
*/
|
*/
|
||||||
public abstract double getBaseMaxOutput();
|
public abstract long getBaseMaxOutput();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns base input rate or zero if machine doesn't accept energy
|
* Returns base input rate or zero if machine doesn't accept energy
|
||||||
*
|
*
|
||||||
* @return double Input rate, E\t
|
* @return double Input rate, E\t
|
||||||
*/
|
*/
|
||||||
public abstract double getBaseMaxInput();
|
public abstract long getBaseMaxInput();
|
||||||
|
|
||||||
// MachineBaseBlockEntity
|
// MachineBaseBlockEntity
|
||||||
@Override
|
@Override
|
||||||
|
@ -308,7 +321,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
if (world == null || world.isClient) {
|
if (world == null || world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (getStored(EnergySide.UNKNOWN) <= 0) {
|
if (getStored() <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isActive(RedstoneConfiguration.POWER_IO)) {
|
if (!isActive(RedstoneConfiguration.POWER_IO)) {
|
||||||
|
@ -316,18 +329,16 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Direction side : Direction.values()) {
|
for (Direction side : Direction.values()) {
|
||||||
BlockEntity blockEntity = world.getBlockEntity(getPos().offset(side));
|
EnergyStorageUtil.move(
|
||||||
if (blockEntity == null || !Energy.valid(blockEntity)) {
|
energyContainer.getSideStorage(side),
|
||||||
continue;
|
EnergyStorage.SIDED.find(world, pos.offset(side), side.getOpposite()),
|
||||||
}
|
Long.MAX_VALUE,
|
||||||
Energy.of(this)
|
null
|
||||||
.side(side)
|
);
|
||||||
.into(Energy.of(blockEntity).side(side.getOpposite()))
|
|
||||||
.move();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
powerChange = getStored(EnergySide.UNKNOWN) - powerLastTick;
|
powerChange = getStored() - powerLastTick;
|
||||||
powerLastTick = getStored(EnergySide.UNKNOWN);
|
powerLastTick = getStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -335,7 +346,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
super.readNbt(tag);
|
super.readNbt(tag);
|
||||||
NbtCompound data = tag.getCompound("PowerAcceptor");
|
NbtCompound data = tag.getCompound("PowerAcceptor");
|
||||||
if (shouldHandleEnergyNBT()) {
|
if (shouldHandleEnergyNBT()) {
|
||||||
this.setStored(data.getDouble("energy"));
|
this.setStored(data.getLong("energy"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +354,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
public NbtCompound writeNbt(NbtCompound tag) {
|
public NbtCompound writeNbt(NbtCompound tag) {
|
||||||
super.writeNbt(tag);
|
super.writeNbt(tag);
|
||||||
NbtCompound data = new NbtCompound();
|
NbtCompound data = new NbtCompound();
|
||||||
data.putDouble("energy", getStored(EnergySide.UNKNOWN));
|
data.putLong("energy", getStored());
|
||||||
tag.put("PowerAcceptor", data);
|
tag.put("PowerAcceptor", data);
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
@ -356,28 +367,23 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
extraPowerInput = 0;
|
extraPowerInput = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnergyStorage
|
public long getStored() {
|
||||||
@Override
|
return energyContainer.amount;
|
||||||
public double getStored(EnergySide face) {
|
|
||||||
return energy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setStored(long amount) {
|
||||||
public void setStored(double amount) {
|
energyContainer.amount = amount;
|
||||||
this.energy = amount;
|
|
||||||
if(checkOverfill){
|
if(checkOverfill){
|
||||||
this.energy = Math.max(Math.min(energy, getMaxStoredPower()), 0);
|
energyContainer.amount = Math.max(Math.min(energyContainer.amount, getMaxStoredPower()), 0);
|
||||||
}
|
}
|
||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public long getMaxStoredPower() {
|
||||||
public double getMaxStoredPower() {
|
|
||||||
return getBaseMaxPower() + extraPowerStorage;
|
return getBaseMaxPower() + extraPowerStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public long getMaxOutput(@Nullable Direction face) {
|
||||||
public double getMaxOutput(EnergySide face) {
|
|
||||||
if (!isActive(RedstoneConfiguration.POWER_IO)) {
|
if (!isActive(RedstoneConfiguration.POWER_IO)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -390,8 +396,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
return getBaseMaxOutput();
|
return getBaseMaxOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public long getMaxInput(@Nullable Direction face) {
|
||||||
public double getMaxInput(EnergySide face) {
|
|
||||||
if (!isActive(RedstoneConfiguration.POWER_IO)) {
|
if (!isActive(RedstoneConfiguration.POWER_IO)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -404,23 +409,31 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
return getBaseMaxInput() + extraPowerInput;
|
return getBaseMaxInput() + extraPowerInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public RcEnergyTier getTier() {
|
||||||
public EnergyTier getTier() {
|
|
||||||
if (blockEntityPowerTier == null) {
|
if (blockEntityPowerTier == null) {
|
||||||
checkTier();
|
checkTier();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extraTier > 0) {
|
if (extraTier > 0) {
|
||||||
for (EnergyTier enumTier : EnergyTier.values()) {
|
for (RcEnergyTier enumTier : RcEnergyTier.values()) {
|
||||||
if (enumTier.ordinal() == blockEntityPowerTier.ordinal() + extraTier) {
|
if (enumTier.ordinal() == blockEntityPowerTier.ordinal() + extraTier) {
|
||||||
return enumTier;
|
return enumTier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EnergyTier.INFINITE;
|
return RcEnergyTier.INFINITE;
|
||||||
}
|
}
|
||||||
return blockEntityPowerTier;
|
return blockEntityPowerTier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean tryUseExact(long energy) {
|
||||||
|
if (getStored() >= energy) {
|
||||||
|
addEnergy(-energy);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// IListInfoProvider
|
// IListInfoProvider
|
||||||
@Override
|
@Override
|
||||||
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
||||||
|
@ -429,7 +442,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
new TranslatableText("reborncore.tooltip.energy")
|
new TranslatableText("reborncore.tooltip.energy")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(": ")
|
.append(": ")
|
||||||
.append(PowerSystem.getLocalizedPower(energy))
|
.append(PowerSystem.getLocalizedPower(getStored()))
|
||||||
.formatted(Formatting.GOLD)
|
.formatted(Formatting.GOLD)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -442,21 +455,21 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
|
||||||
.formatted(Formatting.GOLD)
|
.formatted(Formatting.GOLD)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (getMaxInput(EnergySide.UNKNOWN) != 0) {
|
if (getMaxInput(null) != 0) {
|
||||||
info.add(
|
info.add(
|
||||||
new TranslatableText("reborncore.tooltip.energy.inputRate")
|
new TranslatableText("reborncore.tooltip.energy.inputRate")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(": ")
|
.append(": ")
|
||||||
.append(PowerSystem.getLocalizedPower(getMaxInput(EnergySide.UNKNOWN)))
|
.append(PowerSystem.getLocalizedPower(getMaxInput(null)))
|
||||||
.formatted(Formatting.GOLD)
|
.formatted(Formatting.GOLD)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (getMaxOutput(EnergySide.UNKNOWN) > 0) {
|
if (getMaxOutput(null) > 0) {
|
||||||
info.add(
|
info.add(
|
||||||
new TranslatableText("reborncore.tooltip.energy.outputRate")
|
new TranslatableText("reborncore.tooltip.energy.outputRate")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(": ")
|
.append(": ")
|
||||||
.append(PowerSystem.getLocalizedPower(getMaxOutput(EnergySide.UNKNOWN)))
|
.append(PowerSystem.getLocalizedPower(getMaxOutput(null)))
|
||||||
.formatted(Formatting.GOLD)
|
.formatted(Formatting.GOLD)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package reborncore.common.powerSystem;
|
||||||
|
|
||||||
|
import team.reborn.energy.api.base.SimpleBatteryItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement on simple energy-containing items and (on top of what SimpleBatteryItem does):
|
||||||
|
* <ul>
|
||||||
|
* <li>A tooltip will be added for the item, indicating the stored power, the max power and the extraction rates.</li>
|
||||||
|
* <li>Any RcEnergyItem input in a crafting recipe input will automatically give its energy to the output if the output implements RcEnergyItem.</li>
|
||||||
|
* </ul>
|
||||||
|
* TODO: consider moving this functionality to the energy API?
|
||||||
|
*/
|
||||||
|
public interface RcEnergyItem extends SimpleBatteryItem {
|
||||||
|
long getEnergyCapacity();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the tier of this EnergyStorage, used to have standard I/O rates.
|
||||||
|
*/
|
||||||
|
RcEnergyTier getTier();
|
||||||
|
|
||||||
|
default long getEnergyMaxInput() {
|
||||||
|
return getTier().getMaxInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
default long getEnergyMaxOutput() {
|
||||||
|
return getTier().getMaxOutput();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package reborncore.common.powerSystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard input / output limits for RC-based machines.
|
||||||
|
*/
|
||||||
|
public enum RcEnergyTier {
|
||||||
|
MICRO(8, 8),
|
||||||
|
LOW(32, 32),
|
||||||
|
MEDIUM(128, 128),
|
||||||
|
HIGH(512, 512),
|
||||||
|
EXTREME(2048, 2048),
|
||||||
|
INSANE(8192, 8192),
|
||||||
|
INFINITE(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
private final int maxInput;
|
||||||
|
private final int maxOutput;
|
||||||
|
|
||||||
|
RcEnergyTier(int maxInput, int maxOutput) {
|
||||||
|
this.maxInput = maxInput;
|
||||||
|
this.maxOutput = maxOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxInput() {
|
||||||
|
return maxInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxOutput() {
|
||||||
|
return maxOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RcEnergyTier getTier(long power) {
|
||||||
|
for (RcEnergyTier tier : RcEnergyTier.values()) {
|
||||||
|
if (tier.getMaxInput() >= power) {
|
||||||
|
return tier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return RcEnergyTier.INFINITE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,7 +39,7 @@ public interface IUpgradeHandler {
|
||||||
|
|
||||||
double getPowerMultiplier();
|
double getPowerMultiplier();
|
||||||
|
|
||||||
double getEuPerTick(double baseEu);
|
long getEuPerTick(long baseEu);
|
||||||
|
|
||||||
void addSpeedMulti(double amount);
|
void addSpeedMulti(double amount);
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,9 @@ import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.Energy;
|
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyStorage;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -63,7 +61,7 @@ public class RecipeCrafter implements IUpgradeHandler {
|
||||||
/**
|
/**
|
||||||
* This is the place to use the power from
|
* This is the place to use the power from
|
||||||
*/
|
*/
|
||||||
public EnergyStorage energy;
|
public PowerAcceptorBlockEntity energy;
|
||||||
|
|
||||||
public Optional<IUpgradeHandler> parentUpgradeHandler = Optional.empty();
|
public Optional<IUpgradeHandler> parentUpgradeHandler = Optional.empty();
|
||||||
|
|
||||||
|
@ -107,8 +105,8 @@ public class RecipeCrafter implements IUpgradeHandler {
|
||||||
int[] inputSlots, int[] outputSlots) {
|
int[] inputSlots, int[] outputSlots) {
|
||||||
this.recipeType = recipeType;
|
this.recipeType = recipeType;
|
||||||
this.blockEntity = blockEntity;
|
this.blockEntity = blockEntity;
|
||||||
if (blockEntity instanceof EnergyStorage) {
|
if (blockEntity instanceof PowerAcceptorBlockEntity powerAcceptor) {
|
||||||
energy = (EnergyStorage) blockEntity;
|
energy = powerAcceptor;
|
||||||
}
|
}
|
||||||
if (blockEntity instanceof IUpgradeHandler) {
|
if (blockEntity instanceof IUpgradeHandler) {
|
||||||
parentUpgradeHandler = Optional.of((IUpgradeHandler) blockEntity);
|
parentUpgradeHandler = Optional.of((IUpgradeHandler) blockEntity);
|
||||||
|
@ -180,8 +178,8 @@ public class RecipeCrafter implements IUpgradeHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (currentRecipe != null && currentTickTime < currentNeededTicks) {
|
} else if (currentRecipe != null && currentTickTime < currentNeededTicks) {
|
||||||
double useRequirement = getEuPerTick(currentRecipe.getPower());
|
long useRequirement = getEuPerTick(currentRecipe.getPower());
|
||||||
if (Energy.of(energy).use(useRequirement)) {
|
if (energy.tryUseExact(useRequirement)) {
|
||||||
currentTickTime++;
|
currentTickTime++;
|
||||||
if ((currentTickTime == 1 || currentTickTime % 20 == 0) && soundHanlder != null) {
|
if ((currentTickTime == 1 || currentTickTime % 20 == 0) && soundHanlder != null) {
|
||||||
soundHanlder.playSound(false, blockEntity);
|
soundHanlder.playSound(false, blockEntity);
|
||||||
|
@ -315,7 +313,7 @@ public class RecipeCrafter implements IUpgradeHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isActive() {
|
private boolean isActive() {
|
||||||
return currentRecipe != null && energy.getStored(EnergySide.UNKNOWN) >= currentRecipe.getPower();
|
return currentRecipe != null && energy.getEnergy() >= currentRecipe.getPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canCraftAgain() {
|
public boolean canCraftAgain() {
|
||||||
|
@ -326,7 +324,7 @@ public class RecipeCrafter implements IUpgradeHandler {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !(energy.getStored(EnergySide.UNKNOWN) < recipe.getPower());
|
return !(energy.getEnergy() < recipe.getPower());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -404,8 +402,8 @@ public class RecipeCrafter implements IUpgradeHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getEuPerTick(double baseEu) {
|
public long getEuPerTick(long baseEu) {
|
||||||
double power = parentUpgradeHandler.map(iUpgradeHandler -> iUpgradeHandler.getEuPerTick(baseEu)).orElse(1D);
|
long power = parentUpgradeHandler.map(iUpgradeHandler -> iUpgradeHandler.getEuPerTick(baseEu)).orElse(1L);
|
||||||
return Math.min(power, energy.getMaxStoredPower());
|
return Math.min(power, energy.getMaxStoredPower());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,20 @@
|
||||||
|
|
||||||
package reborncore.common.util;
|
package reborncore.common.util;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.item.PlayerInventoryStorage;
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage;
|
||||||
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.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
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 reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.recipes.IRecipeInput;
|
import reborncore.common.recipes.IRecipeInput;
|
||||||
import team.reborn.energy.Energy;
|
import team.reborn.energy.api.EnergyStorage;
|
||||||
|
import team.reborn.energy.api.EnergyStorageUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
@ -103,15 +109,11 @@ public class ItemUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getPowerForDurabilityBar(ItemStack stack) {
|
public static double getPowerForDurabilityBar(ItemStack stack) {
|
||||||
if (stack.isEmpty()) {
|
if (!(stack.getItem() instanceof RcEnergyItem energyItem)) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Energy.valid(stack)) {
|
return (double) energyItem.getStoredEnergy(stack) / energyItem.getEnergyCapacity();
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Energy.of(stack).getEnergy() / Energy.of(stack).getMaxStored();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +138,7 @@ public class ItemUtils {
|
||||||
if (!ItemUtils.isActive(stack)) {
|
if (!ItemUtils.isActive(stack)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Energy.of(stack).getEnergy() >= cost) {
|
if (((RcEnergyItem) stack.getItem()).getStoredEnergy(stack) >= cost) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isClient) {
|
if (isClient) {
|
||||||
|
@ -213,12 +215,29 @@ public class ItemUtils {
|
||||||
* @param itemStack ItemStack Powered item
|
* @param itemStack ItemStack Powered item
|
||||||
* @param maxOutput int Maximum output rate of powered item
|
* @param maxOutput int Maximum output rate of powered item
|
||||||
*/
|
*/
|
||||||
public static void distributePowerToInventory(PlayerEntity player, ItemStack itemStack, int maxOutput) {
|
public static void distributePowerToInventory(PlayerEntity player, ItemStack itemStack, long maxOutput) {
|
||||||
distributePowerToInventory(player, itemStack, maxOutput, (stack) -> true);
|
distributePowerToInventory(player, itemStack, maxOutput, (stack) -> true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void distributePowerToInventory(PlayerEntity player, ItemStack itemStack, int maxOutput, Predicate<ItemStack> filter) {
|
public static void distributePowerToInventory(PlayerEntity player, ItemStack itemStack, long maxOutput, Predicate<ItemStack> filter) {
|
||||||
if (!Energy.valid(itemStack)) {
|
// Locate the current stack in the player inventory.
|
||||||
|
PlayerInventoryStorage playerInv = PlayerInventoryStorage.of(player);
|
||||||
|
SingleSlotStorage<ItemVariant> sourceSlot = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < player.getInventory().size(); i++) {
|
||||||
|
if (player.getInventory().getStack(i) == itemStack) {
|
||||||
|
sourceSlot = playerInv.getSlots().get(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sourceSlot == null) {
|
||||||
|
throw new IllegalArgumentException("Failed to locate current stack in the player inventory.");
|
||||||
|
}
|
||||||
|
|
||||||
|
EnergyStorage sourceStorage = ContainerItemContext.ofPlayerSlot(player, sourceSlot).find(EnergyStorage.ITEM);
|
||||||
|
|
||||||
|
if (sourceStorage == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,11 +248,12 @@ public class ItemUtils {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Energy.valid(invStack)) {
|
EnergyStorageUtil.move(
|
||||||
Energy.of(itemStack)
|
sourceStorage,
|
||||||
.into(Energy.of(invStack))
|
ContainerItemContext.ofPlayerSlot(player, playerInv.getSlots().get(i)).find(EnergyStorage.ITEM),
|
||||||
.move(maxOutput);
|
maxOutput,
|
||||||
}
|
null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,10 @@ allprojects {
|
||||||
dev
|
dev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
|
||||||
// Shared deps between TR and RC
|
// Shared deps between TR and RC
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
|
|
|
@ -51,9 +51,10 @@ import net.minecraft.util.registry.Registry;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.multiblock.MultiblockRenderer;
|
import reborncore.client.multiblock.MultiblockRenderer;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.mixin.client.AccessorModelPredicateProviderRegistry;
|
import reborncore.mixin.client.AccessorModelPredicateProviderRegistry;
|
||||||
import team.reborn.energy.Energy;
|
import team.reborn.energy.api.base.SimpleBatteryItem;
|
||||||
import techreborn.client.render.DynamicBucketBakedModel;
|
import techreborn.client.render.DynamicBucketBakedModel;
|
||||||
import techreborn.client.render.DynamicCellBakedModel;
|
import techreborn.client.render.DynamicCellBakedModel;
|
||||||
import techreborn.client.render.entitys.CableCoverRenderer;
|
import techreborn.client.render.entitys.CableCoverRenderer;
|
||||||
|
@ -183,7 +184,7 @@ public class TechRebornClient implements ClientModInitializer {
|
||||||
BatpackItem.class,
|
BatpackItem.class,
|
||||||
new Identifier("techreborn:empty"),
|
new Identifier("techreborn:empty"),
|
||||||
(item, stack, world, entity, seed) -> {
|
(item, stack, world, entity, seed) -> {
|
||||||
if (!stack.isEmpty() && Energy.of(stack).getEnergy() == 0) {
|
if (!stack.isEmpty() && SimpleBatteryItem.getStoredEnergyUnchecked(stack) == 0) {
|
||||||
return 1.0F;
|
return 1.0F;
|
||||||
}
|
}
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
|
@ -194,7 +195,7 @@ public class TechRebornClient implements ClientModInitializer {
|
||||||
BatteryItem.class,
|
BatteryItem.class,
|
||||||
new Identifier("techreborn:empty"),
|
new Identifier("techreborn:empty"),
|
||||||
(item, stack, world, entity, seed) -> {
|
(item, stack, world, entity, seed) -> {
|
||||||
if (!stack.isEmpty() && Energy.of(stack).getEnergy() == 0) {
|
if (!stack.isEmpty() && SimpleBatteryItem.getStoredEnergyUnchecked(stack) == 0) {
|
||||||
return 1.0F;
|
return 1.0F;
|
||||||
}
|
}
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
|
@ -218,7 +219,7 @@ public class TechRebornClient implements ClientModInitializer {
|
||||||
ChainsawItem.class,
|
ChainsawItem.class,
|
||||||
new Identifier("techreborn:animated"),
|
new Identifier("techreborn:animated"),
|
||||||
(item, stack, world, entity, seed) -> {
|
(item, stack, world, entity, seed) -> {
|
||||||
if (!stack.isEmpty() && Energy.of(stack).getEnergy() >= item.getCost() && entity != null && entity.getMainHandStack().equals(stack)) {
|
if (!stack.isEmpty() && SimpleBatteryItem.getStoredEnergyUnchecked(stack) >= item.getCost() && entity != null && entity.getMainHandStack().equals(stack)) {
|
||||||
return 1.0F;
|
return 1.0F;
|
||||||
}
|
}
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
|
@ -230,7 +231,8 @@ public class TechRebornClient implements ClientModInitializer {
|
||||||
new Identifier("techreborn:active"),
|
new Identifier("techreborn:active"),
|
||||||
(item, stack, world, entity, seed) -> {
|
(item, stack, world, entity, seed) -> {
|
||||||
if (ItemUtils.isActive(stack)) {
|
if (ItemUtils.isActive(stack)) {
|
||||||
if (Energy.of(stack).getMaxStored() - Energy.of(stack).getEnergy() >= 0.9 * Energy.of(stack).getMaxStored()) {
|
RcEnergyItem energyItem = (RcEnergyItem) stack.getItem();
|
||||||
|
if (energyItem.getEnergyCapacity() - energyItem.getStoredEnergy(stack) >= 0.9 * item.getEnergyCapacity()) {
|
||||||
return 0.5F;
|
return 0.5F;
|
||||||
}
|
}
|
||||||
return 1.0F;
|
return 1.0F;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
package techreborn.blockentity.cable;
|
package techreborn.blockentity.cable;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
|
||||||
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.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
@ -40,18 +41,16 @@ import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IListInfoProvider;
|
import reborncore.api.IListInfoProvider;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.network.ClientBoundPackets;
|
import reborncore.common.network.ClientBoundPackets;
|
||||||
import reborncore.common.network.NetworkManager;
|
import reborncore.common.network.NetworkManager;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.util.StringUtils;
|
import reborncore.common.util.StringUtils;
|
||||||
import team.reborn.energy.Energy;
|
import team.reborn.energy.api.EnergyStorage;
|
||||||
import team.reborn.energy.EnergySide;
|
import team.reborn.energy.api.EnergyStorageUtil;
|
||||||
import team.reborn.energy.EnergyStorage;
|
import team.reborn.energy.api.base.SimpleSidedEnergyContainer;
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.blocks.cable.CableBlock;
|
import techreborn.blocks.cable.CableBlock;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -65,11 +64,29 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CableBlockEntity extends BlockEntity
|
public class CableBlockEntity extends BlockEntity
|
||||||
implements BlockEntityTicker<CableBlockEntity>, IListInfoProvider, IToolDrop, EnergyStorage {
|
implements BlockEntityTicker<CableBlockEntity>, IListInfoProvider, IToolDrop {
|
||||||
|
private final SimpleSidedEnergyContainer energyContainer = new SimpleSidedEnergyContainer() {
|
||||||
|
@Override
|
||||||
|
public long getCapacity() {
|
||||||
|
return getCableType().transferRate * 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getMaxInsert(@Nullable Direction side) {
|
||||||
|
if (!canAcceptEnergy(side)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return getCableType().transferRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getMaxExtract(@Nullable Direction side) {
|
||||||
|
return getCableType().transferRate;
|
||||||
|
}
|
||||||
|
};
|
||||||
private double energy = 0;
|
private double energy = 0;
|
||||||
private TRContent.Cables cableType = null;
|
private TRContent.Cables cableType = null;
|
||||||
private ArrayList<EnergySide> sendingFace = new ArrayList<>();
|
private ArrayList<Direction> sendingFace = new ArrayList<>();
|
||||||
private BlockState cover = null;
|
private BlockState cover = null;
|
||||||
|
|
||||||
public CableBlockEntity(BlockPos pos, BlockState state) {
|
public CableBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
@ -96,6 +113,10 @@ public class CableBlockEntity extends BlockEntity
|
||||||
return TRContent.Cables.COPPER;
|
return TRContent.Cables.COPPER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EnergyStorage getSideEnergyStorage(@Nullable Direction side) {
|
||||||
|
return energyContainer.getSideStorage(side);
|
||||||
|
}
|
||||||
|
|
||||||
public BlockState getCover() {
|
public BlockState getCover() {
|
||||||
return cover;
|
return cover;
|
||||||
}
|
}
|
||||||
|
@ -107,19 +128,19 @@ public class CableBlockEntity extends BlockEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canAcceptEnergy(EnergySide direction) {
|
public boolean canAcceptEnergy(@Nullable Direction direction) {
|
||||||
if (sendingFace.contains(direction)) {
|
if (sendingFace.contains(direction)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return getMaxStoredPower() != getEnergy();
|
return energyContainer.getCapacity() != getEnergy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getEnergy() {
|
public long getEnergy() {
|
||||||
return getStored(EnergySide.UNKNOWN);
|
return energyContainer.amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnergy(double energy) {
|
public void setEnergy(long energy) {
|
||||||
setStored(energy);
|
energyContainer.amount = energy;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockEntity
|
// BlockEntity
|
||||||
|
@ -171,17 +192,19 @@ public class CableBlockEntity extends BlockEntity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Pair<BlockEntity, Direction>> acceptors = new ArrayList<>();
|
ArrayList<EnergyStorage> acceptors = new ArrayList<>();
|
||||||
ArrayList<CableBlockEntity> cables = new ArrayList<>();
|
ArrayList<CableBlockEntity> cables = new ArrayList<>();
|
||||||
|
|
||||||
for (Direction face : Direction.values()) {
|
for (Direction face : Direction.values()) {
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos.offset(face));
|
BlockPos adjPos = pos.offset(face);
|
||||||
if (blockEntity == null || !Energy.valid(blockEntity)) {
|
BlockEntity blockEntity = world.getBlockEntity(adjPos);
|
||||||
|
EnergyStorage target = EnergyStorage.SIDED.find(world, adjPos, null, blockEntity, face.getOpposite());
|
||||||
|
if (target == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockEntity instanceof CableBlockEntity cableBlockEntity) {
|
if (blockEntity instanceof CableBlockEntity cableBlockEntity) {
|
||||||
if (cableBlockEntity.getTier() != this.getTier()) {
|
if (cableBlockEntity.cableType != this.cableType) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Only need ones with energy stores less than ours
|
// Only need ones with energy stores less than ours
|
||||||
|
@ -191,12 +214,12 @@ public class CableBlockEntity extends BlockEntity
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
EnergySide side = EnergySide.fromMinecraft(face);
|
try (Transaction transaction = Transaction.openOuter()) {
|
||||||
|
if (target.insert(Long.MAX_VALUE, transaction) > 0) {
|
||||||
if (Energy.of(blockEntity).side(face.getOpposite()).getMaxInput() > 0) {
|
acceptors.add(target);
|
||||||
acceptors.add(Pair.of(blockEntity, face));
|
if (!sendingFace.contains(face)) {
|
||||||
if (!sendingFace.contains(side)) {
|
sendingFace.add(face);
|
||||||
sendingFace.add(side);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,11 +228,12 @@ public class CableBlockEntity extends BlockEntity
|
||||||
if (!acceptors.isEmpty()) {
|
if (!acceptors.isEmpty()) {
|
||||||
Collections.shuffle(acceptors);
|
Collections.shuffle(acceptors);
|
||||||
|
|
||||||
acceptors.forEach(pair ->
|
acceptors.forEach(t -> EnergyStorageUtil.move(
|
||||||
Energy.of(this)
|
energyContainer.getSideStorage(null),
|
||||||
.into(Energy.of(pair.getLeft()).side(pair.getRight().getOpposite()))
|
t,
|
||||||
.move()
|
Long.MAX_VALUE,
|
||||||
);
|
null
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,10 +242,15 @@ public class CableBlockEntity extends BlockEntity
|
||||||
if (!cables.isEmpty()) {
|
if (!cables.isEmpty()) {
|
||||||
|
|
||||||
cables.add(this);
|
cables.add(this);
|
||||||
double energyTotal = cables.stream().mapToDouble(CableBlockEntity::getEnergy).sum();
|
long energyTotal = cables.stream().mapToLong(CableBlockEntity::getEnergy).sum();
|
||||||
double energyPer = energyTotal / cables.size();
|
long remainingCount = cables.size();
|
||||||
|
|
||||||
cables.forEach(cableBlockEntity -> cableBlockEntity.setEnergy(energyPer));
|
for (CableBlockEntity cable : cables) {
|
||||||
|
long newEnergy = energyTotal / remainingCount;
|
||||||
|
cable.setEnergy(newEnergy);
|
||||||
|
energyTotal -= newEnergy;
|
||||||
|
remainingCount--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,38 +286,4 @@ public class CableBlockEntity extends BlockEntity
|
||||||
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
||||||
return new ItemStack(getCableType().block);
|
return new ItemStack(getCableType().block);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnergyStorage
|
|
||||||
@Override
|
|
||||||
public double getStored(EnergySide face) {
|
|
||||||
return energy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setStored(double amount) {
|
|
||||||
this.energy = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxStoredPower() {
|
|
||||||
return getCableType().transferRate * 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnergyTier getTier() {
|
|
||||||
return PowerAcceptorBlockEntity.getTier(getCableType().transferRate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxInput(EnergySide side) {
|
|
||||||
if (!canAcceptEnergy(side)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return getCableType().transferRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxOutput(EnergySide side) {
|
|
||||||
return getCableType().transferRate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.block.entity.BlockEntityType;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -41,7 +42,6 @@ import reborncore.common.fluid.container.ItemFluidInfo;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.api.generator.EFluidGenerator;
|
import techreborn.api.generator.EFluidGenerator;
|
||||||
import techreborn.api.generator.FluidGeneratorRecipe;
|
import techreborn.api.generator.FluidGeneratorRecipe;
|
||||||
import techreborn.api.generator.FluidGeneratorRecipeList;
|
import techreborn.api.generator.FluidGeneratorRecipeList;
|
||||||
|
@ -150,17 +150,17 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return euTick;
|
return euTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(EnergySide side) {
|
public boolean canAcceptEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,14 +31,15 @@ import net.minecraft.entity.LightningEntity;
|
||||||
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.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.Heightmap;
|
import net.minecraft.world.Heightmap;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -91,7 +92,7 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
if (!world.isClient) {
|
if (!world.isClient) {
|
||||||
world.spawnEntity(lightningBolt);
|
world.spawnEntity(lightningBolt);
|
||||||
}
|
}
|
||||||
addEnergy(TechRebornConfig.lightningRodBaseEnergyStrike * (0.3F + weatherStrength));
|
addEnergy((long) (TechRebornConfig.lightningRodBaseEnergyStrike * (0.3F + weatherStrength)));
|
||||||
machineBaseBlock.setActive(true, world, pos);
|
machineBaseBlock.setActive(true, world, pos);
|
||||||
onStatusHoldTicks = 400;
|
onStatusHoldTicks = 400;
|
||||||
}
|
}
|
||||||
|
@ -123,22 +124,22 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.lightningRodMaxEnergy;
|
return TechRebornConfig.lightningRodMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(EnergySide side) {
|
public boolean canAcceptEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.lightningRodMaxOutput;
|
return TechRebornConfig.lightningRodMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,12 @@ public class PlasmaGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity im
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.plasmaGeneratorMaxEnergy;
|
return TechRebornConfig.plasmaGeneratorMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.plasmaGeneratorMaxOutput;
|
return TechRebornConfig.plasmaGeneratorMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,9 @@ import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
|
@ -43,9 +45,8 @@ import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.StringUtils;
|
import reborncore.common.util.StringUtils;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.blocks.generator.BlockSolarPanel;
|
import techreborn.blocks.generator.BlockSolarPanel;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -171,24 +172,24 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return getPanel().internalCapacity;
|
return getPanel().internalCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canAcceptEnergy(EnergySide side) { return false; }
|
protected boolean canAcceptEnergy(@Nullable Direction side) { return false; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
if (getPanel() == TRContent.SolarPanels.CREATIVE) {
|
if (getPanel() == TRContent.SolarPanels.CREATIVE) {
|
||||||
return EnergyTier.INSANE.getMaxOutput();
|
return RcEnergyTier.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
|
||||||
return EnergyTier.EXTREME.getMaxOutput();
|
return RcEnergyTier.EXTREME.getMaxOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +204,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return getPanel().powerTier;
|
return getPanel().powerTier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,12 @@ public class DieselGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity im
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.dieselGeneratorMaxEnergy;
|
return TechRebornConfig.dieselGeneratorMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.dieselGeneratorMaxOutput;
|
return TechRebornConfig.dieselGeneratorMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,14 +29,15 @@ import net.minecraft.block.Blocks;
|
||||||
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.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -85,22 +86,22 @@ public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.dragonEggSyphonMaxEnergy;
|
return TechRebornConfig.dragonEggSyphonMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(EnergySide side) {
|
public boolean canAcceptEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.dragonEggSyphonMaxOutput;
|
return TechRebornConfig.dragonEggSyphonMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,12 @@ public class GasTurbineBlockEntity extends BaseFluidGeneratorBlockEntity impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.gasTurbineMaxEnergy;
|
return TechRebornConfig.gasTurbineMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.gasTurbineMaxOutput;
|
return TechRebornConfig.gasTurbineMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,12 @@ public class SemiFluidGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.semiFluidGeneratorMaxEnergy;
|
return TechRebornConfig.semiFluidGeneratorMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.semiFluidGeneratorMaxOutput;
|
return TechRebornConfig.semiFluidGeneratorMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,12 @@ public class ThermalGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.thermalGeneratorMaxEnergy;
|
return TechRebornConfig.thermalGeneratorMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.thermalGeneratorMaxOutput;
|
return TechRebornConfig.thermalGeneratorMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,10 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -44,7 +46,6 @@ import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -131,22 +132,22 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.solidFuelGeneratorMaxEnergy;
|
return TechRebornConfig.solidFuelGeneratorMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(EnergySide side) {
|
public boolean canAcceptEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.solidFuelGeneratorMaxOutput;
|
return TechRebornConfig.solidFuelGeneratorMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,12 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -58,7 +59,7 @@ public class WaterMillBlockEntity extends PowerAcceptorBlockEntity implements IT
|
||||||
checkForWater();
|
checkForWater();
|
||||||
}
|
}
|
||||||
if (waterblocks > 0) {
|
if (waterblocks > 0) {
|
||||||
addEnergy(waterblocks * TechRebornConfig.waterMillEnergyMultiplier);
|
addEnergyProbabilistic(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));
|
||||||
|
@ -75,22 +76,22 @@ public class WaterMillBlockEntity extends PowerAcceptorBlockEntity implements IT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.waterMillMaxEnergy;
|
return TechRebornConfig.waterMillMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(EnergySide side) {
|
public boolean canAcceptEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.waterMillMaxOutput;
|
return TechRebornConfig.waterMillMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,13 @@ import net.minecraft.block.BlockState;
|
||||||
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.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -82,22 +84,22 @@ public class WindMillBlockEntity extends PowerAcceptorBlockEntity implements ITo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.windMillMaxEnergy;
|
return TechRebornConfig.windMillMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.windMillMaxOutput;
|
return TechRebornConfig.windMillMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,10 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.blocks.lighting.LampBlock;
|
import techreborn.blocks.lighting.LampBlock;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -59,8 +59,8 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity implements IToolDr
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double cost = getEuPerTick(((LampBlock) b).getCost());
|
long cost = getEuPerTick(((LampBlock) b).getCost());
|
||||||
if (getStored(EnergySide.UNKNOWN) > cost) {
|
if (getStored() > cost) {
|
||||||
useEnergy(cost);
|
useEnergy(cost);
|
||||||
if (!LampBlock.isActive(state)) {
|
if (!LampBlock.isActive(state)) {
|
||||||
LampBlock.setActive(true, world, pos);
|
LampBlock.setActive(true, world, pos);
|
||||||
|
@ -71,27 +71,27 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity implements IToolDr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canAcceptEnergy(EnergySide side) {
|
protected boolean canAcceptEnergy(@Nullable Direction side) {
|
||||||
return side == EnergySide.UNKNOWN || getFacing().getOpposite() == Direction.values()[side.ordinal()];
|
return side == null || getFacing().getOpposite() == Direction.values()[side.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return capacity;
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return 32;
|
return 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,9 @@ 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.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||||
|
@ -38,7 +40,7 @@ import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
|
@ -97,22 +99,22 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return maxEnergy;
|
return maxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return maxInput;
|
return maxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,9 @@ import net.minecraft.block.BlockState;
|
||||||
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.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -37,7 +39,6 @@ import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -65,23 +66,23 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.chargeOMatBMaxEnergy;
|
return TechRebornConfig.chargeOMatBMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
// This allows to move energy from BE to chargeable item. #2264
|
// This allows to move energy from BE to chargeable item. #2264
|
||||||
return side == EnergySide.UNKNOWN;
|
return side == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return TechRebornConfig.chargeOMatBMaxOutput;
|
return TechRebornConfig.chargeOMatBMaxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return TechRebornConfig.chargeOMatBMaxInput;
|
return TechRebornConfig.chargeOMatBMaxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,9 @@ import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
@ -44,7 +46,6 @@ import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import reborncore.common.util.StringUtils;
|
import reborncore.common.util.StringUtils;
|
||||||
import reborncore.common.util.Torus;
|
import reborncore.common.util.Torus;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.api.recipe.recipes.FusionReactorRecipe;
|
import techreborn.api.recipe.recipes.FusionReactorRecipe;
|
||||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -229,12 +230,12 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return Math.min(TechRebornConfig.fusionControlComputerMaxEnergy * getPowerMultiplier(), Integer.MAX_VALUE);
|
return Math.min((long) (TechRebornConfig.fusionControlComputerMaxEnergy * getPowerMultiplier()), Long.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
if (!hasStartedCrafting) {
|
if (!hasStartedCrafting) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +243,7 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
if (hasStartedCrafting) {
|
if (hasStartedCrafting) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -297,7 +298,7 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
|
|
||||||
if (!hasStartedCrafting) {
|
if (!hasStartedCrafting) {
|
||||||
// Ignition!
|
// Ignition!
|
||||||
if (getStored(EnergySide.UNKNOWN) > currentRecipe.getStartEnergy()) {
|
if (getStored() > currentRecipe.getStartEnergy()) {
|
||||||
useEnergy(currentRecipe.getStartEnergy());
|
useEnergy(currentRecipe.getStartEnergy());
|
||||||
hasStartedCrafting = true;
|
hasStartedCrafting = true;
|
||||||
useInput(topStackSlot);
|
useInput(topStackSlot);
|
||||||
|
@ -308,12 +309,12 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
// Power gen
|
// Power gen
|
||||||
if (currentRecipe.getPower() > 0) {
|
if (currentRecipe.getPower() > 0) {
|
||||||
// Waste power if it has no where to go
|
// Waste power if it has no where to go
|
||||||
double power = Math.abs(currentRecipe.getPower()) * getPowerMultiplier();
|
long power = (long) (Math.abs(currentRecipe.getPower()) * getPowerMultiplier());
|
||||||
addEnergy(power);
|
addEnergy(power);
|
||||||
powerChange = (power);
|
powerChange = (power);
|
||||||
craftingTickTime++;
|
craftingTickTime++;
|
||||||
} else { // Power user
|
} else { // Power user
|
||||||
if (getStored(EnergySide.UNKNOWN) > currentRecipe.getPower()) {
|
if (getStored() > currentRecipe.getPower()) {
|
||||||
setEnergy(getEnergy() - currentRecipe.getPower());
|
setEnergy(getEnergy() - currentRecipe.getPower());
|
||||||
craftingTickTime++;
|
craftingTickTime++;
|
||||||
}
|
}
|
||||||
|
@ -342,15 +343,15 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canAcceptEnergy(EnergySide side) {
|
protected boolean canAcceptEnergy(@Nullable Direction side) {
|
||||||
// Accept from sides
|
// Accept from sides
|
||||||
return !(side == EnergySide.DOWN || side == EnergySide.UP);
|
return !(side == Direction.DOWN || side == Direction.UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
// Provide from top and bottom
|
// Provide from top and bottom
|
||||||
return side == EnergySide.DOWN || side == EnergySide.UP;
|
return side == Direction.DOWN || side == Direction.UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,6 +37,7 @@ import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -50,7 +51,6 @@ import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.recipes.ExtendedRecipeRemainder;
|
import reborncore.common.recipes.ExtendedRecipeRemainder;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.ModSounds;
|
import techreborn.init.ModSounds;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
|
@ -372,7 +372,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (canMake(recipe)) {
|
if (canMake(recipe)) {
|
||||||
if (getStored(EnergySide.UNKNOWN) > euTick) {
|
if (getStored() > euTick) {
|
||||||
progress++;
|
progress++;
|
||||||
if (progress == 1) {
|
if (progress == 1) {
|
||||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.AUTO_CRAFTING,
|
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.AUTO_CRAFTING,
|
||||||
|
@ -387,22 +387,22 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.autoCraftingTableMaxEnergy;
|
return TechRebornConfig.autoCraftingTableMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return TechRebornConfig.autoCraftingTableMaxInput;
|
return TechRebornConfig.autoCraftingTableMaxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,9 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.recipe.RecipeType;
|
import net.minecraft.recipe.RecipeType;
|
||||||
import net.minecraft.recipe.SmeltingRecipe;
|
import net.minecraft.recipe.SmeltingRecipe;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -43,7 +45,6 @@ import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -221,7 +222,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
craftRecipe(currentRecipe);
|
craftRecipe(currentRecipe);
|
||||||
updateCurrentRecipe();
|
updateCurrentRecipe();
|
||||||
} else if (cookTime < cookTimeTotal) {
|
} else if (cookTime < cookTimeTotal) {
|
||||||
if (getStored(EnergySide.UNKNOWN) > getEuPerTick(EnergyPerTick)) {
|
if (getStored() > getEuPerTick(EnergyPerTick)) {
|
||||||
useEnergy(getEuPerTick(EnergyPerTick));
|
useEnergy(getEuPerTick(EnergyPerTick));
|
||||||
cookTime++;
|
cookTime++;
|
||||||
if (cookTime == 1 || cookTime % 20 == 0 && RecipeCrafter.soundHanlder != null) {
|
if (cookTime == 1 || cookTime % 20 == 0 && RecipeCrafter.soundHanlder != null) {
|
||||||
|
@ -234,22 +235,22 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canProvideEnergy(EnergySide side) {
|
protected boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.electricFurnaceMaxEnergy;
|
return TechRebornConfig.electricFurnaceMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return TechRebornConfig.electricFurnaceMaxInput;
|
return TechRebornConfig.electricFurnaceMaxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -43,7 +44,6 @@ import reborncore.common.blockentity.MultiblockWriter;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.blocks.lighting.LampBlock;
|
import techreborn.blocks.lighting.LampBlock;
|
||||||
import techreborn.blocks.misc.BlockRubberLog;
|
import techreborn.blocks.misc.BlockRubberLog;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -88,7 +88,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
if (block instanceof Fertilizable || block instanceof PlantBlock
|
if (block instanceof Fertilizable || block instanceof PlantBlock
|
||||||
|| block instanceof SugarCaneBlock || block instanceof CactusBlock
|
|| block instanceof SugarCaneBlock || block instanceof CactusBlock
|
||||||
) {
|
) {
|
||||||
if (getStored(EnergySide.UNKNOWN) > TechRebornConfig.greenhouseControllerEnergyPerBonemeal) {
|
if (getStored() > TechRebornConfig.greenhouseControllerEnergyPerBonemeal) {
|
||||||
useEnergy(TechRebornConfig.greenhouseControllerEnergyPerBonemeal);
|
useEnergy(TechRebornConfig.greenhouseControllerEnergyPerBonemeal);
|
||||||
blockState.randomTick((ServerWorld) world, blockPos, world.random);
|
blockState.randomTick((ServerWorld) world, blockPos, world.random);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
} else if (block instanceof BlockRubberLog) {
|
} else if (block instanceof BlockRubberLog) {
|
||||||
for (int y = 0; (blockState = world.getBlockState(blockPos.up(y))).getBlock() == block && y < 10; y++) {
|
for (int y = 0; (blockState = world.getBlockState(blockPos.up(y))).getBlock() == block && y < 10; y++) {
|
||||||
if (blockState.get(BlockRubberLog.HAS_SAP)
|
if (blockState.get(BlockRubberLog.HAS_SAP)
|
||||||
&& (getStored(EnergySide.UNKNOWN) > TechRebornConfig.greenhouseControllerEnergyPerHarvest)
|
&& (getStored() > TechRebornConfig.greenhouseControllerEnergyPerHarvest)
|
||||||
&& insertIntoInv(Collections.singletonList(TRContent.Parts.SAP.getStack()))
|
&& insertIntoInv(Collections.singletonList(TRContent.Parts.SAP.getStack()))
|
||||||
) {
|
) {
|
||||||
useEnergy(TechRebornConfig.greenhouseControllerEnergyPerHarvest);
|
useEnergy(TechRebornConfig.greenhouseControllerEnergyPerHarvest);
|
||||||
|
@ -150,7 +150,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getStored(EnergySide.UNKNOWN) < TechRebornConfig.greenhouseControllerEnergyPerHarvest){
|
if (getStored() < TechRebornConfig.greenhouseControllerEnergyPerHarvest){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (insertIntoInv(Block.getDroppedStacks(blockState, (ServerWorld) world, blockPos, null))) {
|
if (insertIntoInv(Block.getDroppedStacks(blockState, (ServerWorld) world, blockPos, null))) {
|
||||||
|
@ -204,7 +204,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
|
|
||||||
charge(6);
|
charge(6);
|
||||||
|
|
||||||
if (getStored(EnergySide.UNKNOWN) < getEuPerTick(TechRebornConfig.greenhouseControllerEnergyPerTick)) {
|
if (getStored() < getEuPerTick(TechRebornConfig.greenhouseControllerEnergyPerTick)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,22 +222,22 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.greenhouseControllerMaxEnergy;
|
return TechRebornConfig.greenhouseControllerMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return TechRebornConfig.greenhouseControllerMaxInput;
|
return TechRebornConfig.greenhouseControllerMaxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,10 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
|
@ -38,7 +40,7 @@ import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.WorldUtils;
|
import reborncore.common.util.WorldUtils;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.blocks.machine.tier1.PlayerDetectorBlock;
|
import techreborn.blocks.machine.tier1.PlayerDetectorBlock;
|
||||||
import techreborn.blocks.machine.tier1.PlayerDetectorBlock.PlayerDetectorType;
|
import techreborn.blocks.machine.tier1.PlayerDetectorBlock.PlayerDetectorType;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -86,7 +88,7 @@ public class PlayerDetectorBlockEntity extends PowerAcceptorBlockEntity implemen
|
||||||
|
|
||||||
boolean lastRedstone = redstone;
|
boolean lastRedstone = redstone;
|
||||||
redstone = false;
|
redstone = false;
|
||||||
if (getStored(EnergySide.UNKNOWN) > TechRebornConfig.playerDetectorEuPerTick) {
|
if (getStored() > TechRebornConfig.playerDetectorEuPerTick) {
|
||||||
for (PlayerEntity player : world.getPlayers()) {
|
for (PlayerEntity player : world.getPlayers()) {
|
||||||
if (MathHelper.sqrt((float)player.squaredDistanceTo(pos.getX(), pos.getY(), pos.getZ())) <= (float)radius ) {
|
if (MathHelper.sqrt((float)player.squaredDistanceTo(pos.getX(), pos.getY(), pos.getZ())) <= (float)radius ) {
|
||||||
PlayerDetectorType type = world.getBlockState(pos).get(PlayerDetectorBlock.TYPE);
|
PlayerDetectorType type = world.getBlockState(pos).get(PlayerDetectorBlock.TYPE);
|
||||||
|
@ -112,22 +114,22 @@ public class PlayerDetectorBlockEntity extends PowerAcceptorBlockEntity implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.playerDetectorMaxEnergy;
|
return TechRebornConfig.playerDetectorMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return TechRebornConfig.playerDetectorMaxInput;
|
return TechRebornConfig.playerDetectorMaxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,11 @@ import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.recipe.Ingredient;
|
import net.minecraft.recipe.Ingredient;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -45,7 +47,7 @@ import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.api.recipe.recipes.RollingMachineRecipe;
|
import techreborn.api.recipe.recipes.RollingMachineRecipe;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.ModRecipes;
|
import techreborn.init.ModRecipes;
|
||||||
|
@ -81,22 +83,22 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.rollingMachineMaxEnergy;
|
return TechRebornConfig.rollingMachineMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return TechRebornConfig.rollingMachineMaxInput;
|
return TechRebornConfig.rollingMachineMaxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +159,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
tickTime = 0;
|
tickTime = 0;
|
||||||
}
|
}
|
||||||
if (!currentRecipeOutput.isEmpty()) {
|
if (!currentRecipeOutput.isEmpty()) {
|
||||||
if (getStored(EnergySide.UNKNOWN) > getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick)
|
if (getStored() > getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick)
|
||||||
&& tickTime < Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1)
|
&& tickTime < Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1)
|
||||||
&& canMake(craftMatrix)) {
|
&& canMake(craftMatrix)) {
|
||||||
useEnergy(getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick));
|
useEnergy(getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick));
|
||||||
|
|
|
@ -28,7 +28,9 @@ import net.minecraft.block.BlockState;
|
||||||
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.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -38,7 +40,6 @@ import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -85,20 +86,6 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean decreaseStoredEnergy(double aEnergy, boolean aIgnoreTooLessEnergy) {
|
|
||||||
if (getEnergy() - aEnergy < 0 && !aIgnoreTooLessEnergy) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
setEnergy(getEnergy() - aEnergy);
|
|
||||||
if (getEnergy() < 0) {
|
|
||||||
setEnergy(0);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getValue(ItemStack itemStack) {
|
public int getValue(ItemStack itemStack) {
|
||||||
if (itemStack.isItemEqualIgnoreDamage(TRContent.Parts.SCRAP.getStack())) {
|
if (itemStack.isItemEqualIgnoreDamage(TRContent.Parts.SCRAP.getStack())) {
|
||||||
return 200;
|
return 200;
|
||||||
|
@ -138,7 +125,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
||||||
if (!stack.isEmpty() && spaceForOutput()) {
|
if (!stack.isEmpty() && spaceForOutput()) {
|
||||||
final int amp = getValue(stack);
|
final int amp = getValue(stack);
|
||||||
final int euNeeded = amp * TechRebornConfig.matterFabricatorEnergyPerAmp;
|
final int euNeeded = amp * TechRebornConfig.matterFabricatorEnergyPerAmp;
|
||||||
if (amp != 0 && getStored(EnergySide.UNKNOWN) > euNeeded) {
|
if (amp != 0 && getStored() > euNeeded) {
|
||||||
useEnergy(euNeeded);
|
useEnergy(euNeeded);
|
||||||
amplifier += amp;
|
amplifier += amp;
|
||||||
inventory.shrinkSlot(i, 1);
|
inventory.shrinkSlot(i, 1);
|
||||||
|
@ -155,22 +142,22 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return TechRebornConfig.matterFabricatorMaxEnergy;
|
return TechRebornConfig.matterFabricatorMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return TechRebornConfig.matterFabricatorMaxInput;
|
return TechRebornConfig.matterFabricatorMaxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,16 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.blockentity.IUpgrade;
|
import reborncore.api.blockentity.IUpgrade;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -49,7 +50,7 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
public int superconductors = 0;
|
public int superconductors = 0;
|
||||||
|
|
||||||
public AdjustableSUBlockEntity(BlockPos pos, BlockState state) {
|
public AdjustableSUBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.ADJUSTABLE_SU, pos, state, "ADJUSTABLE_SU", 4, TRContent.Machine.ADJUSTABLE_SU.block, EnergyTier.INSANE, TechRebornConfig.aesuMaxEnergy);
|
super(TRBlockEntities.ADJUSTABLE_SU, pos, state, "ADJUSTABLE_SU", 4, TRContent.Machine.ADJUSTABLE_SU.block, RcEnergyTier.INSANE, TechRebornConfig.aesuMaxEnergy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxConfigOutput() {
|
public int getMaxConfigOutput() {
|
||||||
|
@ -114,12 +115,12 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return OUTPUT;
|
return OUTPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long 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();
|
||||||
|
@ -135,7 +136,7 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxOutput(EnergySide side) {
|
public long getMaxOutput(@Nullable Direction side) {
|
||||||
return OUTPUT;
|
return OUTPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,13 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.blocks.storage.energy.EnergyStorageBlock;
|
import techreborn.blocks.storage.energy.EnergyStorageBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,16 +49,14 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity implement
|
||||||
public RebornInventory<EnergyStorageBlockEntity> inventory;
|
public RebornInventory<EnergyStorageBlockEntity> inventory;
|
||||||
public String name;
|
public String name;
|
||||||
public Block wrenchDrop;
|
public Block wrenchDrop;
|
||||||
public EnergyTier tier;
|
|
||||||
public int maxInput;
|
public int maxInput;
|
||||||
public int maxOutput;
|
public int maxOutput;
|
||||||
public int maxStorage;
|
public int maxStorage;
|
||||||
|
|
||||||
public EnergyStorageBlockEntity(BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state, String name, int invSize, Block wrenchDrop, EnergyTier tier, int maxStorage) {
|
public EnergyStorageBlockEntity(BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state, String name, int invSize, Block wrenchDrop, RcEnergyTier tier, int maxStorage) {
|
||||||
super(blockEntityType, pos, state);
|
super(blockEntityType, pos, state);
|
||||||
inventory = new RebornInventory<>(invSize, name + "BlockEntity", 64, this);
|
inventory = new RebornInventory<>(invSize, name + "BlockEntity", 64, this);
|
||||||
this.wrenchDrop = wrenchDrop;
|
this.wrenchDrop = wrenchDrop;
|
||||||
this.tier = tier;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.maxInput = tier.getMaxInput();
|
this.maxInput = tier.getMaxInput();
|
||||||
this.maxOutput = tier.getMaxOutput();
|
this.maxOutput = tier.getMaxOutput();
|
||||||
|
@ -86,27 +84,28 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(EnergySide side) {
|
public boolean canAcceptEnergy(@Nullable Direction side) {
|
||||||
return side == EnergySide.UNKNOWN || getFacing() != Direction.values()[side.ordinal()];
|
return getFacing() != side;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(EnergySide side) {
|
public boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
return side == EnergySide.UNKNOWN || getFacing() == Direction.values()[side.ordinal()];
|
// side == null allows to move energy from BE to chargeable item.
|
||||||
|
return side == null || getFacing() == side;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return maxStorage;
|
return maxStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return maxOutput;
|
return maxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return maxInput;
|
return maxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ public class HighVoltageSUBlockEntity extends EnergyStorageBlockEntity implement
|
||||||
* MFSU should store 4M Energy with 512 E/t I/O
|
* MFSU should store 4M Energy with 512 E/t I/O
|
||||||
*/
|
*/
|
||||||
public HighVoltageSUBlockEntity(BlockPos pos, BlockState state) {
|
public HighVoltageSUBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.HIGH_VOLTAGE_SU, pos, state, "HIGH_VOLTAGE_SU", 2, TRContent.Machine.HIGH_VOLTAGE_SU.block, EnergyTier.HIGH, 4_000_000);
|
super(TRBlockEntities.HIGH_VOLTAGE_SU, pos, state, "HIGH_VOLTAGE_SU", 2, TRContent.Machine.HIGH_VOLTAGE_SU.block, RcEnergyTier.HIGH, 4_000_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,7 +30,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import techreborn.init.TRContent;
|
||||||
public class LowVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
|
public class LowVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
public LowVoltageSUBlockEntity(BlockPos pos, BlockState state) {
|
public LowVoltageSUBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.LOW_VOLTAGE_SU, pos, state, "BatBox", 2, TRContent.Machine.LOW_VOLTAGE_SU.block, EnergyTier.LOW, 40_000);
|
super(TRBlockEntities.LOW_VOLTAGE_SU, pos, state, "BatBox", 2, TRContent.Machine.LOW_VOLTAGE_SU.block, RcEnergyTier.LOW, 40_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,7 +30,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class MediumVoltageSUBlockEntity extends EnergyStorageBlockEntity impleme
|
||||||
* MFE should store 300k energy with 128 E/t I/O
|
* MFE should store 300k energy with 128 E/t I/O
|
||||||
*/
|
*/
|
||||||
public MediumVoltageSUBlockEntity(BlockPos pos, BlockState state) {
|
public MediumVoltageSUBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.MEDIUM_VOLTAGE_SU, pos, state, "MEDIUM_VOLTAGE_SU", 2, TRContent.Machine.MEDIUM_VOLTAGE_SU.block, EnergyTier.MEDIUM, 300_000);
|
super(TRBlockEntities.MEDIUM_VOLTAGE_SU, pos, state, "MEDIUM_VOLTAGE_SU", 2, TRContent.Machine.MEDIUM_VOLTAGE_SU.block, RcEnergyTier.MEDIUM, 300_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class IDSUManager extends PersistentState {
|
||||||
|
|
||||||
public class IDSUPlayer implements NBTSerializable {
|
public class IDSUPlayer implements NBTSerializable {
|
||||||
|
|
||||||
private double energy;
|
private long energy;
|
||||||
|
|
||||||
private IDSUPlayer() {
|
private IDSUPlayer() {
|
||||||
}
|
}
|
||||||
|
@ -91,20 +91,20 @@ public class IDSUManager extends PersistentState {
|
||||||
@Override
|
@Override
|
||||||
public NbtCompound write() {
|
public NbtCompound write() {
|
||||||
NbtCompound tag = new NbtCompound();
|
NbtCompound tag = new NbtCompound();
|
||||||
tag.putDouble("energy", energy);
|
tag.putLong("energy", energy);
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(@NotNull NbtCompound tag) {
|
public void read(@NotNull NbtCompound tag) {
|
||||||
energy = tag.getDouble("energy");
|
energy = tag.getLong("energy");
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getEnergy() {
|
public long getEnergy() {
|
||||||
return energy;
|
return energy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnergy(double energy) {
|
public void setEnergy(long energy) {
|
||||||
this.energy = energy;
|
this.energy = energy;
|
||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
import team.reborn.energy.EnergySide;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.blockentity.storage.energy.EnergyStorageBlockEntity;
|
import techreborn.blockentity.storage.energy.EnergyStorageBlockEntity;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
|
@ -44,16 +43,16 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
||||||
public String ownerUdid;
|
public String ownerUdid;
|
||||||
|
|
||||||
//This is the energy value that is synced to the client
|
//This is the energy value that is synced to the client
|
||||||
private double clientEnergy;
|
private long clientEnergy;
|
||||||
|
|
||||||
public InterdimensionalSUBlockEntity(BlockPos pos, BlockState state) {
|
public InterdimensionalSUBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.INTERDIMENSIONAL_SU, pos, state, "IDSU", 2, TRContent.Machine.INTERDIMENSIONAL_SU.block, EnergyTier.INSANE, TechRebornConfig.idsuMaxEnergy);
|
super(TRBlockEntities.INTERDIMENSIONAL_SU, pos, state, "IDSU", 2, TRContent.Machine.INTERDIMENSIONAL_SU.block, RcEnergyTier.INSANE, TechRebornConfig.idsuMaxEnergy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getStored(EnergySide face) {
|
public long getStored() {
|
||||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||||
return 0.0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (world.isClient) {
|
if (world.isClient) {
|
||||||
return clientEnergy;
|
return clientEnergy;
|
||||||
|
@ -62,7 +61,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStored(double energy) {
|
public void setStored(long energy) {
|
||||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -74,14 +73,14 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void useEnergy(double extract) {
|
public void useEnergy(long extract) {
|
||||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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.getServer(), ownerUdid).getEnergy();
|
long energy = IDSUManager.getPlayer(world.getServer(), ownerUdid).getEnergy();
|
||||||
if (extract > energy) {
|
if (extract > energy) {
|
||||||
extract = energy;
|
extract = energy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.blockentity.storage.energy.EnergyStorageBlockEntity;
|
import techreborn.blockentity.storage.energy.EnergyStorageBlockEntity;
|
||||||
import techreborn.blocks.storage.energy.LapotronicSUBlock;
|
import techreborn.blocks.storage.energy.LapotronicSUBlock;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -50,7 +50,7 @@ public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
private final ArrayList<LesuNetwork> countedNetworks = new ArrayList<>();
|
private final ArrayList<LesuNetwork> countedNetworks = new ArrayList<>();
|
||||||
|
|
||||||
public LapotronicSUBlockEntity(BlockPos pos, BlockState state) {
|
public LapotronicSUBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.LAPOTRONIC_SU, pos, state, "LESU", 2, TRContent.Machine.LAPOTRONIC_SU.block, EnergyTier.LOW, TechRebornConfig.lesuStoragePerBlock);
|
super(TRBlockEntities.LAPOTRONIC_SU, pos, state, "LESU", 2, TRContent.Machine.LAPOTRONIC_SU.block, RcEnergyTier.LOW, TechRebornConfig.lesuStoragePerBlock);
|
||||||
checkOverfill = false;
|
checkOverfill = false;
|
||||||
this.maxOutput = TechRebornConfig.lesuBaseOutput;
|
this.maxOutput = TechRebornConfig.lesuBaseOutput;
|
||||||
}
|
}
|
||||||
|
@ -67,9 +67,9 @@ public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
if (connectedBlocks < 32) {
|
if (connectedBlocks < 32) {
|
||||||
return;
|
return;
|
||||||
} else if (connectedBlocks < 128) {
|
} else if (connectedBlocks < 128) {
|
||||||
maxInput = EnergyTier.MEDIUM.getMaxInput();
|
maxInput = RcEnergyTier.MEDIUM.getMaxInput();
|
||||||
} else {
|
} else {
|
||||||
maxInput = EnergyTier.HIGH.getMaxInput();
|
maxInput = RcEnergyTier.HIGH.getMaxInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ package techreborn.blockentity.transformers;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import techreborn.init.TRContent;
|
||||||
public class EVTransformerBlockEntity extends TransformerBlockEntity {
|
public class EVTransformerBlockEntity extends TransformerBlockEntity {
|
||||||
|
|
||||||
public EVTransformerBlockEntity(BlockPos pos, BlockState state) {
|
public EVTransformerBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.EV_TRANSFORMER, pos, state, "EVTransformer", TRContent.Machine.EV_TRANSFORMER.block, EnergyTier.INSANE);
|
super(TRBlockEntities.EV_TRANSFORMER, pos, state, "EVTransformer", TRContent.Machine.EV_TRANSFORMER.block, RcEnergyTier.INSANE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ package techreborn.blockentity.transformers;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import techreborn.init.TRContent;
|
||||||
public class HVTransformerBlockEntity extends TransformerBlockEntity {
|
public class HVTransformerBlockEntity extends TransformerBlockEntity {
|
||||||
|
|
||||||
public HVTransformerBlockEntity(BlockPos pos, BlockState state) {
|
public HVTransformerBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.HV_TRANSFORMER, pos, state, "HVTransformer", TRContent.Machine.HV_TRANSFORMER.block, EnergyTier.EXTREME);
|
super(TRBlockEntities.HV_TRANSFORMER, pos, state, "HVTransformer", TRContent.Machine.HV_TRANSFORMER.block, RcEnergyTier.EXTREME);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ package techreborn.blockentity.transformers;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import techreborn.init.TRContent;
|
||||||
public class LVTransformerBlockEntity extends TransformerBlockEntity {
|
public class LVTransformerBlockEntity extends TransformerBlockEntity {
|
||||||
|
|
||||||
public LVTransformerBlockEntity(BlockPos pos, BlockState state) {
|
public LVTransformerBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.LV_TRANSFORMER, pos, state, "LVTransformer", TRContent.Machine.LV_TRANSFORMER.block, EnergyTier.MEDIUM);
|
super(TRBlockEntities.LV_TRANSFORMER, pos, state, "LVTransformer", TRContent.Machine.LV_TRANSFORMER.block, RcEnergyTier.MEDIUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ package techreborn.blockentity.transformers;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
|
@ -36,6 +36,6 @@ import techreborn.init.TRContent;
|
||||||
public class MVTransformerBlockEntity extends TransformerBlockEntity {
|
public class MVTransformerBlockEntity extends TransformerBlockEntity {
|
||||||
|
|
||||||
public MVTransformerBlockEntity(BlockPos pos, BlockState state) {
|
public MVTransformerBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.MV_TRANSFORMER, pos, state, "MVTransformer", TRContent.Machine.MV_TRANSFORMER.block, EnergyTier.HIGH);
|
super(TRBlockEntities.MV_TRANSFORMER, pos, state, "MVTransformer", TRContent.Machine.MV_TRANSFORMER.block, RcEnergyTier.HIGH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,13 +34,13 @@ import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IListInfoProvider;
|
import reborncore.api.IListInfoProvider;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.util.StringUtils;
|
import reborncore.common.util.StringUtils;
|
||||||
import team.reborn.energy.EnergySide;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.blocks.transformers.BlockTransformer;
|
import techreborn.blocks.transformers.BlockTransformer;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
|
||||||
|
@ -53,20 +53,20 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public Block wrenchDrop;
|
public Block wrenchDrop;
|
||||||
public EnergyTier inputTier;
|
public RcEnergyTier inputTier;
|
||||||
public EnergyTier outputTier;
|
public RcEnergyTier outputTier;
|
||||||
public int maxInput;
|
public int maxInput;
|
||||||
public int maxOutput;
|
public int maxOutput;
|
||||||
public int maxStorage;
|
public int maxStorage;
|
||||||
|
|
||||||
public TransformerBlockEntity(BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state, String name, Block wrenchDrop, EnergyTier tier) {
|
public TransformerBlockEntity(BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state, String name, Block wrenchDrop, RcEnergyTier tier) {
|
||||||
super(blockEntityType, pos, state);
|
super(blockEntityType, pos, state);
|
||||||
this.wrenchDrop = wrenchDrop;
|
this.wrenchDrop = wrenchDrop;
|
||||||
this.inputTier = tier;
|
this.inputTier = tier;
|
||||||
if (tier != EnergyTier.MICRO) {
|
if (tier != RcEnergyTier.MICRO) {
|
||||||
outputTier = EnergyTier.values()[tier.ordinal() - 1];
|
outputTier = RcEnergyTier.values()[tier.ordinal() - 1];
|
||||||
} else {
|
} else {
|
||||||
outputTier = EnergyTier.MICRO;
|
outputTier = RcEnergyTier.MICRO;
|
||||||
}
|
}
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.maxInput = tier.getMaxInput();
|
this.maxInput = tier.getMaxInput();
|
||||||
|
@ -77,39 +77,39 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
|
|
||||||
// PowerAcceptorBlockEntity
|
// PowerAcceptorBlockEntity
|
||||||
@Override
|
@Override
|
||||||
protected boolean canAcceptEnergy(EnergySide side) {
|
protected boolean canAcceptEnergy(@Nullable Direction side) {
|
||||||
if (side == EnergySide.UNKNOWN) {
|
if (side == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (TechRebornConfig.IC2TransformersStyle) {
|
if (TechRebornConfig.IC2TransformersStyle) {
|
||||||
return getFacing() == Direction.values()[side.ordinal()];
|
return getFacing() == side;
|
||||||
}
|
}
|
||||||
return getFacing() != Direction.values()[side.ordinal()];
|
return getFacing() != side;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canProvideEnergy(EnergySide side) {
|
protected boolean canProvideEnergy(@Nullable Direction side) {
|
||||||
if (side == EnergySide.UNKNOWN) {
|
if (side == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (TechRebornConfig.IC2TransformersStyle) {
|
if (TechRebornConfig.IC2TransformersStyle) {
|
||||||
return getFacing() != Direction.values()[side.ordinal()];
|
return getFacing() != side;
|
||||||
}
|
}
|
||||||
return getFacing() == Direction.values()[side.ordinal()];
|
return getFacing() == side;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public long getBaseMaxPower() {
|
||||||
return maxStorage;
|
return maxStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public long getBaseMaxOutput() {
|
||||||
return outputTier.getMaxOutput();
|
return outputTier.getMaxOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public long getBaseMaxInput() {
|
||||||
return inputTier.getMaxInput();
|
return inputTier.getMaxInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
new TranslatableText("reborncore.tooltip.energy.inputRate")
|
new TranslatableText("reborncore.tooltip.energy.inputRate")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(": ")
|
.append(": ")
|
||||||
.append(PowerSystem.getLocalizedPower(getMaxInput(EnergySide.UNKNOWN)))
|
.append(PowerSystem.getLocalizedPower(getMaxInput(null)))
|
||||||
.formatted(Formatting.GOLD)
|
.formatted(Formatting.GOLD)
|
||||||
);
|
);
|
||||||
info.add(
|
info.add(
|
||||||
|
@ -163,7 +163,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
new TranslatableText("reborncore.tooltip.energy.outputRate")
|
new TranslatableText("reborncore.tooltip.energy.outputRate")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(": ")
|
.append(": ")
|
||||||
.append(PowerSystem.getLocalizedPower(getMaxOutput(EnergySide.UNKNOWN)))
|
.append(PowerSystem.getLocalizedPower(getMaxOutput(null)))
|
||||||
.formatted(Formatting.GOLD)
|
.formatted(Formatting.GOLD)
|
||||||
);
|
);
|
||||||
info.add(
|
info.add(
|
||||||
|
|
|
@ -37,6 +37,7 @@ import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
|
@ -58,7 +59,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.ToolManager;
|
import reborncore.api.ToolManager;
|
||||||
import reborncore.common.blocks.BlockWrenchEventHandler;
|
import reborncore.common.blocks.BlockWrenchEventHandler;
|
||||||
import reborncore.common.util.WrenchUtils;
|
import reborncore.common.util.WrenchUtils;
|
||||||
import team.reborn.energy.Energy;
|
import team.reborn.energy.api.EnergyStorage;
|
||||||
import techreborn.api.events.CableElectrocutionEvent;
|
import techreborn.api.events.CableElectrocutionEvent;
|
||||||
import techreborn.blockentity.cable.CableBlockEntity;
|
import techreborn.blockentity.cable.CableBlockEntity;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -116,20 +117,25 @@ public class CableBlock extends BlockWithEntity implements Waterloggable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockState makeConnections(World world, BlockPos pos) {
|
private BlockState makeConnections(World world, BlockPos pos) {
|
||||||
Boolean down = canConnectTo(world, pos.down());
|
Boolean down = canConnectTo(world, pos, Direction.DOWN);
|
||||||
Boolean up = canConnectTo(world, pos.up());
|
Boolean up = canConnectTo(world, pos, Direction.UP);
|
||||||
Boolean north = canConnectTo(world, pos.north());
|
Boolean north = canConnectTo(world, pos, Direction.NORTH);
|
||||||
Boolean east = canConnectTo(world, pos.east());
|
Boolean east = canConnectTo(world, pos, Direction.EAST);
|
||||||
Boolean south = canConnectTo(world, pos.south());
|
Boolean south = canConnectTo(world, pos, Direction.SOUTH);
|
||||||
Boolean west = canConnectTo(world, pos.west());
|
Boolean west = canConnectTo(world, pos, Direction.WEST);
|
||||||
|
|
||||||
return this.getDefaultState().with(DOWN, down).with(UP, up).with(NORTH, north).with(EAST, east)
|
return this.getDefaultState().with(DOWN, down).with(UP, up).with(NORTH, north).with(EAST, east)
|
||||||
.with(SOUTH, south).with(WEST, west);
|
.with(SOUTH, south).with(WEST, west);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean canConnectTo(WorldAccess world, BlockPos pos) {
|
private Boolean canConnectTo(WorldAccess world, BlockPos currentPos, Direction side) {
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
BlockPos adjPos = currentPos.offset(side);
|
||||||
if (blockEntity != null && (Energy.valid(blockEntity) || blockEntity instanceof CableBlockEntity)) {
|
BlockEntity adjBe = world.getBlockEntity(adjPos);
|
||||||
|
if (adjBe instanceof CableBlockEntity) {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
// TODO: this doesn't work at all, fix this
|
||||||
|
else if (world instanceof ServerWorld sw && EnergyStorage.SIDED.find(sw, adjPos, null, adjBe, side.getOpposite()) != null) {
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
|
@ -210,13 +216,13 @@ public class CableBlock extends BlockWithEntity implements Waterloggable {
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState ourState, Direction ourFacing, BlockState otherState,
|
public BlockState getStateForNeighborUpdate(BlockState ourState, Direction direction, BlockState otherState,
|
||||||
WorldAccess worldIn, BlockPos ourPos, BlockPos otherPos) {
|
WorldAccess worldIn, BlockPos ourPos, BlockPos otherPos) {
|
||||||
if (ourState.get(WATERLOGGED)) {
|
if (ourState.get(WATERLOGGED)) {
|
||||||
worldIn.getFluidTickScheduler().schedule(ourPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
|
worldIn.getFluidTickScheduler().schedule(ourPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
|
||||||
}
|
}
|
||||||
Boolean value = canConnectTo(worldIn, otherPos);
|
Boolean value = canConnectTo(worldIn, otherPos, direction);
|
||||||
return ourState.with(getProperty(ourFacing), value);
|
return ourState.with(getProperty(direction), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -260,7 +266,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable {
|
||||||
entity.setOnFireFor(1);
|
entity.setOnFireFor(1);
|
||||||
}
|
}
|
||||||
entity.damage(new ElectrialShockSource(), 1F);
|
entity.damage(new ElectrialShockSource(), 1F);
|
||||||
blockEntityCable.setEnergy(0d);
|
blockEntityCable.setEnergy(0);
|
||||||
}
|
}
|
||||||
if (TechRebornConfig.uninsulatedElectrocutionSound) {
|
if (TechRebornConfig.uninsulatedElectrocutionSound) {
|
||||||
world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), ModSounds.CABLE_SHOCK, SoundCategory.BLOCKS,
|
world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), ModSounds.CABLE_SHOCK, SoundCategory.BLOCKS,
|
||||||
|
|
|
@ -46,7 +46,6 @@ import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.common.util.WorldUtils;
|
import reborncore.common.util.WorldUtils;
|
||||||
import team.reborn.energy.Energy;
|
|
||||||
import techreborn.events.TRRecipeHandler;
|
import techreborn.events.TRRecipeHandler;
|
||||||
import techreborn.init.ModSounds;
|
import techreborn.init.ModSounds;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -135,15 +134,15 @@ public class BlockRubberLog extends PillarBlock {
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Energy.valid(stack) && Energy.of(stack).getEnergy() > 20 && stack.getItem() instanceof ElectricTreetapItem) || stack.getItem() instanceof TreeTapItem) {
|
if ((stack.getItem() instanceof ElectricTreetapItem item && item.getStoredEnergy(stack) > 20) || stack.getItem() instanceof TreeTapItem) {
|
||||||
if (state.get(HAS_SAP) && state.get(SAP_SIDE) == hitResult.getSide()) {
|
if (state.get(HAS_SAP) && state.get(SAP_SIDE) == hitResult.getSide()) {
|
||||||
worldIn.setBlockState(pos, state.with(HAS_SAP, false).with(SAP_SIDE, Direction.fromHorizontal(0)));
|
worldIn.setBlockState(pos, state.with(HAS_SAP, false).with(SAP_SIDE, Direction.fromHorizontal(0)));
|
||||||
worldIn.playSound(playerIn, pos, ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS, 0.6F, 1F);
|
worldIn.playSound(playerIn, pos, ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS, 0.6F, 1F);
|
||||||
if (worldIn.isClient) {
|
if (worldIn.isClient) {
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
if (Energy.valid(stack)) {
|
if (stack.getItem() instanceof ElectricTreetapItem item) {
|
||||||
Energy.of(stack).use(20);
|
item.tryUseEnergy(stack, 20);
|
||||||
} else {
|
} else {
|
||||||
stack.damage(1, playerIn, player -> player.sendToolBreakStatus(hand));
|
stack.damage(1, playerIn, player -> player.sendToolBreakStatus(hand));
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class TechRebornConfig {
|
||||||
public static int plasmaGeneratorMaxOutput = 2048;
|
public static int plasmaGeneratorMaxOutput = 2048;
|
||||||
|
|
||||||
@Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxEnergy", comment = "Plasma Generator Max Energy")
|
@Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxEnergy", comment = "Plasma Generator Max Energy")
|
||||||
public static double plasmaGeneratorMaxEnergy = 500_000_000;
|
public static long plasmaGeneratorMaxEnergy = 500_000_000;
|
||||||
|
|
||||||
@Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorEnergyPerTick", comment = "Plasma Generator Energy Per Tick")
|
@Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorEnergyPerTick", comment = "Plasma Generator Energy Per Tick")
|
||||||
public static int plasmaGeneratorEnergyPerTick = 400;
|
public static int plasmaGeneratorEnergyPerTick = 400;
|
||||||
|
@ -275,22 +275,22 @@ public class TechRebornConfig {
|
||||||
public static int cloackingDeviceCost = 10;
|
public static int cloackingDeviceCost = 10;
|
||||||
|
|
||||||
@Config(config = "items", category = "power", key = "quantumSuitCapacity", comment = "Quantum Suit Energy Capacity")
|
@Config(config = "items", category = "power", key = "quantumSuitCapacity", comment = "Quantum Suit Energy Capacity")
|
||||||
public static double quantumSuitCapacity = 40_000_000;
|
public static long quantumSuitCapacity = 40_000_000;
|
||||||
|
|
||||||
@Config(config = "items", category = "power", key = "quantumSuitFlyingCost", comment = "Quantum Suit Flying Cost")
|
@Config(config = "items", category = "power", key = "quantumSuitFlyingCost", comment = "Quantum Suit Flying Cost")
|
||||||
public static double quantumSuitFlyingCost = 50;
|
public static long quantumSuitFlyingCost = 50;
|
||||||
|
|
||||||
@Config(config = "items", category = "power", key = "quantumSuitSwimmingCost", comment = "Quantum Suit Swimming Cost")
|
@Config(config = "items", category = "power", key = "quantumSuitSwimmingCost", comment = "Quantum Suit Swimming Cost")
|
||||||
public static double quantumSuitSwimmingCost = 20;
|
public static long quantumSuitSwimmingCost = 20;
|
||||||
|
|
||||||
@Config(config = "items", category = "power", key = "quantumSuitBreathingCost", comment = "Quantum Suit Breathing Cost")
|
@Config(config = "items", category = "power", key = "quantumSuitBreathingCost", comment = "Quantum Suit Breathing Cost")
|
||||||
public static double quantumSuitBreathingCost = 20;
|
public static long quantumSuitBreathingCost = 20;
|
||||||
|
|
||||||
@Config(config = "items", category = "power", key = "quantumSuitSprintingCost", comment = "Quantum Suit Sprinting Cost")
|
@Config(config = "items", category = "power", key = "quantumSuitSprintingCost", comment = "Quantum Suit Sprinting Cost")
|
||||||
public static double quantumSuitSprintingCost = 20;
|
public static long quantumSuitSprintingCost = 20;
|
||||||
|
|
||||||
@Config(config = "items", category = "power", key = "quantumSuitFireExtinguishCost", comment = "Quantum Suit Cost for Fire Extinguish")
|
@Config(config = "items", category = "power", key = "quantumSuitFireExtinguishCost", comment = "Quantum Suit Cost for Fire Extinguish")
|
||||||
public static double fireExtinguishCost = 50;
|
public static long fireExtinguishCost = 50;
|
||||||
|
|
||||||
@Config(config = "items", category = "power", key = "quantumSuitEnableSprint", comment = "Enable Sprint Speed increase for Quantum Legs")
|
@Config(config = "items", category = "power", key = "quantumSuitEnableSprint", comment = "Enable Sprint Speed increase for Quantum Legs")
|
||||||
public static boolean quantumSuitEnableSprint = true;
|
public static boolean quantumSuitEnableSprint = true;
|
||||||
|
|
|
@ -28,7 +28,6 @@ import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import reborncore.api.events.ApplyArmorToDamageCallback;
|
import reborncore.api.events.ApplyArmorToDamageCallback;
|
||||||
import team.reborn.energy.Energy;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.items.armor.QuantumSuitItem;
|
import techreborn.items.armor.QuantumSuitItem;
|
||||||
|
|
||||||
|
@ -42,17 +41,17 @@ public class ApplyArmorToDamageHandler implements ApplyArmorToDamageCallback {
|
||||||
public float applyArmorToDamage(PlayerEntity player, DamageSource source, float amount) {
|
public float applyArmorToDamage(PlayerEntity player, DamageSource source, float amount) {
|
||||||
double damageAbsorbed = 0.0d;
|
double damageAbsorbed = 0.0d;
|
||||||
for (ItemStack stack : player.getArmorItems()) {
|
for (ItemStack stack : player.getArmorItems()) {
|
||||||
if (!(stack.getItem() instanceof QuantumSuitItem)) {
|
if (!(stack.getItem() instanceof QuantumSuitItem item)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double stackEnergy = Energy.of(stack).getEnergy();
|
double stackEnergy = item.getStoredEnergy(stack);
|
||||||
if (stackEnergy == 0.0d) {
|
if (stackEnergy == 0.0d) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double damageToAbsorb = Math.min(stackEnergy, amount * 0.2d);
|
double damageToAbsorb = Math.min(stackEnergy, amount * 0.2d);
|
||||||
if (Energy.of(stack).use(damageToAbsorb * TechRebornConfig.damageAbsorbCost)) {
|
if (item.tryUseEnergy(stack, (long) (damageToAbsorb * TechRebornConfig.damageAbsorbCost))) {
|
||||||
damageAbsorbed += damageToAbsorb;
|
damageAbsorbed += damageToAbsorb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,11 @@ import net.minecraft.item.Items;
|
||||||
import net.minecraft.item.ToolMaterials;
|
import net.minecraft.item.ToolMaterials;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.sound.BlockSoundGroup;
|
||||||
import reborncore.RebornRegistry;
|
import reborncore.RebornRegistry;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
|
import team.reborn.energy.api.EnergyStorage;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
|
import techreborn.blockentity.cable.CableBlockEntity;
|
||||||
import techreborn.blocks.misc.*;
|
import techreborn.blocks.misc.*;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.*;
|
import techreborn.init.*;
|
||||||
|
@ -65,6 +68,7 @@ public class ModRegistry {
|
||||||
registerItems();
|
registerItems();
|
||||||
registerFluids();
|
registerFluids();
|
||||||
registerSounds();
|
registerSounds();
|
||||||
|
registerApis();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerBlocks() {
|
private static void registerBlocks() {
|
||||||
|
@ -170,26 +174,26 @@ public class ModRegistry {
|
||||||
RebornRegistry.registerItem(TRContent.PERIDOT_BOOTS = InitUtils.setup(new TRArmourItem(TRArmorMaterials.PERIDOT, EquipmentSlot.FEET), "peridot_boots"));
|
RebornRegistry.registerItem(TRContent.PERIDOT_BOOTS = InitUtils.setup(new TRArmourItem(TRArmorMaterials.PERIDOT, EquipmentSlot.FEET), "peridot_boots"));
|
||||||
|
|
||||||
// Battery
|
// Battery
|
||||||
RebornRegistry.registerItem(TRContent.RED_CELL_BATTERY = InitUtils.setup(new BatteryItem(TechRebornConfig.redCellBatteryMaxCharge, EnergyTier.LOW), "red_cell_battery"));
|
RebornRegistry.registerItem(TRContent.RED_CELL_BATTERY = InitUtils.setup(new BatteryItem(TechRebornConfig.redCellBatteryMaxCharge, RcEnergyTier.LOW), "red_cell_battery"));
|
||||||
RebornRegistry.registerItem(TRContent.LITHIUM_ION_BATTERY = InitUtils.setup(new BatteryItem(TechRebornConfig.lithiumIonBatteryMaxCharge, EnergyTier.MEDIUM), "lithium_ion_battery"));
|
RebornRegistry.registerItem(TRContent.LITHIUM_ION_BATTERY = InitUtils.setup(new BatteryItem(TechRebornConfig.lithiumIonBatteryMaxCharge, RcEnergyTier.MEDIUM), "lithium_ion_battery"));
|
||||||
RebornRegistry.registerItem(TRContent.LITHIUM_ION_BATPACK = InitUtils.setup(new BatpackItem(TechRebornConfig.lithiumBatpackCharge, TRArmorMaterials.LITHIUM_BATPACK, EnergyTier.MEDIUM), "lithium_ion_batpack"));
|
RebornRegistry.registerItem(TRContent.LITHIUM_ION_BATPACK = InitUtils.setup(new BatpackItem(TechRebornConfig.lithiumBatpackCharge, TRArmorMaterials.LITHIUM_BATPACK, RcEnergyTier.MEDIUM), "lithium_ion_batpack"));
|
||||||
RebornRegistry.registerItem(TRContent.ENERGY_CRYSTAL = InitUtils.setup(new BatteryItem(TechRebornConfig.energyCrystalMaxCharge, EnergyTier.HIGH), "energy_crystal"));
|
RebornRegistry.registerItem(TRContent.ENERGY_CRYSTAL = InitUtils.setup(new BatteryItem(TechRebornConfig.energyCrystalMaxCharge, RcEnergyTier.HIGH), "energy_crystal"));
|
||||||
RebornRegistry.registerItem(TRContent.LAPOTRON_CRYSTAL = InitUtils.setup(new BatteryItem(TechRebornConfig.lapotronCrystalMaxCharge, EnergyTier.EXTREME), "lapotron_crystal"));
|
RebornRegistry.registerItem(TRContent.LAPOTRON_CRYSTAL = InitUtils.setup(new BatteryItem(TechRebornConfig.lapotronCrystalMaxCharge, RcEnergyTier.EXTREME), "lapotron_crystal"));
|
||||||
RebornRegistry.registerItem(TRContent.LAPOTRONIC_ORB = InitUtils.setup(new BatteryItem(TechRebornConfig.lapotronicOrbMaxCharge, EnergyTier.INSANE), "lapotronic_orb"));
|
RebornRegistry.registerItem(TRContent.LAPOTRONIC_ORB = InitUtils.setup(new BatteryItem(TechRebornConfig.lapotronicOrbMaxCharge, RcEnergyTier.INSANE), "lapotronic_orb"));
|
||||||
RebornRegistry.registerItem(TRContent.LAPOTRONIC_ORBPACK = InitUtils.setup(new BatpackItem(TechRebornConfig.lapotronPackCharge, TRArmorMaterials.LAPOTRONIC_ORBPACK, EnergyTier.INSANE), "lapotronic_orbpack"));
|
RebornRegistry.registerItem(TRContent.LAPOTRONIC_ORBPACK = InitUtils.setup(new BatpackItem(TechRebornConfig.lapotronPackCharge, TRArmorMaterials.LAPOTRONIC_ORBPACK, RcEnergyTier.INSANE), "lapotronic_orbpack"));
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
RebornRegistry.registerItem(TRContent.TREE_TAP = InitUtils.setup(new TreeTapItem(), "treetap"));
|
RebornRegistry.registerItem(TRContent.TREE_TAP = InitUtils.setup(new TreeTapItem(), "treetap"));
|
||||||
RebornRegistry.registerItem(TRContent.WRENCH = InitUtils.setup(new WrenchItem(), "wrench"));
|
RebornRegistry.registerItem(TRContent.WRENCH = InitUtils.setup(new WrenchItem(), "wrench"));
|
||||||
RebornRegistry.registerItem(TRContent.PAINTING_TOOL = InitUtils.setup(new PaintingToolItem(), "painting_tool"));
|
RebornRegistry.registerItem(TRContent.PAINTING_TOOL = InitUtils.setup(new PaintingToolItem(), "painting_tool"));
|
||||||
|
|
||||||
RebornRegistry.registerItem(TRContent.BASIC_DRILL = InitUtils.setup(new DrillItem(ToolMaterials.IRON, TechRebornConfig.basicDrillCharge, EnergyTier.MEDIUM, TechRebornConfig.basicDrillCost, 6F, -.5F, MiningLevel.IRON), "basic_drill"));
|
RebornRegistry.registerItem(TRContent.BASIC_DRILL = InitUtils.setup(new DrillItem(ToolMaterials.IRON, TechRebornConfig.basicDrillCharge, RcEnergyTier.MEDIUM, TechRebornConfig.basicDrillCost, 6F, -.5F, MiningLevel.IRON), "basic_drill"));
|
||||||
RebornRegistry.registerItem(TRContent.BASIC_CHAINSAW = InitUtils.setup(new ChainsawItem(ToolMaterials.IRON, TechRebornConfig.basicChainsawCharge, EnergyTier.MEDIUM, TechRebornConfig.basicChainsawCost, 20F, 0.5F, Items.IRON_AXE), "basic_chainsaw"));
|
RebornRegistry.registerItem(TRContent.BASIC_CHAINSAW = InitUtils.setup(new ChainsawItem(ToolMaterials.IRON, TechRebornConfig.basicChainsawCharge, RcEnergyTier.MEDIUM, TechRebornConfig.basicChainsawCost, 20F, 0.5F, Items.IRON_AXE), "basic_chainsaw"));
|
||||||
RebornRegistry.registerItem(TRContent.BASIC_JACKHAMMER = InitUtils.setup(new JackhammerItem(TechRebornConfig.basicJackhammerCharge, EnergyTier.MEDIUM, TechRebornConfig.basicJackhammerCost), "basic_jackhammer"));
|
RebornRegistry.registerItem(TRContent.BASIC_JACKHAMMER = InitUtils.setup(new JackhammerItem(TechRebornConfig.basicJackhammerCharge, RcEnergyTier.MEDIUM, TechRebornConfig.basicJackhammerCost), "basic_jackhammer"));
|
||||||
RebornRegistry.registerItem(TRContent.ELECTRIC_TREE_TAP = InitUtils.setup(new ElectricTreetapItem(), "electric_treetap"));
|
RebornRegistry.registerItem(TRContent.ELECTRIC_TREE_TAP = InitUtils.setup(new ElectricTreetapItem(), "electric_treetap"));
|
||||||
|
|
||||||
RebornRegistry.registerItem(TRContent.ADVANCED_DRILL = InitUtils.setup(new DrillItem(ToolMaterials.DIAMOND, TechRebornConfig.advancedDrillCharge, EnergyTier.EXTREME, TechRebornConfig.advancedDrillCost, 12F, 0.2F, MiningLevel.DIAMOND), "advanced_drill"));
|
RebornRegistry.registerItem(TRContent.ADVANCED_DRILL = InitUtils.setup(new DrillItem(ToolMaterials.DIAMOND, TechRebornConfig.advancedDrillCharge, RcEnergyTier.EXTREME, TechRebornConfig.advancedDrillCost, 12F, 0.2F, MiningLevel.DIAMOND), "advanced_drill"));
|
||||||
RebornRegistry.registerItem(TRContent.ADVANCED_CHAINSAW = InitUtils.setup(new ChainsawItem(ToolMaterials.DIAMOND, TechRebornConfig.advancedChainsawCharge, EnergyTier.EXTREME, TechRebornConfig.advancedChainsawCost, 20F, 1.0F, Items.DIAMOND_AXE), "advanced_chainsaw"));
|
RebornRegistry.registerItem(TRContent.ADVANCED_CHAINSAW = InitUtils.setup(new ChainsawItem(ToolMaterials.DIAMOND, TechRebornConfig.advancedChainsawCharge, RcEnergyTier.EXTREME, TechRebornConfig.advancedChainsawCost, 20F, 1.0F, Items.DIAMOND_AXE), "advanced_chainsaw"));
|
||||||
RebornRegistry.registerItem(TRContent.ADVANCED_JACKHAMMER = InitUtils.setup(new AdvancedJackhammerItem(), "advanced_jackhammer"));
|
RebornRegistry.registerItem(TRContent.ADVANCED_JACKHAMMER = InitUtils.setup(new AdvancedJackhammerItem(), "advanced_jackhammer"));
|
||||||
RebornRegistry.registerItem(TRContent.ROCK_CUTTER = InitUtils.setup(new RockCutterItem(), "rock_cutter"));
|
RebornRegistry.registerItem(TRContent.ROCK_CUTTER = InitUtils.setup(new RockCutterItem(), "rock_cutter"));
|
||||||
|
|
||||||
|
@ -227,4 +231,8 @@ public class ModRegistry {
|
||||||
ModSounds.MACHINE_START = InitUtils.setup("machine_start");
|
ModSounds.MACHINE_START = InitUtils.setup("machine_start");
|
||||||
ModSounds.SAP_EXTRACT = InitUtils.setup("sap_extract");
|
ModSounds.SAP_EXTRACT = InitUtils.setup("sap_extract");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void registerApis() {
|
||||||
|
EnergyStorage.SIDED.registerForBlockEntities((be, direction) -> ((CableBlockEntity) be).getSideEnergyStorage(direction), TRBlockEntities.CABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,9 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.blockentity.IUpgrade;
|
import reborncore.api.blockentity.IUpgrade;
|
||||||
import reborncore.common.fluid.FluidValue;
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import team.reborn.energy.EnergySide;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.blockentity.generator.LightningRodBlockEntity;
|
import techreborn.blockentity.generator.LightningRodBlockEntity;
|
||||||
import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
|
import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
|
||||||
|
@ -238,12 +239,12 @@ public class TRContent {
|
||||||
public static Item PERIDOT_BOOTS;
|
public static Item PERIDOT_BOOTS;
|
||||||
|
|
||||||
public enum SolarPanels implements ItemConvertible {
|
public enum SolarPanels implements ItemConvertible {
|
||||||
BASIC(EnergyTier.MICRO, TechRebornConfig.basicGenerationRateD, TechRebornConfig.basicGenerationRateN),
|
BASIC(RcEnergyTier.MICRO, TechRebornConfig.basicGenerationRateD, TechRebornConfig.basicGenerationRateN),
|
||||||
ADVANCED(EnergyTier.LOW, TechRebornConfig.advancedGenerationRateD, TechRebornConfig.advancedGenerationRateN),
|
ADVANCED(RcEnergyTier.LOW, TechRebornConfig.advancedGenerationRateD, TechRebornConfig.advancedGenerationRateN),
|
||||||
INDUSTRIAL(EnergyTier.MEDIUM, TechRebornConfig.industrialGenerationRateD, TechRebornConfig.industrialGenerationRateN),
|
INDUSTRIAL(RcEnergyTier.MEDIUM, TechRebornConfig.industrialGenerationRateD, TechRebornConfig.industrialGenerationRateN),
|
||||||
ULTIMATE(EnergyTier.HIGH, TechRebornConfig.ultimateGenerationRateD, TechRebornConfig.ultimateGenerationRateN),
|
ULTIMATE(RcEnergyTier.HIGH, TechRebornConfig.ultimateGenerationRateD, TechRebornConfig.ultimateGenerationRateN),
|
||||||
QUANTUM(EnergyTier.EXTREME, TechRebornConfig.quantumGenerationRateD, TechRebornConfig.quantumGenerationRateN),
|
QUANTUM(RcEnergyTier.EXTREME, TechRebornConfig.quantumGenerationRateD, TechRebornConfig.quantumGenerationRateN),
|
||||||
CREATIVE(EnergyTier.INFINITE, Integer.MAX_VALUE / 100, Integer.MAX_VALUE / 100);
|
CREATIVE(RcEnergyTier.INFINITE, Integer.MAX_VALUE / 100, Integer.MAX_VALUE / 100);
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final Block block;
|
public final Block block;
|
||||||
|
@ -254,9 +255,9 @@ public class TRContent {
|
||||||
public int generationRateN;
|
public int generationRateN;
|
||||||
// Internal EU storage of solar panel
|
// Internal EU storage of solar panel
|
||||||
public int internalCapacity;
|
public int internalCapacity;
|
||||||
public final EnergyTier powerTier;
|
public final RcEnergyTier powerTier;
|
||||||
|
|
||||||
SolarPanels(EnergyTier tier, int generationRateD, int generationRateN) {
|
SolarPanels(RcEnergyTier tier, int generationRateD, int generationRateN) {
|
||||||
name = this.toString().toLowerCase(Locale.ROOT);
|
name = this.toString().toLowerCase(Locale.ROOT);
|
||||||
powerTier = tier;
|
powerTier = tier;
|
||||||
block = new BlockSolarPanel(this);
|
block = new BlockSolarPanel(this);
|
||||||
|
@ -332,15 +333,15 @@ public class TRContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Cables implements ItemConvertible {
|
public enum Cables implements ItemConvertible {
|
||||||
COPPER(128, 12.0, true, EnergyTier.MEDIUM),
|
COPPER(128, 12.0, true, RcEnergyTier.MEDIUM),
|
||||||
TIN(32, 12.0, true, EnergyTier.LOW),
|
TIN(32, 12.0, true, RcEnergyTier.LOW),
|
||||||
GOLD(512, 12.0, true, EnergyTier.HIGH),
|
GOLD(512, 12.0, true, RcEnergyTier.HIGH),
|
||||||
HV(2048, 12.0, true, EnergyTier.EXTREME),
|
HV(2048, 12.0, true, RcEnergyTier.EXTREME),
|
||||||
GLASSFIBER(8192, 12.0, false, EnergyTier.INSANE),
|
GLASSFIBER(8192, 12.0, false, RcEnergyTier.INSANE),
|
||||||
INSULATED_COPPER(128, 10.0, false, EnergyTier.MEDIUM),
|
INSULATED_COPPER(128, 10.0, false, RcEnergyTier.MEDIUM),
|
||||||
INSULATED_GOLD(512, 10.0, false, EnergyTier.HIGH),
|
INSULATED_GOLD(512, 10.0, false, RcEnergyTier.HIGH),
|
||||||
INSULATED_HV(2048, 10.0, false, EnergyTier.EXTREME),
|
INSULATED_HV(2048, 10.0, false, RcEnergyTier.EXTREME),
|
||||||
SUPERCONDUCTOR(Integer.MAX_VALUE / 4, 10.0, false, EnergyTier.INFINITE);
|
SUPERCONDUCTOR(Integer.MAX_VALUE / 4, 10.0, false, RcEnergyTier.INFINITE);
|
||||||
|
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
|
@ -351,10 +352,10 @@ public class TRContent {
|
||||||
public double cableThickness;
|
public double cableThickness;
|
||||||
public boolean canKill;
|
public boolean canKill;
|
||||||
public boolean defaultCanKill;
|
public boolean defaultCanKill;
|
||||||
public EnergyTier tier;
|
public RcEnergyTier tier;
|
||||||
|
|
||||||
|
|
||||||
Cables(int transferRate, double cableThickness, boolean canKill, EnergyTier tier) {
|
Cables(int transferRate, double cableThickness, boolean canKill, RcEnergyTier tier) {
|
||||||
name = this.toString().toLowerCase(Locale.ROOT);
|
name = this.toString().toLowerCase(Locale.ROOT);
|
||||||
this.transferRate = transferRate;
|
this.transferRate = transferRate;
|
||||||
this.defaultTransferRate = transferRate;
|
this.defaultTransferRate = transferRate;
|
||||||
|
@ -860,7 +861,7 @@ public class TRContent {
|
||||||
handler.addPowerMulti(TechRebornConfig.overclockerPower);
|
handler.addPowerMulti(TechRebornConfig.overclockerPower);
|
||||||
}
|
}
|
||||||
if (powerAcceptor != null) {
|
if (powerAcceptor != null) {
|
||||||
powerAcceptor.extraPowerInput += powerAcceptor.getMaxInput(EnergySide.UNKNOWN);
|
powerAcceptor.extraPowerInput += powerAcceptor.getMaxInput(null);
|
||||||
powerAcceptor.extraPowerStorage += powerAcceptor.getBaseMaxPower();
|
powerAcceptor.extraPowerStorage += powerAcceptor.getBaseMaxPower();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -40,22 +40,22 @@ import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
import reborncore.common.util.ItemDurabilityExtensions;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
import techreborn.utils.MessageIDs;
|
import techreborn.utils.MessageIDs;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BatteryItem extends Item implements EnergyHolder, ItemDurabilityExtensions {
|
public class BatteryItem extends Item implements RcEnergyItem, ItemDurabilityExtensions {
|
||||||
|
|
||||||
private final int maxEnergy;
|
private final int maxEnergy;
|
||||||
private final EnergyTier tier;
|
private final RcEnergyTier tier;
|
||||||
|
|
||||||
public BatteryItem(int maxEnergy, EnergyTier tier) {
|
public BatteryItem(int maxEnergy, RcEnergyTier tier) {
|
||||||
super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1));
|
super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1));
|
||||||
this.maxEnergy = maxEnergy;
|
this.maxEnergy = maxEnergy;
|
||||||
this.tier = tier;
|
this.tier = tier;
|
||||||
|
@ -102,12 +102,12 @@ public class BatteryItem extends Item implements EnergyHolder, ItemDurabilityExt
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return maxEnergy;
|
return maxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return tier;
|
return tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,19 +36,19 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
import reborncore.common.util.ItemDurabilityExtensions;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
public class BatpackItem extends ArmorItem implements EnergyHolder, ItemDurabilityExtensions {
|
public class BatpackItem extends ArmorItem implements RcEnergyItem, ItemDurabilityExtensions {
|
||||||
|
|
||||||
public final int maxCharge;
|
public final int maxCharge;
|
||||||
public final EnergyTier tier;
|
public final RcEnergyTier tier;
|
||||||
|
|
||||||
public BatpackItem(int maxCharge, ArmorMaterial material, EnergyTier tier) {
|
public BatpackItem(int maxCharge, ArmorMaterial material, RcEnergyTier tier) {
|
||||||
super(material, EquipmentSlot.CHEST, new Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
super(material, EquipmentSlot.CHEST, new Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||||
this.maxCharge = maxCharge;
|
this.maxCharge = maxCharge;
|
||||||
this.tier = tier;
|
this.tier = tier;
|
||||||
|
@ -86,12 +86,12 @@ public class BatpackItem extends ArmorItem implements EnergyHolder, ItemDurabili
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return maxCharge;
|
return maxCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return tier;
|
return tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,17 +35,15 @@ import net.minecraft.util.collection.DefaultedList;
|
||||||
import reborncore.api.items.ArmorBlockEntityTicker;
|
import reborncore.api.items.ArmorBlockEntityTicker;
|
||||||
import reborncore.api.items.ArmorRemoveHandler;
|
import reborncore.api.items.ArmorRemoveHandler;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.Energy;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRArmorMaterials;
|
import techreborn.init.TRArmorMaterials;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
public class CloakingDeviceItem extends TRArmourItem implements EnergyHolder, ArmorBlockEntityTicker, ArmorRemoveHandler {
|
public class CloakingDeviceItem extends TRArmourItem implements RcEnergyItem, ArmorBlockEntityTicker, ArmorRemoveHandler {
|
||||||
|
|
||||||
public static int maxCharge = TechRebornConfig.cloakingDeviceCharge;
|
public static int maxCharge = TechRebornConfig.cloakingDeviceCharge;
|
||||||
public static int cost = TechRebornConfig.cloackingDeviceCost;
|
public static int cost = TechRebornConfig.cloackingDeviceCost;
|
||||||
|
@ -94,24 +92,24 @@ public class CloakingDeviceItem extends TRArmourItem implements EnergyHolder, Ar
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return maxCharge;
|
return maxCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return EnergyTier.INSANE;
|
return RcEnergyTier.INSANE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxOutput(EnergySide side) {
|
public long getEnergyMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ArmorTickable
|
// ArmorTickable
|
||||||
@Override
|
@Override
|
||||||
public void tickArmor(ItemStack stack, PlayerEntity playerEntity) {
|
public void tickArmor(ItemStack stack, PlayerEntity playerEntity) {
|
||||||
if (Energy.of(stack).use(cost)) {
|
if (tryUseEnergy(stack, cost)) {
|
||||||
playerEntity.setInvisible(true);
|
playerEntity.setInvisible(true);
|
||||||
} else {
|
} else {
|
||||||
if (playerEntity.isInvisible()) {
|
if (playerEntity.isInvisible()) {
|
||||||
|
|
|
@ -44,21 +44,20 @@ import reborncore.api.items.ArmorBlockEntityTicker;
|
||||||
import reborncore.api.items.ArmorRemoveHandler;
|
import reborncore.api.items.ArmorRemoveHandler;
|
||||||
import reborncore.api.items.ItemStackModifiers;
|
import reborncore.api.items.ItemStackModifiers;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.Energy;
|
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers, ArmorBlockEntityTicker, ArmorRemoveHandler, EnergyHolder {
|
public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers, ArmorBlockEntityTicker, ArmorRemoveHandler, RcEnergyItem {
|
||||||
|
|
||||||
public final double flyCost = TechRebornConfig.quantumSuitFlyingCost;
|
public final long flyCost = TechRebornConfig.quantumSuitFlyingCost;
|
||||||
public final double swimCost = TechRebornConfig.quantumSuitSwimmingCost;
|
public final long swimCost = TechRebornConfig.quantumSuitSwimmingCost;
|
||||||
public final double breathingCost = TechRebornConfig.quantumSuitBreathingCost;
|
public final long breathingCost = TechRebornConfig.quantumSuitBreathingCost;
|
||||||
public final double sprintingCost = TechRebornConfig.quantumSuitSprintingCost;
|
public final long sprintingCost = TechRebornConfig.quantumSuitSprintingCost;
|
||||||
public final double fireExtinguishCost = TechRebornConfig.fireExtinguishCost;
|
public final long fireExtinguishCost = TechRebornConfig.fireExtinguishCost;
|
||||||
|
|
||||||
public final boolean enableSprint = TechRebornConfig.quantumSuitEnableSprint;
|
public final boolean enableSprint = TechRebornConfig.quantumSuitEnableSprint;
|
||||||
public final boolean enableFlight = TechRebornConfig.quantumSuitEnableFlight;
|
public final boolean enableFlight = TechRebornConfig.quantumSuitEnableFlight;
|
||||||
|
@ -73,12 +72,12 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
|
||||||
attributes.removeAll(EntityAttributes.GENERIC_MOVEMENT_SPEED);
|
attributes.removeAll(EntityAttributes.GENERIC_MOVEMENT_SPEED);
|
||||||
|
|
||||||
if (this.slot == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS && enableSprint) {
|
if (this.slot == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS && enableSprint) {
|
||||||
if (Energy.of(stack).getEnergy() > sprintingCost) {
|
if (getStoredEnergy(stack) > sprintingCost) {
|
||||||
attributes.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(MODIFIERS[equipmentSlot.getEntitySlotId()], "Movement Speed", 0.15, EntityAttributeModifier.Operation.ADDITION));
|
attributes.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(MODIFIERS[equipmentSlot.getEntitySlotId()], "Movement Speed", 0.15, EntityAttributeModifier.Operation.ADDITION));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (equipmentSlot == this.slot && Energy.of(stack).getEnergy() > 0) {
|
if (equipmentSlot == this.slot && getStoredEnergy(stack) > 0) {
|
||||||
attributes.put(EntityAttributes.GENERIC_ARMOR, new EntityAttributeModifier(MODIFIERS[slot.getEntitySlotId()], "Armor modifier", 20, EntityAttributeModifier.Operation.ADDITION));
|
attributes.put(EntityAttributes.GENERIC_ARMOR, new EntityAttributeModifier(MODIFIERS[slot.getEntitySlotId()], "Armor modifier", 20, EntityAttributeModifier.Operation.ADDITION));
|
||||||
attributes.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(MODIFIERS[slot.getEntitySlotId()], "Knockback modifier", 2, EntityAttributeModifier.Operation.ADDITION));
|
attributes.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(MODIFIERS[slot.getEntitySlotId()], "Knockback modifier", 2, EntityAttributeModifier.Operation.ADDITION));
|
||||||
}
|
}
|
||||||
|
@ -89,17 +88,17 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
|
||||||
switch (this.slot) {
|
switch (this.slot) {
|
||||||
case HEAD:
|
case HEAD:
|
||||||
if (playerEntity.isSubmergedInWater()) {
|
if (playerEntity.isSubmergedInWater()) {
|
||||||
if (Energy.of(stack).use(breathingCost)) {
|
if (tryUseEnergy(stack, breathingCost)) {
|
||||||
playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.WATER_BREATHING, 5, 1));
|
playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.WATER_BREATHING, 5, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHEST:
|
case CHEST:
|
||||||
if (enableFlight){
|
if (enableFlight){
|
||||||
if (Energy.of(stack).getEnergy() > flyCost && !TechReborn.elytraPredicate.test(playerEntity)) {
|
if (getStoredEnergy(stack) > flyCost && !TechReborn.elytraPredicate.test(playerEntity)) {
|
||||||
playerEntity.getAbilities().allowFlying = true;
|
playerEntity.getAbilities().allowFlying = true;
|
||||||
if (playerEntity.getAbilities().flying) {
|
if (playerEntity.getAbilities().flying) {
|
||||||
Energy.of(stack).use(flyCost);
|
tryUseEnergy(stack, flyCost);
|
||||||
}
|
}
|
||||||
playerEntity.setOnGround(true);
|
playerEntity.setOnGround(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,18 +106,18 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
|
||||||
playerEntity.getAbilities().flying = false;
|
playerEntity.getAbilities().flying = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (playerEntity.isOnFire() && Energy.of(stack).getEnergy() > fireExtinguishCost) {
|
if (playerEntity.isOnFire() && getStoredEnergy(stack) > fireExtinguishCost) {
|
||||||
playerEntity.extinguish();
|
playerEntity.extinguish();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LEGS:
|
case LEGS:
|
||||||
if (playerEntity.isSprinting() && enableSprint) {
|
if (playerEntity.isSprinting() && enableSprint) {
|
||||||
Energy.of(stack).use(sprintingCost);
|
tryUseEnergy(stack, sprintingCost);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FEET:
|
case FEET:
|
||||||
if (playerEntity.isSwimming()) {
|
if (playerEntity.isSwimming()) {
|
||||||
if (Energy.of(stack).use(swimCost)) {
|
if (tryUseEnergy(stack, swimCost)) {
|
||||||
playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.DOLPHINS_GRACE, 5, 1));
|
playerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.DOLPHINS_GRACE, 5, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,13 +168,13 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return TechRebornConfig.quantumSuitCapacity;
|
return TechRebornConfig.quantumSuitCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return EnergyTier.EXTREME;
|
return RcEnergyTier.EXTREME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
|
|
|
@ -34,27 +34,25 @@ import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
import reborncore.common.util.ItemDurabilityExtensions;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.Energy;
|
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class ChainsawItem extends AxeItem implements EnergyHolder, ItemDurabilityExtensions {
|
public class ChainsawItem extends AxeItem implements RcEnergyItem, ItemDurabilityExtensions {
|
||||||
|
|
||||||
public final int maxCharge;
|
public final int maxCharge;
|
||||||
public final int cost;
|
public final int cost;
|
||||||
public final float poweredSpeed;
|
public final float poweredSpeed;
|
||||||
private final float unpoweredSpeed;
|
private final float unpoweredSpeed;
|
||||||
public final Item referenceTool;
|
public final Item referenceTool;
|
||||||
public final EnergyTier tier;
|
public final RcEnergyTier tier;
|
||||||
|
|
||||||
public ChainsawItem(ToolMaterials material, int energyCapacity, EnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, Item referenceTool) {
|
public ChainsawItem(ToolMaterials material, int energyCapacity, RcEnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, Item referenceTool) {
|
||||||
// combat stats same as for diamond axe. Fix for #2468
|
// combat stats same as for diamond axe. Fix for #2468
|
||||||
super(material, 5.0F, -3.0F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
super(material, 5.0F, -3.0F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||||
this.maxCharge = energyCapacity;
|
this.maxCharge = energyCapacity;
|
||||||
|
@ -68,7 +66,7 @@ public class ChainsawItem extends AxeItem implements EnergyHolder, ItemDurabilit
|
||||||
// AxeItem
|
// AxeItem
|
||||||
@Override
|
@Override
|
||||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||||
if (Energy.of(stack).getEnergy() >= cost
|
if (getStoredEnergy(stack) >= cost
|
||||||
&& (state.getMaterial() == Material.WOOD || state.getMaterial() == Material.NETHER_WOOD)) {
|
&& (state.getMaterial() == Material.WOOD || state.getMaterial() == Material.NETHER_WOOD)) {
|
||||||
return poweredSpeed;
|
return poweredSpeed;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +78,7 @@ public class ChainsawItem extends AxeItem implements EnergyHolder, ItemDurabilit
|
||||||
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
||||||
Energy.of(stack).use(cost);
|
tryUseEnergy(stack, cost);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -138,17 +136,17 @@ public class ChainsawItem extends AxeItem implements EnergyHolder, ItemDurabilit
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return maxCharge;
|
return maxCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return tier;
|
return tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxOutput(EnergySide side) {
|
public long getEnergyMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.Util;
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import team.reborn.energy.Energy;
|
import team.reborn.energy.api.EnergyStorage;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
@ -60,26 +60,30 @@ public class DebugToolItem extends Item {
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
if (context.getWorld().isClient) {
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
sendMessage(context, new LiteralText(getRegistryName(block)));
|
sendMessage(context, new LiteralText(getRegistryName(block)));
|
||||||
|
|
||||||
for (Entry<Property<?>, Comparable<?>> entry : blockState.getEntries().entrySet()) {
|
for (Entry<Property<?>, Comparable<?>> entry : blockState.getEntries().entrySet()) {
|
||||||
sendMessage(context, new LiteralText(getPropertyString(entry)));
|
sendMessage(context, new LiteralText(getPropertyString(entry)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnergyStorage energyStorage = EnergyStorage.SIDED.find(context.getWorld(), context.getBlockPos(), context.getSide());
|
||||||
|
if (energyStorage != null) {
|
||||||
|
sendMessage(context, new LiteralText(getRCPower(energyStorage)));
|
||||||
|
}
|
||||||
|
|
||||||
BlockEntity blockEntity = context.getWorld().getBlockEntity(context.getBlockPos());
|
BlockEntity blockEntity = context.getWorld().getBlockEntity(context.getBlockPos());
|
||||||
if (blockEntity == null) {
|
if (blockEntity == null) {
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.CONSUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage(context, new LiteralText(getBlockEntityType(blockEntity)));
|
sendMessage(context, new LiteralText(getBlockEntityType(blockEntity)));
|
||||||
|
|
||||||
if (Energy.valid(blockEntity)) {
|
|
||||||
sendMessage(context, new LiteralText(getRCPower(blockEntity)));
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMessage(context, getBlockEntityTags(blockEntity));
|
sendMessage(context, getBlockEntityTags(blockEntity));
|
||||||
|
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.CONSUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(ItemUsageContext context, Text message) {
|
private void sendMessage(ItemUsageContext context, Text message) {
|
||||||
|
@ -120,13 +124,13 @@ public class DebugToolItem extends Item {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getRCPower(BlockEntity blockEntity) {
|
private String getRCPower(EnergyStorage energyStorage) {
|
||||||
String s = "" + Formatting.GREEN;
|
String s = "" + Formatting.GREEN;
|
||||||
s += "Power: ";
|
s += "Power: ";
|
||||||
s += Formatting.BLUE;
|
s += Formatting.BLUE;
|
||||||
s += PowerSystem.getLocalizedPower(Energy.of(blockEntity).getEnergy());
|
s += PowerSystem.getLocalizedPower(energyStorage.getAmount());
|
||||||
s += "/";
|
s += "/";
|
||||||
s += PowerSystem.getLocalizedPower(Energy.of(blockEntity).getMaxStored());
|
s += PowerSystem.getLocalizedPower(energyStorage.getCapacity());
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,25 +36,23 @@ import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
import reborncore.common.util.ItemDurabilityExtensions;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.Energy;
|
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabilityExtensions, DynamicAttributeTool {
|
public class DrillItem extends PickaxeItem implements RcEnergyItem, ItemDurabilityExtensions, DynamicAttributeTool {
|
||||||
|
|
||||||
public final int maxCharge;
|
public final int maxCharge;
|
||||||
public final int cost;
|
public final int cost;
|
||||||
public final float poweredSpeed;
|
public final float poweredSpeed;
|
||||||
public final float unpoweredSpeed;
|
public final float unpoweredSpeed;
|
||||||
public final int miningLevel;
|
public final int miningLevel;
|
||||||
public final EnergyTier tier;
|
public final RcEnergyTier tier;
|
||||||
|
|
||||||
public DrillItem(ToolMaterials material, int energyCapacity, EnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, MiningLevel miningLevel) {
|
public DrillItem(ToolMaterials material, int energyCapacity, RcEnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, MiningLevel miningLevel) {
|
||||||
// combat stats same as for diamond pickaxe. Fix for #2468
|
// combat stats same as for diamond pickaxe. Fix for #2468
|
||||||
super(material, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
super(material, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||||
this.maxCharge = energyCapacity;
|
this.maxCharge = energyCapacity;
|
||||||
|
@ -69,7 +67,7 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
|
||||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||||
// Going to remain to use this ol reliable function, the fabric one is funky
|
// Going to remain to use this ol reliable function, the fabric one is funky
|
||||||
|
|
||||||
if (Energy.of(stack).getEnergy() >= cost) {
|
if (getStoredEnergy(stack) >= cost) {
|
||||||
if (stack.getItem().isSuitableFor(state)) {
|
if (stack.getItem().isSuitableFor(state)) {
|
||||||
return poweredSpeed;
|
return poweredSpeed;
|
||||||
} else {
|
} else {
|
||||||
|
@ -105,7 +103,7 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
|
||||||
@Override
|
@Override
|
||||||
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
||||||
if (worldIn.random.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
if (worldIn.random.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
||||||
Energy.of(stack).use(cost);
|
tryUseEnergy(stack, cost);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -153,17 +151,17 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return maxCharge;
|
return maxCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return tier;
|
return tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxOutput(EnergySide side) {
|
public long getEnergyMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,26 +37,24 @@ import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
import reborncore.common.util.ItemDurabilityExtensions;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.Energy;
|
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
import techreborn.utils.ToolsUtil;
|
import techreborn.utils.ToolsUtil;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class JackhammerItem extends PickaxeItem implements EnergyHolder, ItemDurabilityExtensions, DynamicAttributeTool {
|
public class JackhammerItem extends PickaxeItem implements RcEnergyItem, ItemDurabilityExtensions, DynamicAttributeTool {
|
||||||
|
|
||||||
public final int maxCharge;
|
public final int maxCharge;
|
||||||
public final EnergyTier tier;
|
public final RcEnergyTier tier;
|
||||||
public final int cost;
|
public final int cost;
|
||||||
protected final float unpoweredSpeed = 0.5F;
|
protected final float unpoweredSpeed = 0.5F;
|
||||||
|
|
||||||
public JackhammerItem(int energyCapacity, EnergyTier tier, int cost) {
|
public JackhammerItem(int energyCapacity, RcEnergyTier tier, int cost) {
|
||||||
// combat stats same as for diamond pickaxe. Fix for #2468
|
// combat stats same as for diamond pickaxe. Fix for #2468
|
||||||
super(ToolMaterials.DIAMOND, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
super(ToolMaterials.DIAMOND, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||||
this.maxCharge = energyCapacity;
|
this.maxCharge = energyCapacity;
|
||||||
|
@ -67,7 +65,7 @@ public class JackhammerItem extends PickaxeItem implements EnergyHolder, ItemDur
|
||||||
// PickaxeItem
|
// PickaxeItem
|
||||||
@Override
|
@Override
|
||||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||||
if (Energy.of(stack).getEnergy() < cost) return unpoweredSpeed;
|
if (getStoredEnergy(stack) < cost) return unpoweredSpeed;
|
||||||
if (ToolsUtil.JackHammerSkippedBlocks(state)) return unpoweredSpeed;
|
if (ToolsUtil.JackHammerSkippedBlocks(state)) return unpoweredSpeed;
|
||||||
|
|
||||||
if (state.getMaterial() == Material.STONE) {
|
if (state.getMaterial() == Material.STONE) {
|
||||||
|
@ -95,7 +93,7 @@ public class JackhammerItem extends PickaxeItem implements EnergyHolder, ItemDur
|
||||||
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
||||||
Energy.of(stack).use(cost);
|
tryUseEnergy(stack, cost);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -132,17 +130,17 @@ public class JackhammerItem extends PickaxeItem implements EnergyHolder, ItemDur
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return maxCharge;
|
return maxCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return tier;
|
return tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxOutput(EnergySide side) {
|
public long getEnergyMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ import net.minecraft.world.World;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.common.misc.MultiBlockBreakingTool;
|
import reborncore.common.misc.MultiBlockBreakingTool;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.items.tool.JackhammerItem;
|
import techreborn.items.tool.JackhammerItem;
|
||||||
import techreborn.utils.MessageIDs;
|
import techreborn.utils.MessageIDs;
|
||||||
|
@ -55,7 +55,7 @@ import java.util.stream.Collectors;
|
||||||
public class AdvancedJackhammerItem extends JackhammerItem implements MultiBlockBreakingTool {
|
public class AdvancedJackhammerItem extends JackhammerItem implements MultiBlockBreakingTool {
|
||||||
|
|
||||||
public AdvancedJackhammerItem() {
|
public AdvancedJackhammerItem() {
|
||||||
super(TechRebornConfig.advancedJackhammerCharge, EnergyTier.EXTREME, TechRebornConfig.advancedJackhammerCost);
|
super(TechRebornConfig.advancedJackhammerCharge, RcEnergyTier.EXTREME, TechRebornConfig.advancedJackhammerCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldBreak(World worldIn, BlockPos originalPos, BlockPos pos, ItemStack stack) {
|
private boolean shouldBreak(World worldIn, BlockPos originalPos, BlockPos pos, ItemStack stack) {
|
||||||
|
|
|
@ -31,10 +31,10 @@ import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
import reborncore.common.util.ItemDurabilityExtensions;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
@ -42,11 +42,11 @@ import techreborn.utils.InitUtils;
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 05/11/2016.
|
* Created by modmuss50 on 05/11/2016.
|
||||||
*/
|
*/
|
||||||
public class ElectricTreetapItem extends Item implements EnergyHolder, ItemDurabilityExtensions {
|
public class ElectricTreetapItem extends Item implements RcEnergyItem, ItemDurabilityExtensions {
|
||||||
|
|
||||||
public final int maxCharge = TechRebornConfig.electricTreetapCharge;
|
public final int maxCharge = TechRebornConfig.electricTreetapCharge;
|
||||||
public int cost = TechRebornConfig.electricTreetapCost;
|
public int cost = TechRebornConfig.electricTreetapCost;
|
||||||
public EnergyTier tier = EnergyTier.MEDIUM;
|
public RcEnergyTier tier = RcEnergyTier.MEDIUM;
|
||||||
|
|
||||||
public ElectricTreetapItem() {
|
public ElectricTreetapItem() {
|
||||||
super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
|
||||||
|
@ -85,12 +85,12 @@ public class ElectricTreetapItem extends Item implements EnergyHolder, ItemDurab
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return maxCharge;
|
return maxCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return tier;
|
return tier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,19 +36,17 @@ import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
import reborncore.common.util.ItemDurabilityExtensions;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.Energy;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDurabilityExtensions {
|
public class RockCutterItem extends PickaxeItem implements RcEnergyItem, ItemDurabilityExtensions {
|
||||||
|
|
||||||
public static final int maxCharge = TechRebornConfig.rockCutterCharge;
|
public static final int maxCharge = TechRebornConfig.rockCutterCharge;
|
||||||
public int cost = TechRebornConfig.rockCutterCost;
|
public int cost = TechRebornConfig.rockCutterCost;
|
||||||
|
@ -67,7 +65,7 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||||
if (Energy.of(stack).getEnergy() < cost) {
|
if (getStoredEnergy(stack) < cost) {
|
||||||
return 2F;
|
return 2F;
|
||||||
} else {
|
} else {
|
||||||
return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(stack, state);
|
return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(stack, state);
|
||||||
|
@ -79,7 +77,7 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
|
||||||
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
||||||
Energy.of(stack).use(cost);
|
tryUseEnergy(stack, cost);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +121,7 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
|
||||||
uncharged.addEnchantment(Enchantments.SILK_TOUCH, 1);
|
uncharged.addEnchantment(Enchantments.SILK_TOUCH, 1);
|
||||||
ItemStack charged = new ItemStack(TRContent.ROCK_CUTTER);
|
ItemStack charged = new ItemStack(TRContent.ROCK_CUTTER);
|
||||||
charged.addEnchantment(Enchantments.SILK_TOUCH, 1);
|
charged.addEnchantment(Enchantments.SILK_TOUCH, 1);
|
||||||
Energy.of(charged).set(Energy.of(charged).getMaxStored());
|
setStoredEnergy(charged, getEnergyCapacity());
|
||||||
|
|
||||||
stacks.add(uncharged);
|
stacks.add(uncharged);
|
||||||
stacks.add(charged);
|
stacks.add(charged);
|
||||||
|
@ -147,17 +145,17 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return maxCharge;
|
return maxCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return EnergyTier.MEDIUM;
|
return RcEnergyTier.MEDIUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxOutput(EnergySide side) {
|
public long getEnergyMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,7 @@ import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.Energy;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.items.tool.ChainsawItem;
|
import techreborn.items.tool.ChainsawItem;
|
||||||
import techreborn.utils.MessageIDs;
|
import techreborn.utils.MessageIDs;
|
||||||
|
@ -59,7 +58,7 @@ public class IndustrialChainsawItem extends ChainsawItem {
|
||||||
private static final Direction[] SEARCH_ORDER = new Direction[]{Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST, Direction.UP};
|
private static final Direction[] SEARCH_ORDER = new Direction[]{Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST, Direction.UP};
|
||||||
|
|
||||||
public IndustrialChainsawItem() {
|
public IndustrialChainsawItem() {
|
||||||
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialChainsawCharge, EnergyTier.EXTREME, TechRebornConfig.industrialChainsawCost, 20F, 1.0F, Items.DIAMOND_AXE);
|
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialChainsawCharge, RcEnergyTier.EXTREME, TechRebornConfig.industrialChainsawCost, 20F, 1.0F, Items.DIAMOND_AXE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findWood(World world, BlockPos pos, List<BlockPos> wood, List<BlockPos> leaves) {
|
private void findWood(World world, BlockPos pos, List<BlockPos> wood, List<BlockPos> leaves) {
|
||||||
|
@ -95,7 +94,7 @@ public class IndustrialChainsawItem extends ChainsawItem {
|
||||||
findWood(worldIn, pos, wood, leaves);
|
findWood(worldIn, pos, wood, leaves);
|
||||||
wood.remove(pos);
|
wood.remove(pos);
|
||||||
wood.stream()
|
wood.stream()
|
||||||
.filter(p -> Energy.of(stack).simulate().use(cost))
|
.filter(p -> tryUseEnergy(stack, cost))
|
||||||
.forEach(pos1 -> ToolsUtil.breakBlock(stack, worldIn, pos1, entityLiving, cost));
|
.forEach(pos1 -> ToolsUtil.breakBlock(stack, worldIn, pos1, entityLiving, cost));
|
||||||
leaves.remove(pos);
|
leaves.remove(pos);
|
||||||
leaves.forEach(pos1 -> ToolsUtil.breakBlock(stack, worldIn, pos1, entityLiving, 0));
|
leaves.forEach(pos1 -> ToolsUtil.breakBlock(stack, worldIn, pos1, entityLiving, 0));
|
||||||
|
|
|
@ -43,7 +43,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
import techreborn.items.tool.DrillItem;
|
import techreborn.items.tool.DrillItem;
|
||||||
|
@ -57,7 +57,7 @@ import java.util.List;
|
||||||
public class IndustrialDrillItem extends DrillItem {
|
public class IndustrialDrillItem extends DrillItem {
|
||||||
|
|
||||||
public IndustrialDrillItem() {
|
public IndustrialDrillItem() {
|
||||||
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialDrillCharge, EnergyTier.INSANE, TechRebornConfig.industrialDrillCost, 20.0F, 1.0F, MiningLevel.DIAMOND);
|
super(ToolMaterials.DIAMOND, TechRebornConfig.industrialDrillCharge, RcEnergyTier.INSANE, TechRebornConfig.industrialDrillCost, 20.0F, 1.0F, MiningLevel.DIAMOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldBreak(PlayerEntity playerIn, World worldIn, BlockPos originalPos, BlockPos pos) {
|
private boolean shouldBreak(PlayerEntity playerIn, World worldIn, BlockPos originalPos, BlockPos pos) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.common.misc.MultiBlockBreakingTool;
|
import reborncore.common.misc.MultiBlockBreakingTool;
|
||||||
import reborncore.common.util.ChatUtils;
|
import reborncore.common.util.ChatUtils;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.EnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.items.tool.JackhammerItem;
|
import techreborn.items.tool.JackhammerItem;
|
||||||
import techreborn.utils.MessageIDs;
|
import techreborn.utils.MessageIDs;
|
||||||
|
@ -59,7 +59,7 @@ import java.util.stream.Collectors;
|
||||||
public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlockBreakingTool {
|
public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlockBreakingTool {
|
||||||
|
|
||||||
public IndustrialJackhammerItem() {
|
public IndustrialJackhammerItem() {
|
||||||
super(TechRebornConfig.industrialJackhammerCharge, EnergyTier.INSANE, TechRebornConfig.industrialJackhammerCost);
|
super(TechRebornConfig.industrialJackhammerCharge, RcEnergyTier.INSANE, TechRebornConfig.industrialJackhammerCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cycle Inactive, Active 3*3 and Active 5*5
|
// Cycle Inactive, Active 3*3 and Active 5*5
|
||||||
|
|
|
@ -46,12 +46,10 @@ import net.minecraft.world.World;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.items.ItemStackModifiers;
|
import reborncore.api.items.ItemStackModifiers;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
import reborncore.common.util.ItemDurabilityExtensions;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.Energy;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -59,7 +57,7 @@ import techreborn.utils.MessageIDs;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabilityExtensions, ItemStackModifiers {
|
public class NanosaberItem extends SwordItem implements RcEnergyItem, ItemDurabilityExtensions, ItemStackModifiers {
|
||||||
public static final int maxCharge = TechRebornConfig.nanosaberCharge;
|
public static final int maxCharge = TechRebornConfig.nanosaberCharge;
|
||||||
public int cost = TechRebornConfig.nanosaberCost;
|
public int cost = TechRebornConfig.nanosaberCost;
|
||||||
|
|
||||||
|
@ -71,7 +69,7 @@ public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabi
|
||||||
// SwordItem
|
// SwordItem
|
||||||
@Override
|
@Override
|
||||||
public boolean postHit(ItemStack stack, LivingEntity entityHit, LivingEntity entityHitter) {
|
public boolean postHit(ItemStack stack, LivingEntity entityHit, LivingEntity entityHitter) {
|
||||||
return Energy.of(stack).use(cost);
|
return tryUseEnergy(stack, cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToolItem
|
// ToolItem
|
||||||
|
@ -120,12 +118,12 @@ public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabi
|
||||||
ItemStack inactiveCharged = new ItemStack(TRContent.NANOSABER);
|
ItemStack inactiveCharged = new ItemStack(TRContent.NANOSABER);
|
||||||
inactiveCharged.setNbt(new NbtCompound());
|
inactiveCharged.setNbt(new NbtCompound());
|
||||||
inactiveCharged.getOrCreateNbt().putBoolean("isActive", false);
|
inactiveCharged.getOrCreateNbt().putBoolean("isActive", false);
|
||||||
Energy.of(inactiveCharged).set(Energy.of(inactiveCharged).getMaxStored());
|
setStoredEnergy(inactiveCharged, getEnergyCapacity());
|
||||||
|
|
||||||
ItemStack activeCharged = new ItemStack(TRContent.NANOSABER);
|
ItemStack activeCharged = new ItemStack(TRContent.NANOSABER);
|
||||||
activeCharged.setNbt(new NbtCompound());
|
activeCharged.setNbt(new NbtCompound());
|
||||||
activeCharged.getOrCreateNbt().putBoolean("isActive", true);
|
activeCharged.getOrCreateNbt().putBoolean("isActive", true);
|
||||||
Energy.of(activeCharged).set(Energy.of(activeCharged).getMaxStored());
|
setStoredEnergy(activeCharged, getEnergyCapacity());
|
||||||
|
|
||||||
itemList.add(inactiveUncharged);
|
itemList.add(inactiveUncharged);
|
||||||
itemList.add(inactiveCharged);
|
itemList.add(inactiveCharged);
|
||||||
|
@ -140,17 +138,17 @@ public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabi
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return maxCharge;
|
return maxCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return EnergyTier.EXTREME;
|
return RcEnergyTier.EXTREME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxOutput(EnergySide side) {
|
public long getEnergyMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,13 +45,11 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
import reborncore.common.util.ItemDurabilityExtensions;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.TorchHelper;
|
import reborncore.common.util.TorchHelper;
|
||||||
import team.reborn.energy.Energy;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import team.reborn.energy.EnergyHolder;
|
|
||||||
import team.reborn.energy.EnergySide;
|
|
||||||
import team.reborn.energy.EnergyTier;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -60,7 +58,7 @@ import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurabilityExtensions, DynamicAttributeTool {
|
public class OmniToolItem extends PickaxeItem implements RcEnergyItem, ItemDurabilityExtensions, DynamicAttributeTool {
|
||||||
|
|
||||||
public final int maxCharge = TechRebornConfig.omniToolCharge;
|
public final int maxCharge = TechRebornConfig.omniToolCharge;
|
||||||
public int cost = TechRebornConfig.omniToolCost;
|
public int cost = TechRebornConfig.omniToolCost;
|
||||||
|
@ -83,7 +81,7 @@ public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurab
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||||
if (Energy.of(stack).getEnergy() >= cost) {
|
if (getStoredEnergy(stack) >= cost) {
|
||||||
return ToolMaterials.DIAMOND.getMiningSpeedMultiplier();
|
return ToolMaterials.DIAMOND.getMiningSpeedMultiplier();
|
||||||
}
|
}
|
||||||
return super.getMiningSpeedMultiplier(stack, state);
|
return super.getMiningSpeedMultiplier(stack, state);
|
||||||
|
@ -92,13 +90,13 @@ public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurab
|
||||||
// MiningToolItem
|
// MiningToolItem
|
||||||
@Override
|
@Override
|
||||||
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
||||||
Energy.of(stack).use(cost);
|
tryUseEnergy(stack, cost);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean postHit(ItemStack stack, LivingEntity entityliving, LivingEntity attacker) {
|
public boolean postHit(ItemStack stack, LivingEntity entityliving, LivingEntity attacker) {
|
||||||
if (Energy.of(stack).use(hitCost)) {
|
if (tryUseEnergy(stack, hitCost)) {
|
||||||
entityliving.damage(DamageSource.player((PlayerEntity) attacker), 8F);
|
entityliving.damage(DamageSource.player((PlayerEntity) attacker), 8F);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -159,18 +157,18 @@ public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurab
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
@Override
|
@Override
|
||||||
public double getMaxStoredPower() {
|
public long getEnergyCapacity() {
|
||||||
return maxCharge;
|
return maxCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxOutput(EnergySide side) {
|
public long getEnergyMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnergyTier getTier() {
|
public RcEnergyTier getTier() {
|
||||||
return EnergyTier.EXTREME;
|
return RcEnergyTier.EXTREME;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DynamicAttributeTool
|
// DynamicAttributeTool
|
||||||
|
|
|
@ -37,7 +37,7 @@ import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import reborncore.RebornRegistry;
|
import reborncore.RebornRegistry;
|
||||||
import team.reborn.energy.Energy;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
|
|
||||||
public class InitUtils {
|
public class InitUtils {
|
||||||
|
@ -59,8 +59,9 @@ public class InitUtils {
|
||||||
public static void initPoweredItems(Item item, DefaultedList<ItemStack> itemList) {
|
public static void initPoweredItems(Item item, DefaultedList<ItemStack> itemList) {
|
||||||
ItemStack uncharged = new ItemStack(item);
|
ItemStack uncharged = new ItemStack(item);
|
||||||
ItemStack charged = new ItemStack(item);
|
ItemStack charged = new ItemStack(item);
|
||||||
|
RcEnergyItem energyItem = (RcEnergyItem) item;
|
||||||
|
|
||||||
Energy.of(charged).set(Energy.of(charged).getMaxStored());
|
energyItem.setStoredEnergy(charged, energyItem.getEnergyCapacity());
|
||||||
|
|
||||||
itemList.add(uncharged);
|
itemList.add(uncharged);
|
||||||
itemList.add(charged);
|
itemList.add(charged);
|
||||||
|
|
|
@ -32,7 +32,7 @@ import net.minecraft.inventory.CraftingInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import reborncore.api.events.ItemCraftCallback;
|
import reborncore.api.events.ItemCraftCallback;
|
||||||
import team.reborn.energy.Energy;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -49,15 +49,20 @@ public final class PoweredCraftingHandler implements ItemCraftCallback {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraft(ItemStack stack, CraftingInventory craftingInventory, PlayerEntity playerEntity) {
|
public void onCraft(ItemStack stack, CraftingInventory craftingInventory, PlayerEntity playerEntity) {
|
||||||
if (Energy.valid(stack)) {
|
if (stack.getItem() instanceof RcEnergyItem energyItem) {
|
||||||
double totalEnergy = IntStream.range(0, craftingInventory.size())
|
long totalEnergy = IntStream.range(0, craftingInventory.size())
|
||||||
.mapToObj(craftingInventory::getStack)
|
.mapToObj(craftingInventory::getStack)
|
||||||
.filter(s -> !s.isEmpty())
|
.filter(s -> !s.isEmpty())
|
||||||
.filter(Energy::valid)
|
.mapToLong(s -> {
|
||||||
.mapToDouble(s -> Energy.of(s).getEnergy())
|
if (s.getItem() instanceof RcEnergyItem inputItem) {
|
||||||
|
return inputItem.getStoredEnergy(s);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
})
|
||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
Energy.of(stack).set(totalEnergy);
|
energyItem.setStoredEnergy(stack, totalEnergy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Registry.ITEM.getId(stack.getItem()).getNamespace().equalsIgnoreCase(TechReborn.MOD_ID)) {
|
if (!Registry.ITEM.getId(stack.getItem()).getNamespace().equalsIgnoreCase(TechReborn.MOD_ID)) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import team.reborn.energy.Energy;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -59,7 +59,7 @@ public class ToolsUtil {
|
||||||
}
|
}
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, tool) + 1) == 0) {
|
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, tool) + 1) == 0) {
|
||||||
if (!Energy.of(tool).use(cost)) {
|
if (!((RcEnergyItem) tool.getItem()).tryUseEnergy(tool, cost)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue