boiler finished

This commit is contained in:
yuesha-yc 2021-10-23 23:25:53 -07:00
parent ef73de7563
commit d16761dd76
No known key found for this signature in database
GPG key ID: 009D79A802D4ED01
5 changed files with 10 additions and 65 deletions

View file

@ -138,7 +138,7 @@ public abstract class BoilerTileEntity extends TileEntity implements IHeatReceiv
int consume = Math.min(getHUPerTick(), heatreceived); int consume = Math.min(getHUPerTick(), heatreceived);
heatreceived = 0; heatreceived = 0;
consume = Math.min(this.input.drain(consume / 120, FluidAction.EXECUTE).getAmount() * 120, consume); consume = Math.min(this.input.drain(consume / 120, FluidAction.EXECUTE).getAmount() * 120, consume);
this.output.fill(new FluidStack(FluidRegistry.steam.get().getFluid(), consume), FluidAction.EXECUTE); this.output.fill(new FluidStack(FluidRegistry.steam.get().getFluid(), consume / 10), FluidAction.EXECUTE);
this.level.sendBlockUpdated(this.getBlockPos(), this.level.getBlockState(this.getBlockPos()), this.level.getBlockState(this.getBlockPos()), 3); this.level.sendBlockUpdated(this.getBlockPos(), this.level.getBlockState(this.getBlockPos()), this.level.getBlockState(this.getBlockPos()), 3);
} }
} }
@ -172,30 +172,4 @@ public abstract class BoilerTileEntity extends TileEntity implements IHeatReceiv
}); });
oldCap.invalidate(); oldCap.invalidate();
} }
// public void syncFluidContent() {
// CompoundNBT nbt = new CompoundNBT();
// nbt.put("in", input.writeToNBT(new CompoundNBT()));
// nbt.put("out", output.writeToNBT(new CompoundNBT()));
// PacketHandler.send(PacketDistributor.TRACKING_CHUNK.with(() -> {
// return this.level.getChunkAt(this.worldPosition);
// }), new TileSyncPacket(this, nbt));
// }
//
// public void receiveFromServer(CompoundNBT message) {
// if (message.contains("in", 10)) {
// this.input.readFromNBT(message.getCompound("in"));
// }
// if (message.contains("out", 10)) {
// this.input.readFromNBT(message.getCompound("out"));
// }
// }
//
// public void receiveFromClient(CompoundNBT message) {
//
// }
//
// public BlockPos getSyncPos() {
// return this.getBlockPos();
// }
} }

View file

@ -142,9 +142,8 @@ public abstract class BurnerTileEntity extends TileEntity implements ITickableTi
@Override @Override
public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) { public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) {
tooltip.add(componentSpacing.plainCopy().append(new TranslationTextComponent("tooltip.steampowered.burner.hu", HURemain).withStyle(TextFormatting.GREEN))); tooltip.add(componentSpacing.plainCopy().append(new TranslationTextComponent("tooltip.steampowered.burner.hu", HURemain).withStyle(TextFormatting.GOLD)));
tooltip.add(componentSpacing.plainCopy().append(new TranslationTextComponent("tooltip.steampowered.burner.item", inv.getStackInSlot(0).getItem().getName(inv.getStackInSlot(0)), inv.getStackInSlot(0).getCount()).withStyle(TextFormatting.GREEN))); tooltip.add(componentSpacing.plainCopy().append(new TranslationTextComponent("tooltip.steampowered.burner.item", inv.getStackInSlot(0).getCount(), inv.getStackInSlot(0).getItem().getName(inv.getStackInSlot(0))).withStyle(TextFormatting.GRAY)));
return true; return true;
} }

View file

@ -7,9 +7,6 @@ import com.simibubi.create.content.contraptions.components.flywheel.engine.Engin
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.teammoeg.steampowered.FluidRegistry; import com.teammoeg.steampowered.FluidRegistry;
import com.teammoeg.steampowered.block.engine.SteamEngineBlock; import com.teammoeg.steampowered.block.engine.SteamEngineBlock;
import com.teammoeg.steampowered.network.ITileSync;
import com.teammoeg.steampowered.network.PacketHandler;
import com.teammoeg.steampowered.network.TileSyncPacket;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
@ -25,18 +22,16 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.data.ForgeFluidTagsProvider;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.templates.FluidTank; import net.minecraftforge.fluids.capability.templates.FluidTank;
import net.minecraftforge.fml.network.PacketDistributor;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public abstract class SteamEngineTileEntity extends EngineTileEntity implements IHaveGoggleInformation, ITileSync { public abstract class SteamEngineTileEntity extends EngineTileEntity implements IHaveGoggleInformation {
private FluidTank tank; private FluidTank tank;
private LazyOptional<IFluidHandler> holder = LazyOptional.of(() -> tank); private LazyOptional<IFluidHandler> holder = LazyOptional.of(() -> tank);
@ -48,11 +43,7 @@ public abstract class SteamEngineTileEntity extends EngineTileEntity implements
ITag<Fluid> steamTag = FluidTags.getAllTags().getTag(new ResourceLocation("forge", "steam")); ITag<Fluid> steamTag = FluidTags.getAllTags().getTag(new ResourceLocation("forge", "steam"));
if (steamTag != null) return fluidStack.getFluid().is(steamTag); if (steamTag != null) return fluidStack.getFluid().is(steamTag);
else return fluidStack.getFluid() == FluidRegistry.steam.get(); else return fluidStack.getFluid() == FluidRegistry.steam.get();
}) { });
protected void onContentsChanged() {
syncFluidContent();
}
};
} }
@Override @Override
@ -116,28 +107,6 @@ public abstract class SteamEngineTileEntity extends EngineTileEntity implements
oldCap.invalidate(); oldCap.invalidate();
} }
public void syncFluidContent() {
CompoundNBT nbt = new CompoundNBT();
nbt.put("tank", tank.writeToNBT(new CompoundNBT()));
PacketHandler.send(PacketDistributor.TRACKING_CHUNK.with(() -> {
return this.level.getChunkAt(this.worldPosition);
}), new TileSyncPacket(this, nbt));
}
public void receiveFromServer(CompoundNBT message) {
if (message.contains("tank", 10)) {
this.tank.readFromNBT(message.getCompound("tank"));
}
}
public void receiveFromClient(CompoundNBT message) {
}
public BlockPos getSyncPos() {
return this.getBlockPos();
}
public void attachWheel() { public void attachWheel() {
Direction engineFacing = (Direction) this.getBlockState().getValue(EngineBlock.FACING); Direction engineFacing = (Direction) this.getBlockState().getValue(EngineBlock.FACING);
BlockPos wheelPos = this.worldPosition.relative(engineFacing, 2); BlockPos wheelPos = this.worldPosition.relative(engineFacing, 2);

View file

@ -59,5 +59,5 @@
"steampowered.ponder.tag.steam.description": "Components related to steam production and usage", "steampowered.ponder.tag.steam.description": "Components related to steam production and usage",
"tooltip.steampowered.burner.hu": "Heat Remaining: %s HU", "tooltip.steampowered.burner.hu": "Heat Remaining: %s HU",
"tooltip.steampowered.burner.item" : "Fuel Remaining: %s %s" "tooltip.steampowered.burner.item" : "Fuel Remaining: %s x %s"
} }

View file

@ -56,5 +56,8 @@
"steampowered.ponder.alternator.text_3": "它产生能量的多少是由输入的转速决定的", "steampowered.ponder.alternator.text_3": "它产生能量的多少是由输入的转速决定的",
"steampowered.ponder.tag.steam": "蒸汽", "steampowered.ponder.tag.steam": "蒸汽",
"steampowered.ponder.tag.steam.description": "使用或生产蒸汽的组件" "steampowered.ponder.tag.steam.description": "使用或生产蒸汽的组件",
"tooltip.steampowered.burner.hu": "剩余热量: %s HU",
"tooltip.steampowered.burner.item" : "燃料: %s x %s"
} }