Tile -> BlockEntity + some more refactors
This commit is contained in:
parent
7f8674f1ca
commit
dbc89adaf7
193 changed files with 3194 additions and 3214 deletions
|
@ -0,0 +1,215 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import reborncore.fluid.FluidStack;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.api.generator.FluidGeneratorRecipe;
|
||||
import techreborn.api.generator.FluidGeneratorRecipeList;
|
||||
import techreborn.api.generator.GeneratorRecipeHelper;
|
||||
import techreborn.utils.FluidUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop, InventoryProvider {
|
||||
|
||||
private final FluidGeneratorRecipeList recipes;
|
||||
private final int euTick;
|
||||
private FluidGeneratorRecipe currentRecipe;
|
||||
private int ticksSinceLastChange;
|
||||
public final Tank tank;
|
||||
public final RebornInventory<?> inventory;
|
||||
protected long lastOutput = 0;
|
||||
|
||||
/*
|
||||
* We use this to keep track of fractional millibuckets, allowing us to hit
|
||||
* our eu/bucket targets while still only ever removing integer millibucket
|
||||
* amounts.
|
||||
*/
|
||||
double pendingWithdraw = 0.0;
|
||||
|
||||
public BaseFluidGeneratorBlockEntity(BlockEntityType<?> blockEntityType, EFluidGenerator type, String blockEntityName, int tankCapacity, int euTick) {
|
||||
super(blockEntityType);
|
||||
recipes = GeneratorRecipeHelper.getFluidRecipesForGenerator(type);
|
||||
tank = new Tank(blockEntityName, tankCapacity, this);
|
||||
inventory = new RebornInventory<>(3, blockEntityName, 64, this).withConfiguredAccess();
|
||||
this.euTick = euTick;
|
||||
this.ticksSinceLastChange = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
ticksSinceLastChange++;
|
||||
|
||||
if(world.isClient){
|
||||
return;
|
||||
}
|
||||
|
||||
// Check cells input slot 2 time per second
|
||||
// Please, keep ticks counting on client also to report progress to GUI
|
||||
if (ticksSinceLastChange >= 10) {
|
||||
if (!inventory.getInvStack(0).isEmpty()) {
|
||||
FluidUtils.drainContainers(tank, inventory, 0, 1);
|
||||
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType());
|
||||
}
|
||||
tank.setBlockEntity(this);
|
||||
tank.compareAndUpdate();
|
||||
|
||||
ticksSinceLastChange = 0;
|
||||
}
|
||||
|
||||
if (tank.getFluidAmount() > 0) {
|
||||
if (currentRecipe == null || !FluidUtils.fluidEquals(currentRecipe.getFluid(), tank.getFluidType()))
|
||||
currentRecipe = getRecipes().getRecipeForFluid(tank.getFluidType()).orElse(null);
|
||||
|
||||
if (currentRecipe != null) {
|
||||
final Integer euPerBucket = currentRecipe.getEnergyPerMb() * 1000;
|
||||
final float millibucketsPerTick = euTick * 1000 / (float) euPerBucket;
|
||||
|
||||
if (tryAddingEnergy(euTick)) {
|
||||
pendingWithdraw += millibucketsPerTick;
|
||||
final int currentWithdraw = (int) pendingWithdraw;
|
||||
pendingWithdraw -= currentWithdraw;
|
||||
tank.drain(currentWithdraw, true);
|
||||
lastOutput = world.getTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (world.getTime() - lastOutput < 30 && !isActive()) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
|
||||
}
|
||||
else if (world.getTime() - lastOutput > 30 && isActive()) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
|
||||
}
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (isActive()){
|
||||
return ticksSinceLastChange * scale;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected boolean tryAddingEnergy(int amount) {
|
||||
if (getMaxPower() - getEnergy() >= amount) {
|
||||
addEnergy(amount);
|
||||
return true;
|
||||
} else if (getMaxPower() - getEnergy() > 0) {
|
||||
addEnergy(getMaxPower() - getEnergy());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean acceptFluid() {
|
||||
if (!inventory.getInvStack(0).isEmpty()) {
|
||||
FluidStack stack = FluidUtils.getFluidStackInContainer(inventory.getInvStack(0));
|
||||
if (stack != null)
|
||||
return recipes.getRecipeForFluid(stack.getFluid()).isPresent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public FluidGeneratorRecipeList getRecipes() {
|
||||
return recipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return euTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(Direction direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RebornInventory<?> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(CompoundTag tagCompound) {
|
||||
super.fromTag(tagCompound);
|
||||
tank.read(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tagCompound) {
|
||||
super.toTag(tagCompound);
|
||||
tank.write(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTicksSinceLastChange() {
|
||||
return ticksSinceLastChange;
|
||||
}
|
||||
|
||||
public void setTicksSinceLastChange(int ticksSinceLastChange) {
|
||||
this.ticksSinceLastChange = ticksSinceLastChange;
|
||||
}
|
||||
|
||||
public int getTankAmount(){
|
||||
return tank.getFluidAmount();
|
||||
}
|
||||
|
||||
public void setTankAmount(int amount){
|
||||
tank.setFluidAmount(amount);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Tank getTank() {
|
||||
return tank;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
@RebornRegister(TechReborn.MOD_ID)
|
||||
public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop {
|
||||
|
||||
@ConfigRegistry(config = "generators", category = "lightning_rod", key = "LightningRodMaxOutput", comment = "Lightning Rod Max Output (Value in EU)")
|
||||
public static int maxOutput = 2048;
|
||||
@ConfigRegistry(config = "generators", category = "lightning_rod", key = "LightningRodMaxEnergy", comment = "Lightning Rod Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 100_000_000;
|
||||
@ConfigRegistry(config = "generators", category = "lightning_rod", key = "LightningRodChanceOfStrike", comment = "Chance of lightning striking a rod (Range: 0-70)")
|
||||
public static int chanceOfStrike = 24;
|
||||
@ConfigRegistry(config = "generators", category = "lightning_rod", key = "LightningRodBaseStrikeEnergy", comment = "Base amount of energy per strike (Value in EU)")
|
||||
public static int baseEnergyStrike = 262_144;
|
||||
|
||||
private int onStatusHoldTicks = -1;
|
||||
|
||||
public LightningRodBlockEntity() {
|
||||
super(TRBlockEntities.LIGHTNING_ROD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
if (onStatusHoldTicks > 0)
|
||||
--onStatusHoldTicks;
|
||||
|
||||
if (onStatusHoldTicks == 0 || getEnergy() <= 0) {
|
||||
if (getCachedState().getBlock() instanceof BlockMachineBase)
|
||||
((BlockMachineBase) getCachedState().getBlock()).setActive(false, world, pos);
|
||||
onStatusHoldTicks = -1;
|
||||
}
|
||||
|
||||
final float weatherStrength = world.getThunderGradient(1.0F);
|
||||
if (weatherStrength > 0.2F) {
|
||||
//lightStrikeChance = (MAX - (CHANCE * WEATHER_STRENGTH)
|
||||
final float lightStrikeChance = (100F - chanceOfStrike) * 20F;
|
||||
final float totalChance = lightStrikeChance * getLightningStrikeMultiplier() * (1.1F - weatherStrength);
|
||||
if (world.random.nextInt((int) Math.floor(totalChance)) == 0) {
|
||||
if (!isValidIronFence(pos.up().getY())) {
|
||||
onStatusHoldTicks = 400;
|
||||
return;
|
||||
}
|
||||
final LightningEntity lightningBolt = new LightningEntity(world,
|
||||
pos.getX() + 0.5F, world.getTopPosition(Heightmap.Type.MOTION_BLOCKING, getPos()).getY(),
|
||||
pos.getZ() + 0.5F, false);
|
||||
if(true){
|
||||
throw new RuntimeException("fix me");
|
||||
}
|
||||
//world.addWeatherEffect(lightningBolt);
|
||||
world.spawnEntity(lightningBolt);
|
||||
addEnergy(baseEnergyStrike * (0.3F + weatherStrength));
|
||||
((BlockMachineBase) world.getBlockState(pos).getBlock()).setActive(true, world, pos);
|
||||
onStatusHoldTicks = 400;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public float getLightningStrikeMultiplier() {
|
||||
final float actualHeight = 256;
|
||||
final float groundLevel = world.getTopPosition(Heightmap.Type.MOTION_BLOCKING, getPos()).getY();
|
||||
for (int i = pos.getY() + 1; i < actualHeight; i++) {
|
||||
if (!isValidIronFence(i)) {
|
||||
if (groundLevel >= i)
|
||||
return 4.3F;
|
||||
final float max = actualHeight - groundLevel;
|
||||
final float got = i - groundLevel;
|
||||
return 1.2F - got / max;
|
||||
}
|
||||
}
|
||||
return 4F;
|
||||
}
|
||||
|
||||
public boolean isValidIronFence(int y) {
|
||||
Block block = this.world.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock();
|
||||
if(block == TRContent.REFINED_IRON_FENCE){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(final Direction direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(final Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
||||
return TRContent.Machine.LIGHTNING_ROD.getStack();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
@RebornRegister(TechReborn.MOD_ID)
|
||||
public class PlasmaGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxOutput", comment = "Plasma Generator Max Output (Value in EU)")
|
||||
public static int maxOutput = 2048;
|
||||
@ConfigRegistry(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxEnergy", comment = "Plasma Generator Max Energy (Value in EU)")
|
||||
public static double maxEnergy = 500_000_000;
|
||||
@ConfigRegistry(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorTankCapacity", comment = "Plasma Generator Tank Capacity")
|
||||
public static int tankCapacity = 10_000;
|
||||
@ConfigRegistry(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorEnergyPerTick", comment = "Plasma Generator Energy Per Tick (Value in EU)")
|
||||
public static int energyPerTick = 400;
|
||||
|
||||
public PlasmaGeneratorBlockEntity() {
|
||||
super(TRBlockEntities.PLASMA_GENERATOR, EFluidGenerator.PLASMA, "PlasmaGeneratorBlockEntity", tankCapacity, energyPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
||||
return TRContent.Machine.PLASMA_GENERATOR.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("plasmagenerator").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
||||
.syncIntegerValue(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
||||
.syncIntegerValue(this::getTankAmount, this::setTankAmount)
|
||||
.addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator;
|
||||
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.blocks.generator.BlockSolarPanel;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRContent.SolarPanels;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop {
|
||||
|
||||
boolean canSeeSky = false;
|
||||
boolean lastState = false;
|
||||
SolarPanels panel;
|
||||
|
||||
public SolarPanelBlockEntity() {
|
||||
super(TRBlockEntities.SOLAR_PANEL);
|
||||
}
|
||||
|
||||
public boolean isSunOut() {
|
||||
return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDaylight();
|
||||
}
|
||||
|
||||
// TilePowerAcceptor
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
if (panel == TRContent.SolarPanels.CREATIVE) {
|
||||
checkOverfill = false;
|
||||
setEnergy(Integer.MAX_VALUE);
|
||||
return;
|
||||
}
|
||||
if (world.getTime() % 20 == 0) {
|
||||
canSeeSky = world.method_8626(pos.up());
|
||||
if (lastState != isSunOut()) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockSolarPanel.ACTIVE, isSunOut()));
|
||||
lastState = isSunOut();
|
||||
}
|
||||
}
|
||||
int powerToAdd;
|
||||
if (isSunOut()) {
|
||||
powerToAdd = panel.generationRateD;
|
||||
} else if (canSeeSky) {
|
||||
powerToAdd = panel.generationRateN;
|
||||
} else {
|
||||
powerToAdd = 0;
|
||||
}
|
||||
|
||||
addEnergy(powerToAdd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return panel.internalCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(final Direction direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(final Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return panel.generationRateD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return panel.powerTier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkTier() {
|
||||
// Nope
|
||||
}
|
||||
|
||||
// TODO: Translate
|
||||
@Override
|
||||
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
||||
info.add(new LiteralText(Formatting.GRAY + "Internal Energy Storage: " + Formatting.GOLD
|
||||
+ PowerSystem.getLocaliszedPowerFormatted((int) getMaxPower())));
|
||||
|
||||
info.add(new LiteralText(Formatting.GRAY + "Generation Rate Day: " + Formatting.GOLD
|
||||
+ PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD)));
|
||||
|
||||
info.add(new LiteralText(Formatting.GRAY + "Generation Rate Night: " + Formatting.GOLD
|
||||
+ PowerSystem.getLocaliszedPowerFormatted(panel.generationRateN)));
|
||||
|
||||
info.add(new LiteralText(Formatting.GRAY + "Tier: " + Formatting.GOLD
|
||||
+ StringUtils.toFirstCapitalAllLowercase(getTier().toString())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(CompoundTag tag) {
|
||||
if (world == null) {
|
||||
// We are in BlockEntity.create method during chunk load.
|
||||
this.checkOverfill = false;
|
||||
}
|
||||
super.fromTag(tag);
|
||||
}
|
||||
|
||||
// TileMachineBase
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
Block panelBlock = world.getBlockState(pos).getBlock();
|
||||
if (panelBlock instanceof BlockSolarPanel) {
|
||||
BlockSolarPanel solarPanelBlock = (BlockSolarPanel) panelBlock;
|
||||
panel = solarPanelBlock.panelType;
|
||||
}
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(final PlayerEntity playerIn) {
|
||||
return new ItemStack(getBlockType());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator.advanced;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||
|
||||
@RebornRegister(TechReborn.MOD_ID)
|
||||
public class DieselGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "generators", category = "diesel_generator", key = "DieselGeneratorMaxOutput", comment = "Diesel Generator Max Output (Value in EU)")
|
||||
public static int maxOutput = 128;
|
||||
@ConfigRegistry(config = "generators", category = "diesel_generator", key = "DieselGeneratorMaxEnergy", comment = "Diesel Generator Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 1_000_000;
|
||||
@ConfigRegistry(config = "generators", category = "diesel_generator", key = "DieselGeneratorTankCapacity", comment = "Diesel Generator Tank Capacity")
|
||||
public static int tankCapacity = 10_000;
|
||||
@ConfigRegistry(config = "generators", category = "diesel_generator", key = "DieselGeneratorEnergyPerTick", comment = "Diesel Generator Energy Per Tick (Value in EU)")
|
||||
public static int energyPerTick = 20;
|
||||
|
||||
public DieselGeneratorBlockEntity() {
|
||||
super(TRBlockEntities.DIESEL_GENERATOR, EFluidGenerator.DIESEL, "DieselGeneratorBlockEntity", tankCapacity, energyPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
|
||||
return TRContent.Machine.DIESEL_GENERATOR.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("dieselgenerator").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
||||
.syncIntegerValue(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
||||
.syncIntegerValue(this::getTankAmount, this::setTankAmount)
|
||||
.addInventory().create(this, syncID);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator.advanced;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
@RebornRegister(TechReborn.MOD_ID)
|
||||
public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
|
||||
implements IToolDrop, InventoryProvider {
|
||||
|
||||
@ConfigRegistry(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxOutput", comment = "Dragon Egg Siphoner Max Output (Value in EU)")
|
||||
public static int maxOutput = 128;
|
||||
@ConfigRegistry(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxEnergy", comment = "Dragon Egg Siphoner Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 1000;
|
||||
@ConfigRegistry(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerEnergyPerTick", comment = "Dragon Egg Siphoner Energy Per Tick (Value in EU)")
|
||||
public static int energyPerTick = 4;
|
||||
|
||||
public RebornInventory<DragonEggSyphonBlockEntity> inventory = new RebornInventory<>(3, "DragonEggSyphonBlockEntity", 64, this).withConfiguredAccess();
|
||||
private long lastOutput = 0;
|
||||
|
||||
public DragonEggSyphonBlockEntity() {
|
||||
super(TRBlockEntities.DRAGON_EGG_SYPHON);
|
||||
}
|
||||
|
||||
private boolean tryAddingEnergy(int amount) {
|
||||
if (this.getMaxPower() - this.getEnergy() >= amount) {
|
||||
addEnergy(amount);
|
||||
return true;
|
||||
} else if (this.getMaxPower() - this.getEnergy() > 0) {
|
||||
addEnergy(this.getMaxPower() - this.getEnergy());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// TilePowerAcceptor
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
if (!world.isClient) {
|
||||
if (world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
|
||||
.getBlock() == Blocks.DRAGON_EGG) {
|
||||
if (tryAddingEnergy(energyPerTick))
|
||||
lastOutput = world.getTime();
|
||||
}
|
||||
|
||||
if (world.getTime() - lastOutput < 30 && !isActive()) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
|
||||
} else if (world.getTime() - lastOutput > 30 && isActive()) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(Direction direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
|
||||
return TRContent.Machine.DRAGON_EGG_SYPHON.getStack();
|
||||
}
|
||||
|
||||
// ItemHandlerProvider
|
||||
@Override
|
||||
public RebornInventory<DragonEggSyphonBlockEntity> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator.advanced;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||
|
||||
@RebornRegister(TechReborn.MOD_ID)
|
||||
public class GasTurbineBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "generators", category = "gas_generator", key = "GasGeneratorMaxOutput", comment = "Gas Generator Max Output (Value in EU)")
|
||||
public static int maxOutput = 128;
|
||||
@ConfigRegistry(config = "generators", category = "gas_generator", key = "GasGeneratorMaxEnergy", comment = "Gas Generator Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 1000000;
|
||||
@ConfigRegistry(config = "generators", category = "gas_generator", key = "GasGeneratorTankCapacity", comment = "Gas Generator Tank Capacity")
|
||||
public static int tankCapacity = 10000;
|
||||
@ConfigRegistry(config = "generators", category = "gas_generator", key = "GasGeneratorEnergyPerTick", comment = "Gas Generator Energy Per Tick (Value in EU)")
|
||||
public static int energyPerTick = 16;
|
||||
|
||||
public GasTurbineBlockEntity() {
|
||||
super(TRBlockEntities.GAS_TURBINE, EFluidGenerator.GAS, "GasTurbineBlockEntity", tankCapacity, energyPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
|
||||
return TRContent.Machine.GAS_TURBINE.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("gasturbine").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
||||
.syncIntegerValue(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
||||
.syncIntegerValue(this::getTankAmount, this::setTankAmount)
|
||||
.addInventory().create(this, syncID);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator.advanced;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||
|
||||
@RebornRegister(TechReborn.MOD_ID)
|
||||
public class SemiFluidGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorMaxOutput", comment = "Semifluid Generator Max Output (Value in EU)")
|
||||
public static int maxOutput = 128;
|
||||
@ConfigRegistry(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorMaxEnergy", comment = "Semifluid Generator Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 1000000;
|
||||
@ConfigRegistry(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorTankCapacity", comment = "Semifluid Generator Tank Capacity")
|
||||
public static int tankCapacity = 10000;
|
||||
@ConfigRegistry(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorEnergyPerTick", comment = "Semifluid Generator Energy Per Tick (Value in EU)")
|
||||
public static int energyPerTick = 8;
|
||||
|
||||
public SemiFluidGeneratorBlockEntity() {
|
||||
super(TRBlockEntities.SEMI_FLUID_GENERATOR, EFluidGenerator.SEMIFLUID, "SemiFluidGeneratorBlockEntity", tankCapacity, energyPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
||||
return TRContent.Machine.SEMI_FLUID_GENERATOR.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("semifluidgenerator").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
||||
.syncIntegerValue(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
||||
.syncIntegerValue(this::getTankAmount, this::setTankAmount)
|
||||
.addInventory().create(this, syncID);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator.advanced;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||
|
||||
@RebornRegister(TechReborn.MOD_ID)
|
||||
public class ThermalGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "generators", category = "thermal_generator", key = "ThermalGeneratorMaxOutput", comment = "Thermal Generator Max Output (Value in EU)")
|
||||
public static int maxOutput = 128;
|
||||
@ConfigRegistry(config = "generators", category = "thermal_generator", key = "ThermalGeneratorMaxEnergy", comment = "Thermal Generator Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 1_000_000;
|
||||
@ConfigRegistry(config = "generators", category = "thermal_generator", key = "ThermalGeneratorTankCapacity", comment = "Thermal Generator Tank Capacity")
|
||||
public static int tankCapacity = 10_000;
|
||||
@ConfigRegistry(config = "generators", category = "thermal_generator", key = "ThermalGeneratorEnergyPerTick", comment = "Thermal Generator Energy Per Tick (Value in EU)")
|
||||
public static int energyPerTick = 16;
|
||||
|
||||
public ThermalGeneratorBlockEntity() {
|
||||
super(TRBlockEntities.THERMAL_GEN, EFluidGenerator.THERMAL, "ThermalGeneratorBlockEntity", tankCapacity, energyPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
|
||||
return TRContent.Machine.THERMAL_GENERATOR.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("thermalgenerator").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
|
||||
.syncIntegerValue(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
|
||||
.syncIntegerValue(this::getTankAmount, this::setTankAmount)
|
||||
.addInventory().create(this, syncID);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,191 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator.basic;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.FurnaceBlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BucketItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
@RebornRegister(TechReborn.MOD_ID)
|
||||
public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop, InventoryProvider, IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorMaxOutput", comment = "Solid Fuel Generator Max Output (Value in EU)")
|
||||
public static int maxOutput = 32;
|
||||
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorMaxEnergy", comment = "Solid Fuel Generator Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 10_000;
|
||||
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorEnergyOutput", comment = "Solid Fuel Generator Energy Output Amount (Value in EU)")
|
||||
public static int outputAmount = 10;
|
||||
|
||||
public RebornInventory<SolidFuelGeneratorBlockEntity> inventory = new RebornInventory<>(2, "SolidFuelGeneratorBlockEntity", 64, this).withConfiguredAccess();
|
||||
public int fuelSlot = 0;
|
||||
public int burnTime;
|
||||
public int totalBurnTime = 0;
|
||||
// sould properly use the conversion
|
||||
// ratio here.
|
||||
public boolean isBurning;
|
||||
public boolean lastTickBurning;
|
||||
ItemStack burnItem;
|
||||
|
||||
public SolidFuelGeneratorBlockEntity() {
|
||||
super(TRBlockEntities.SOLID_FUEL_GENEREATOR);
|
||||
}
|
||||
|
||||
public static int getItemBurnTime(ItemStack stack) {
|
||||
return FurnaceBlockEntity.createFuelTimeMap().get(stack) / 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
if (getEnergy() < getMaxPower()) {
|
||||
if (burnTime > 0) {
|
||||
burnTime--;
|
||||
addEnergy(SolidFuelGeneratorBlockEntity.outputAmount);
|
||||
isBurning = true;
|
||||
}
|
||||
} else {
|
||||
isBurning = false;
|
||||
}
|
||||
|
||||
if (burnTime == 0) {
|
||||
updateState();
|
||||
burnTime = totalBurnTime = SolidFuelGeneratorBlockEntity.getItemBurnTime(inventory.getInvStack(fuelSlot));
|
||||
if (burnTime > 0) {
|
||||
updateState();
|
||||
burnItem = inventory.getInvStack(fuelSlot);
|
||||
if (inventory.getInvStack(fuelSlot).getCount() == 1) {
|
||||
if (inventory.getInvStack(fuelSlot).getItem() == Items.LAVA_BUCKET || inventory.getInvStack(fuelSlot).getItem() instanceof BucketItem) {
|
||||
inventory.setInvStack(fuelSlot, new ItemStack(Items.BUCKET));
|
||||
} else {
|
||||
inventory.setInvStack(fuelSlot, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
} else {
|
||||
inventory.shrinkSlot(fuelSlot, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastTickBurning = isBurning;
|
||||
}
|
||||
|
||||
public void updateState() {
|
||||
final BlockState BlockStateContainer = world.getBlockState(pos);
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
|
||||
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
|
||||
if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != burnTime > 0) {
|
||||
blockMachineBase.setActive(burnTime > 0, world, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(Direction direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
||||
return TRContent.Machine.SOLID_FUEL_GENERATOR.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RebornInventory<SolidFuelGeneratorBlockEntity> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public int getBurnTime() {
|
||||
return burnTime;
|
||||
}
|
||||
|
||||
public void setBurnTime(final int burnTime) {
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
public int getTotalBurnTime() {
|
||||
return totalBurnTime;
|
||||
}
|
||||
|
||||
public void setTotalBurnTime(final int totalBurnTime) {
|
||||
this.totalBurnTime = totalBurnTime;
|
||||
}
|
||||
|
||||
public int getScaledBurnTime(final int i) {
|
||||
return (int) ((float) burnTime / (float) totalBurnTime * i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("generator").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).fuelSlot(0, 80, 54).energySlot(1, 8, 72).syncEnergyValue()
|
||||
.syncIntegerValue(this::getBurnTime, this::setBurnTime)
|
||||
.syncIntegerValue(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator.basic;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.blocks.generator.BlockWindMill;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 25/02/2016.
|
||||
*/
|
||||
|
||||
@RebornRegister(TechReborn.MOD_ID)
|
||||
public class WaterMillBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop {
|
||||
|
||||
@ConfigRegistry(config = "generators", category = "water_mill", key = "WaterMillMaxOutput", comment = "Water Mill Max Output (Value in EU)")
|
||||
public static int maxOutput = 32;
|
||||
@ConfigRegistry(config = "generators", category = "water_mill", key = "WaterMillMaxEnergy", comment = "Water Mill Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 1000;
|
||||
@ConfigRegistry(config = "generators", category = "water_mill", key = "WaterMillEnergyPerTick", comment = "Water Mill Energy Multiplier")
|
||||
public static double energyMultiplier = 0.1;
|
||||
|
||||
int waterblocks = 0;
|
||||
|
||||
public WaterMillBlockEntity() {
|
||||
super(TRBlockEntities.WATER_MILL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (world.getTime() % 20 == 0) {
|
||||
checkForWater();
|
||||
}
|
||||
if (waterblocks > 0) {
|
||||
addEnergy(waterblocks * energyMultiplier);
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockWindMill.ACTIVE, true));
|
||||
}
|
||||
else {
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockWindMill.ACTIVE, false));
|
||||
}
|
||||
}
|
||||
|
||||
public void checkForWater() {
|
||||
waterblocks = 0;
|
||||
for (Direction facing : Direction.values()) {
|
||||
if (facing.getAxis().isHorizontal() && world.getBlockState(pos.offset(facing)).getBlock() == Blocks.WATER) {
|
||||
waterblocks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(Direction direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
||||
return TRContent.Machine.WATER_MILL.getStack();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.generator.basic;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 25/02/2016.
|
||||
*/
|
||||
|
||||
@RebornRegister(TechReborn.MOD_ID)
|
||||
public class WindMillBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop {
|
||||
|
||||
@ConfigRegistry(config = "generators", category = "wind_mill", key = "WindMillMaxOutput", comment = "Wind Mill Max Output (Value in EU)")
|
||||
public static int maxOutput = 128;
|
||||
@ConfigRegistry(config = "generators", category = "wind_mill", key = "WindMillMaxEnergy", comment = "Wind Mill Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 10_000;
|
||||
@ConfigRegistry(config = "generators", category = "wind_mill", key = "WindMillEnergyPerTick", comment = "Wind Mill Energy Per Tick (Value in EU)")
|
||||
public static int baseEnergy = 2;
|
||||
@ConfigRegistry(config = "generators", category = "wind_mill", key = "WindMillThunderMultiplier", comment = "Wind Mill Thunder Multiplier")
|
||||
public static double thunderMultiplier = 1.25;
|
||||
|
||||
public WindMillBlockEntity() {
|
||||
super(TRBlockEntities.WIND_MILL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (pos.getY() > 64) {
|
||||
int actualPower = baseEnergy;
|
||||
if (world.isThundering()) {
|
||||
actualPower *= thunderMultiplier;
|
||||
}
|
||||
addEnergy(actualPower); // Value taken from
|
||||
// http://wiki.industrial-craft.net/?title=Wind_Mill
|
||||
// Not worth making more complicated
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(Direction direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
||||
return TRContent.Machine.WIND_MILL.getStack();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue