20w17a compile pass
This commit is contained in:
parent
178e0937d5
commit
7ccd5bcebd
68 changed files with 868 additions and 658 deletions
|
@ -34,6 +34,7 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Tickable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
@ -173,13 +174,27 @@ public class CableBlockEntity extends BlockEntity
|
|||
// IListInfoProvider
|
||||
@Override
|
||||
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.transferRate") + ": "
|
||||
+ Formatting.GOLD
|
||||
+ PowerSystem.getLocaliszedPowerFormatted(getCableType().transferRate) + "/t"));
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.tier") + ": "
|
||||
+ Formatting.GOLD + StringUtils.toFirstCapitalAllLowercase(getCableType().tier.toString())));
|
||||
info.add(
|
||||
new TranslatableText("techreborn.tooltip.transferRate")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(": ")
|
||||
.append(PowerSystem.getLocaliszedPowerFormatted(getCableType().transferRate))
|
||||
.formatted(Formatting.GOLD)
|
||||
.append("/t")
|
||||
);
|
||||
|
||||
info.add(
|
||||
new TranslatableText("techreborn.tooltip.tier")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(": ")
|
||||
.append(
|
||||
new LiteralText(StringUtils.toFirstCapitalAllLowercase(getCableType().tier.toString()))
|
||||
.formatted(Formatting.GOLD)
|
||||
)
|
||||
);
|
||||
|
||||
if (!getCableType().canKill) {
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.cable.can_cover")));
|
||||
info.add(new TranslatableText("techreborn.tooltip.cable.can_cover").formatted(Formatting.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
package techreborn.blockentity.data;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
|
@ -41,20 +42,20 @@ public class DataDrivenGui extends GuiBase<BuiltScreenHandler> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(final float f, final int mouseX, final int mouseY) {
|
||||
super.drawBackground(f, mouseX, mouseY);
|
||||
protected void drawBackground(MatrixStack matrixStack, final float f, final int mouseX, final int mouseY) {
|
||||
super.drawBackground(matrixStack, f, mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
|
||||
final DataDrivenGui gui = this;
|
||||
|
||||
provider.getSlots().forEach(slot -> slot.draw(gui, layer));
|
||||
provider.getSlots().forEach(slot -> slot.draw(matrixStack, gui, layer));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawForeground(final int mouseX, final int mouseY) {
|
||||
super.drawForeground(mouseX, mouseY);
|
||||
protected void drawForeground(MatrixStack matrixStack, final int mouseX, final int mouseY) {
|
||||
super.drawForeground(matrixStack, mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||
|
||||
builder.drawProgressBar(this, blockEntity.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawMultiEnergyBar(this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawMultiEnergyBar(matrixStack, this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ import com.google.gson.JsonArray;
|
|||
import com.google.gson.JsonElement;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import reborncore.client.screen.builder.BlockEntityScreenHandlerBuilder;
|
||||
|
@ -82,12 +83,12 @@ public class DataDrivenSlot {
|
|||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void draw(GuiBase<?> guiBase, GuiBase.Layer layer){
|
||||
public void draw(MatrixStack matrixStack, GuiBase<?> guiBase, GuiBase.Layer layer){
|
||||
//TODO find a better way to do this
|
||||
if(getType() == SlotType.OUTPUT){
|
||||
guiBase.drawOutputSlot(getX(), getY(), layer);
|
||||
guiBase.drawOutputSlot(matrixStack, getX(), getY(), layer);
|
||||
} else {
|
||||
guiBase.drawSlot(getX(), getY(), layer);
|
||||
guiBase.drawSlot(matrixStack, getX(), getY(), layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
|
@ -215,17 +216,46 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
if (panel == SolarPanels.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("reborncore.tooltip.energy.maxEnergy") + ": "
|
||||
+ Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted(getMaxPower())));
|
||||
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.generationRate.day") + ": "
|
||||
+ Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD)));
|
||||
info.add(
|
||||
new TranslatableText("reborncore.tooltip.energy.maxEnergy")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(": ")
|
||||
.append(
|
||||
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(getMaxPower()))
|
||||
.formatted(Formatting.GOLD)
|
||||
)
|
||||
);
|
||||
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.generationRate.night") + ": "
|
||||
+ Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateN)));
|
||||
info.add(
|
||||
new TranslatableText("techreborn.tooltip.generationRate.day")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(": ")
|
||||
.append(
|
||||
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD))
|
||||
.formatted(Formatting.GOLD)
|
||||
)
|
||||
);
|
||||
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("reborncore.tooltip.energy.tier") + ": "
|
||||
+ Formatting.GOLD + StringUtils.toFirstCapitalAllLowercase(getTier().toString())));
|
||||
info.add(
|
||||
new TranslatableText("techreborn.tooltip.generationRate.night")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(": ")
|
||||
.append(
|
||||
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(panel.generationRateN))
|
||||
.formatted(Formatting.GOLD)
|
||||
)
|
||||
);
|
||||
|
||||
info.add(
|
||||
new TranslatableText("reborncore.tooltip.energy.tier")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(": ")
|
||||
.append(
|
||||
new LiteralText(StringUtils.toFirstCapitalAllLowercase(getTier().toString()))
|
||||
.formatted(Formatting.GOLD)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Tickable;
|
||||
import reborncore.api.IToolDrop;
|
||||
|
@ -60,8 +61,11 @@ public class AlarmBlockEntity extends BlockEntity
|
|||
} else {
|
||||
selectedSound = 1;
|
||||
}
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.alarm") + " " + "Alarm " + selectedSound));
|
||||
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new TranslatableText("techreborn.message.alarm")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" Alarm ")
|
||||
.append(String.valueOf(selectedSound)));
|
||||
}
|
||||
|
||||
// BlockEntity
|
||||
|
|
|
@ -28,6 +28,8 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
@ -41,6 +43,7 @@ import reborncore.common.crafting.ingredient.RebornIngredient;
|
|||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import reborncore.common.util.Torus;
|
||||
import techreborn.api.recipe.recipes.FusionReactorRecipe;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -484,22 +487,23 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
|||
.orElse(null);
|
||||
}
|
||||
|
||||
public String getStateString(){
|
||||
public Text getStateText(){
|
||||
if(state == -1){
|
||||
return "";
|
||||
return LiteralText.EMPTY;
|
||||
} else if (state == 0){
|
||||
return "No recipe";
|
||||
return new LiteralText("No recipe");
|
||||
} else if (state == 1){
|
||||
FusionReactorRecipe r = getCurrentRecipeFromID();
|
||||
if(r == null) {
|
||||
return "Charging";
|
||||
return new LiteralText("Charging");
|
||||
}
|
||||
int percentage = percentage(r.getStartEnergy(), getEnergy());
|
||||
return "Charging (" + percentage + "%)";
|
||||
return new LiteralText("Charging (")
|
||||
.append(StringUtils.getPercentageText(percentage));
|
||||
} else if (state == 2){
|
||||
return "Crafting";
|
||||
return new LiteralText("Crafting");
|
||||
}
|
||||
return "";
|
||||
return LiteralText.EMPTY;
|
||||
}
|
||||
|
||||
private int percentage(double MaxValue, double CurrentValue) {
|
||||
|
|
|
@ -25,15 +25,21 @@
|
|||
package techreborn.blockentity.storage.energy.idsu;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.PersistentState;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.util.NBTSerializable;
|
||||
import reborncore.common.world.DataAttachment;
|
||||
import reborncore.common.world.DataAttachmentProvider;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class IDSUManager implements DataAttachment {
|
||||
public class IDSUManager extends PersistentState {
|
||||
|
||||
private static final String KEY = "techreborn_idsu";
|
||||
|
||||
public IDSUManager() {
|
||||
super(KEY);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static IDSUPlayer getPlayer(World world, String uuid){
|
||||
|
@ -41,7 +47,8 @@ public class IDSUManager implements DataAttachment {
|
|||
}
|
||||
|
||||
public static IDSUManager get(World world){
|
||||
return DataAttachmentProvider.get(world, IDSUManager.class);
|
||||
ServerWorld serverWorld = (ServerWorld) world;
|
||||
return serverWorld.getPersistentStateManager().getOrCreate(IDSUManager::new, KEY);
|
||||
}
|
||||
|
||||
private final HashMap<String, IDSUPlayer> playerHashMap = new HashMap<>();
|
||||
|
@ -52,21 +59,19 @@ public class IDSUManager implements DataAttachment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void read(@Nonnull CompoundTag tag) {
|
||||
public void fromTag(CompoundTag tag) {
|
||||
for(String uuid : tag.getKeys()){
|
||||
playerHashMap.put(uuid, new IDSUPlayer(tag.getCompound(uuid)));
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag write() {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
playerHashMap.forEach((uuid, player) -> tag.put(uuid, player.write()));
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static class IDSUPlayer implements NBTSerializable {
|
||||
public class IDSUPlayer implements NBTSerializable {
|
||||
|
||||
private double energy;
|
||||
|
||||
|
@ -96,6 +101,7 @@ public class IDSUManager implements DataAttachment {
|
|||
|
||||
public void setEnergy(double energy) {
|
||||
this.energy = energy;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,12 +155,26 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
|
|||
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
|
||||
if (isReal || hasData) {
|
||||
if (!this.tank.getFluidInstance().isEmpty()) {
|
||||
info.add(new LiteralText(this.tank.getFluidAmount() + StringUtils.t("techreborn.tooltip.unit.divider") + WordUtils.capitalize(FluidUtil.getFluidName(this.tank.getFluid()))));
|
||||
info.add(
|
||||
new LiteralText(String.valueOf(this.tank.getFluidAmount()))
|
||||
.append(new TranslatableText("techreborn.tooltip.unit.divider"))
|
||||
.append(WordUtils.capitalize(FluidUtil.getFluidName(this.tank.getFluid())))
|
||||
);
|
||||
} else {
|
||||
info.add(new TranslatableText("techreborn.tooltip.unit.empty"));
|
||||
}
|
||||
}
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.unit.capacity") + Formatting.GOLD + this.tank.getCapacity() + " (" + this.tank.getCapacity().getRawValue() / 1000 + ")"));
|
||||
info.add(
|
||||
new TranslatableText("techreborn.tooltip.unit.capacity")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(
|
||||
new LiteralText(String.valueOf(this.tank.getCapacity()))
|
||||
.formatted(Formatting.GOLD)
|
||||
.append(" (")
|
||||
.append(String.valueOf(this.tank.getCapacity().getRawValue() / 1000))
|
||||
.append(")")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
|
|
|
@ -332,14 +332,27 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
|||
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
|
||||
if (isReal || hasData) {
|
||||
if (!this.isEmpty()) {
|
||||
info.add(new LiteralText(this.getCurrentCapacity() + StringUtils.t("techreborn.tooltip.unit.divider") + this.getStoredStack().getName().asString()));
|
||||
info.add(
|
||||
new LiteralText(String.valueOf(this.getCurrentCapacity()))
|
||||
.append(new TranslatableText("techreborn.tooltip.unit.divider"))
|
||||
.append(this.getStoredStack().getName())
|
||||
);
|
||||
} else {
|
||||
info.add(new TranslatableText("techreborn.tooltip.unit.empty"));
|
||||
}
|
||||
}
|
||||
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.unit.capacity") + Formatting.GOLD + this.getMaxCapacity() +
|
||||
" items (" + this.getMaxCapacity() / 64 + ")"));
|
||||
info.add(
|
||||
new TranslatableText("techreborn.tooltip.unit.capacity")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(
|
||||
new LiteralText(String.valueOf(this.getMaxCapacity()))
|
||||
.formatted(Formatting.GOLD)
|
||||
.append(" items (")
|
||||
.append(String.valueOf(this.getMaxCapacity() / 64))
|
||||
.append(")")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue