fix inifite power
This commit is contained in:
parent
c10e3a34e6
commit
720c6f22e6
|
@ -48,6 +48,7 @@ import net.minecraftforge.common.capabilities.Capability;
|
|||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
|
||||
public abstract class SteamEngineTileEntity extends EngineTileEntity implements IHaveGoggleInformation {
|
||||
|
@ -70,22 +71,26 @@ public abstract class SteamEngineTileEntity extends EngineTileEntity implements
|
|||
super.tick();
|
||||
if (level != null && !level.isClientSide) {
|
||||
BlockState state = this.level.getBlockState(this.worldPosition);
|
||||
if (!tank.isEmpty()&&tank.drain(this.getSteamConsumptionPerTick(), IFluidHandler.FluidAction.EXECUTE).getAmount() >= this.getSteamConsumptionPerTick()) {
|
||||
this.level.setBlockAndUpdate(this.worldPosition, state.setValue(SteamEngineBlock.LIT, true));
|
||||
if(heatup>=60) {
|
||||
this.appliedCapacity = this.getGeneratingCapacity();
|
||||
this.appliedSpeed = this.getGeneratingSpeed();
|
||||
this.refreshWheelSpeed();
|
||||
}else
|
||||
heatup++;
|
||||
}else {
|
||||
if(heatup>0)
|
||||
heatup--;
|
||||
this.level.setBlockAndUpdate(this.worldPosition, state.setValue(SteamEngineBlock.LIT, false));
|
||||
this.appliedCapacity = 0;
|
||||
this.appliedSpeed = 0;
|
||||
this.refreshWheelSpeed();
|
||||
}
|
||||
if(this.poweredWheel==null||this.poweredWheel.isRemoved()) {
|
||||
heatup=0;
|
||||
} else {
|
||||
if (!tank.isEmpty()&&tank.drain(this.getSteamConsumptionPerTick(), IFluidHandler.FluidAction.EXECUTE).getAmount() >= this.getSteamConsumptionPerTick()) {
|
||||
this.level.setBlockAndUpdate(this.worldPosition, state.setValue(SteamEngineBlock.LIT, true));
|
||||
if(heatup>=60) {
|
||||
this.appliedCapacity = this.getGeneratingCapacity();
|
||||
this.appliedSpeed = this.getGeneratingSpeed();
|
||||
this.refreshWheelSpeed();
|
||||
}else
|
||||
heatup++;
|
||||
}else {
|
||||
if(heatup>0)
|
||||
heatup--;
|
||||
this.level.setBlockAndUpdate(this.worldPosition, state.setValue(SteamEngineBlock.LIT, false));
|
||||
this.appliedCapacity = 0;
|
||||
this.appliedSpeed = 0;
|
||||
this.refreshWheelSpeed();
|
||||
}
|
||||
}
|
||||
this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,14 @@ import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity
|
|||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineBlock;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineTileEntity;
|
||||
import com.teammoeg.steampowered.content.engine.SteamEngineTileEntity;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@Mixin(FlywheelTileEntity.class)
|
||||
public abstract class MixinFlywheel extends GeneratingKineticTileEntity{
|
||||
|
@ -26,9 +31,20 @@ public abstract class MixinFlywheel extends GeneratingKineticTileEntity{
|
|||
public void sp$tick(CallbackInfo cbi) {
|
||||
Direction at=FlywheelBlock.getConnection(getBlockState());
|
||||
if(at!=null) {
|
||||
if(!(this.getWorld().getBlockState(this.getBlockPos().relative(at,2)).getBlock() instanceof EngineBlock)) {
|
||||
BlockPos eng=this.getBlockPos().relative(at,2);
|
||||
Block b=this.getWorld().getBlockState(eng).getBlock();
|
||||
if(!(b instanceof EngineBlock)) {
|
||||
FlywheelBlock.setConnection(getWorld(),getBlockPos(),getBlockState(),null);
|
||||
this.setRotation(0,0);
|
||||
}else {
|
||||
TileEntity te=this.getWorld().getBlockEntity(eng);
|
||||
if(te instanceof EngineTileEntity) {
|
||||
if(te instanceof SteamEngineTileEntity) {
|
||||
SteamEngineTileEntity ete=(SteamEngineTileEntity) te;
|
||||
if(ete.getFlywheel()!=this.getBlockState().getBlock())
|
||||
this.setRotation(0,0);
|
||||
}
|
||||
}else this.setRotation(0,0);
|
||||
}
|
||||
}else this.setRotation(0,0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue