mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-14 08:43:51 +01:00
Boiler heater API
- Add API for boiler heaters - Simplify some component creation
This commit is contained in:
parent
c36c4e756e
commit
c491dd8f13
20 changed files with 161 additions and 119 deletions
|
@ -12,6 +12,7 @@ import com.simibubi.create.compat.Mods;
|
|||
import com.simibubi.create.compat.curios.Curios;
|
||||
import com.simibubi.create.content.CreateItemGroup;
|
||||
import com.simibubi.create.content.contraptions.TorquePropagator;
|
||||
import com.simibubi.create.content.contraptions.fluids.tank.BoilerHeaters;
|
||||
import com.simibubi.create.content.curiosities.weapons.BuiltinPotatoProjectileTypes;
|
||||
import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler;
|
||||
import com.simibubi.create.content.logistics.block.display.AllDisplayBehaviours;
|
||||
|
@ -139,6 +140,7 @@ public class Create {
|
|||
SchematicProcessor.register();
|
||||
AllWorldFeatures.registerFeatures();
|
||||
AllWorldFeatures.registerPlacementTypes();
|
||||
BoilerHeaters.registerDefaults();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement;
|
||||
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class AssemblyException extends Exception {
|
||||
|
@ -45,13 +45,12 @@ public class AssemblyException extends Exception {
|
|||
}
|
||||
|
||||
public AssemblyException(String langKey, Object... objects) {
|
||||
this(new TranslatableComponent("create.gui.assembly.exception." + langKey, objects));
|
||||
this(Lang.translateDirect("gui.assembly.exception." + langKey, objects));
|
||||
}
|
||||
|
||||
public static AssemblyException unmovableBlock(BlockPos pos, BlockState state) {
|
||||
AssemblyException e = new AssemblyException("unmovableBlock", pos.getX(), pos.getY(), pos.getZ(),
|
||||
new TranslatableComponent(state.getBlock()
|
||||
.getDescriptionId()));
|
||||
state.getBlock().getName());
|
||||
e.position = pos;
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import com.simibubi.create.foundation.utility.Lang;
|
|||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -73,10 +72,9 @@ public class FillingRecipe extends ProcessingRecipe<RecipeWrapper> implements IA
|
|||
if (matchingFluidStacks.size() == 0)
|
||||
return new TextComponent("Invalid");
|
||||
return Lang.translateDirect("recipe.assembly.spout_filling_fluid",
|
||||
new TranslatableComponent(matchingFluidStacks.get(0)
|
||||
.getTranslationKey()).getString());
|
||||
matchingFluidStacks.get(0).getDisplayName().getString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addRequiredMachines(Set<ItemLike> list) {
|
||||
list.add(AllBlocks.SPOUT.get());
|
||||
|
|
|
@ -333,12 +333,12 @@ public class BoilerData {
|
|||
for (int zOffset = 0; zOffset < controller.width; zOffset++) {
|
||||
BlockPos pos = controllerPos.offset(xOffset, -1, zOffset);
|
||||
BlockState blockState = level.getBlockState(pos);
|
||||
float heat = BoilerHeaters.getActiveHeatOf(blockState);
|
||||
float heat = BoilerHeaters.getActiveHeat(level, pos, blockState);
|
||||
if (heat == 0) {
|
||||
passiveHeat |= BoilerHeaters.canHeatPassively(blockState);
|
||||
continue;
|
||||
passiveHeat = true;
|
||||
} else if (heat > 0) {
|
||||
activeHeat += heat;
|
||||
}
|
||||
activeHeat += heat;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,39 +1,90 @@
|
|||
package com.simibubi.create.content.contraptions.fluids.tank;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllTags.AllBlockTags;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class BoilerHeaters { // API?
|
||||
public class BoilerHeaters {
|
||||
private static final Map<IRegistryDelegate<Block>, Heater> BLOCK_HEATERS = new HashMap<>();
|
||||
private static final List<HeaterProvider> GLOBAL_HEATERS = new ArrayList<>();
|
||||
|
||||
public static boolean canHeatPassively(BlockState state) {
|
||||
if (AllBlocks.BLAZE_BURNER.has(state))
|
||||
return state.getValue(BlazeBurnerBlock.HEAT_LEVEL) != HeatLevel.NONE;
|
||||
if (AllBlockTags.PASSIVE_BOILER_HEATERS.matches(state))
|
||||
return true;
|
||||
return false;
|
||||
public static void registerHeater(IRegistryDelegate<Block> block, Heater heater) {
|
||||
BLOCK_HEATERS.put(block, heater);
|
||||
}
|
||||
|
||||
public static int getActiveHeatOf(BlockState state) {
|
||||
if (AllBlocks.BLAZE_BURNER.has(state)) {
|
||||
HeatLevel value = state.getValue(BlazeBurnerBlock.HEAT_LEVEL);
|
||||
switch (value) {
|
||||
case FADING:
|
||||
case KINDLED:
|
||||
return 1;
|
||||
case SEETHING:
|
||||
return 2;
|
||||
default:
|
||||
case SMOULDERING:
|
||||
case NONE:
|
||||
return 0;
|
||||
public static void registerHeaterProvider(HeaterProvider provider) {
|
||||
GLOBAL_HEATERS.add(provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* A return value of {@code -1} represents no heat.
|
||||
* A return value of {@code 0} represents passive heat.
|
||||
* All other positive values are used as the amount of active heat.
|
||||
*/
|
||||
public static float getActiveHeat(Level level, BlockPos pos, BlockState state) {
|
||||
Heater heater = BLOCK_HEATERS.get(state.getBlock().delegate);
|
||||
if (heater != null) {
|
||||
return heater.getActiveHeat(level, pos, state);
|
||||
}
|
||||
|
||||
for (HeaterProvider provider : GLOBAL_HEATERS) {
|
||||
heater = provider.getHeater(level, pos, state);
|
||||
if (heater != null) {
|
||||
return heater.getActiveHeat(level, pos, state);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void registerDefaults() {
|
||||
registerHeater(AllBlocks.BLAZE_BURNER.get().delegate, (level, pos, state) -> {
|
||||
HeatLevel value = state.getValue(BlazeBurnerBlock.HEAT_LEVEL);
|
||||
if (value == HeatLevel.NONE) {
|
||||
return -1;
|
||||
}
|
||||
if (value == HeatLevel.SEETHING) {
|
||||
return 2;
|
||||
}
|
||||
if (value.isAtLeast(HeatLevel.FADING)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
registerHeaterProvider((level, pos, state) -> {
|
||||
if (AllBlockTags.PASSIVE_BOILER_HEATERS.matches(state)) {
|
||||
return (level1, pos1, state1) -> 0;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public interface Heater {
|
||||
/**
|
||||
* A return value of {@code -1} represents no heat.
|
||||
* A return value of {@code 0} represents passive heat.
|
||||
* All other positive values are used as the amount of active heat.
|
||||
*/
|
||||
float getActiveHeat(Level level, BlockPos pos, BlockState state);
|
||||
}
|
||||
|
||||
public interface HeaterProvider {
|
||||
@Nullable
|
||||
Heater getHeater(Level level, BlockPos pos, BlockState state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.Nameable;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
@ -141,8 +140,8 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements Namea
|
|||
@Override
|
||||
public Component getName() {
|
||||
return this.customName != null ? this.customName
|
||||
: new TranslatableComponent(AllItems.COPPER_BACKTANK.get()
|
||||
.getDescriptionId());
|
||||
: AllItems.COPPER_BACKTANK.get()
|
||||
.getDescription();
|
||||
}
|
||||
|
||||
public int getAirLevel() {
|
||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
|
@ -392,9 +391,9 @@ public class ToolboxTileEntity extends SmartTileEntity implements MenuProvider,
|
|||
@Override
|
||||
public Component getDisplayName() {
|
||||
return customName != null ? customName
|
||||
: new TranslatableComponent(AllBlocks.TOOLBOXES.get(getColor())
|
||||
: AllBlocks.TOOLBOXES.get(getColor())
|
||||
.get()
|
||||
.getDescriptionId());
|
||||
.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,7 +29,6 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
|
@ -544,8 +543,8 @@ public class BlueprintEntity extends HangingEntity
|
|||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return new TranslatableComponent(AllItems.CRAFTING_BLUEPRINT.get()
|
||||
.getDescriptionId());
|
||||
return AllItems.CRAFTING_BLUEPRINT.get()
|
||||
.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
|
@ -54,14 +54,14 @@ public abstract class ZapperItem extends Item {
|
|||
public void appendHoverText(ItemStack stack, Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
||||
if (stack.hasTag() && stack.getTag()
|
||||
.contains("BlockUsed")) {
|
||||
String usedblock = NbtUtils.readBlockState(stack.getTag()
|
||||
MutableComponent usedBlock = NbtUtils.readBlockState(stack.getTag()
|
||||
.getCompound("BlockUsed"))
|
||||
.getBlock()
|
||||
.getDescriptionId();
|
||||
.getName();
|
||||
ItemDescription.add(tooltip,
|
||||
Lang.translateDirect("terrainzapper.usingBlock",
|
||||
new TranslatableComponent(usedblock).withStyle(ChatFormatting.GRAY))
|
||||
.withStyle(ChatFormatting.DARK_GRAY));
|
||||
usedBlock.withStyle(ChatFormatting.GRAY))
|
||||
.withStyle(ChatFormatting.DARK_GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -752,8 +752,8 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave
|
|||
.withStyle(ChatFormatting.WHITE));
|
||||
for (ItemStack item : allStacks) {
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("tooltip.brass_tunnel.contains_entry", new TranslatableComponent(item.getItem()
|
||||
.getDescriptionId(item)).getString(), item.getCount()))
|
||||
.append(Lang.translateDirect("tooltip.brass_tunnel.contains_entry", new TranslatableComponent(item.getDescriptionId())
|
||||
.getString(), item.getCount()))
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
|
|
|
@ -719,8 +719,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
|||
.withStyle(ChatFormatting.YELLOW)));
|
||||
if (!item.isEmpty()) {
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("tooltip.chute.contains", new TranslatableComponent(item.getItem()
|
||||
.getDescriptionId(item)).getString(), item.getCount()))
|
||||
.append(Lang.translateDirect("tooltip.chute.contains", new TranslatableComponent(item.getDescriptionId())
|
||||
.getString(), item.getCount()))
|
||||
.withStyle(ChatFormatting.GREEN));
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.simibubi.create.foundation.utility.Couple;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
@ -139,7 +138,7 @@ public class LinkedControllerItem extends Item implements MenuProvider {
|
|||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return new TranslatableComponent(getDescriptionId());
|
||||
return getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.nbt.ListTag;
|
|||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
@ -165,7 +164,7 @@ public class FilterItem extends Item implements MenuProvider {
|
|||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return new TranslatableComponent(getDescriptionId());
|
||||
return getDescription();
|
||||
}
|
||||
|
||||
public static ItemStackHandler getFilterItems(ItemStack stack) {
|
||||
|
|
|
@ -19,64 +19,64 @@ import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
|||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class FluidContentsAttribute implements ItemAttribute {
|
||||
public static final FluidContentsAttribute EMPTY = new FluidContentsAttribute(null);
|
||||
public static final FluidContentsAttribute EMPTY = new FluidContentsAttribute(null);
|
||||
|
||||
private final Fluid fluid;
|
||||
private final Fluid fluid;
|
||||
|
||||
public FluidContentsAttribute(@Nullable Fluid fluid) {
|
||||
this.fluid = fluid;
|
||||
}
|
||||
public FluidContentsAttribute(@Nullable Fluid fluid) {
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appliesTo(ItemStack itemStack) {
|
||||
return extractFluids(itemStack).contains(fluid);
|
||||
}
|
||||
@Override
|
||||
public boolean appliesTo(ItemStack itemStack) {
|
||||
return extractFluids(itemStack).contains(fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemAttribute> listAttributesOf(ItemStack itemStack) {
|
||||
return extractFluids(itemStack).stream().map(FluidContentsAttribute::new).collect(Collectors.toList());
|
||||
}
|
||||
@Override
|
||||
public List<ItemAttribute> listAttributesOf(ItemStack itemStack) {
|
||||
return extractFluids(itemStack).stream().map(FluidContentsAttribute::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey() {
|
||||
return "has_fluid";
|
||||
}
|
||||
@Override
|
||||
public String getTranslationKey() {
|
||||
return "has_fluid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getTranslationParameters() {
|
||||
String parameter = "";
|
||||
if(fluid != null)
|
||||
parameter = new TranslatableComponent(fluid.getAttributes().getTranslationKey()).getString();
|
||||
return new Object[] { parameter };
|
||||
}
|
||||
@Override
|
||||
public Object[] getTranslationParameters() {
|
||||
String parameter = "";
|
||||
if (fluid != null)
|
||||
parameter = new TranslatableComponent(fluid.getAttributes().getTranslationKey()).getString();
|
||||
return new Object[] { parameter };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(CompoundTag nbt) {
|
||||
if (fluid == null)
|
||||
return;
|
||||
ResourceLocation id = ForgeRegistries.FLUIDS.getKey(fluid);
|
||||
if (id == null)
|
||||
return;
|
||||
nbt.putString("id", id.toString());
|
||||
}
|
||||
@Override
|
||||
public void writeNBT(CompoundTag nbt) {
|
||||
if (fluid == null)
|
||||
return;
|
||||
ResourceLocation id = ForgeRegistries.FLUIDS.getKey(fluid);
|
||||
if (id == null)
|
||||
return;
|
||||
nbt.putString("id", id.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemAttribute readNBT(CompoundTag nbt) {
|
||||
return nbt.contains("id") ? new FluidContentsAttribute(ForgeRegistries.FLUIDS.getValue(ResourceLocation.tryParse(nbt.getString("id")))) : EMPTY;
|
||||
}
|
||||
@Override
|
||||
public ItemAttribute readNBT(CompoundTag nbt) {
|
||||
return nbt.contains("id") ? new FluidContentsAttribute(ForgeRegistries.FLUIDS.getValue(ResourceLocation.tryParse(nbt.getString("id")))) : EMPTY;
|
||||
}
|
||||
|
||||
private List<Fluid> extractFluids(ItemStack stack) {
|
||||
List<Fluid> fluids = new ArrayList<>();
|
||||
private List<Fluid> extractFluids(ItemStack stack) {
|
||||
List<Fluid> fluids = new ArrayList<>();
|
||||
|
||||
LazyOptional<IFluidHandlerItem> capability =
|
||||
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
|
||||
LazyOptional<IFluidHandlerItem> capability =
|
||||
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
|
||||
|
||||
capability.ifPresent((cap) -> {
|
||||
for(int i = 0; i < cap.getTanks(); i++) {
|
||||
fluids.add(cap.getFluidInTank(i).getFluid());
|
||||
}
|
||||
});
|
||||
capability.ifPresent((cap) -> {
|
||||
for(int i = 0; i < cap.getTanks(); i++) {
|
||||
fluids.add(cap.getFluidInTank(i).getFluid());
|
||||
}
|
||||
});
|
||||
|
||||
return fluids;
|
||||
}
|
||||
return fluids;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.core.NonNullList;
|
|||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
@ -167,7 +166,7 @@ public class ScheduleItem extends Item implements MenuProvider {
|
|||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return new TranslatableComponent(getDescriptionId());
|
||||
return getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -88,9 +88,9 @@ public class MaterialChecklist {
|
|||
List<Item> keys = new ArrayList<>(Sets.union(required.keySet(), damageRequired.keySet()));
|
||||
Collections.sort(keys, (item1, item2) -> {
|
||||
Locale locale = Locale.ENGLISH;
|
||||
String name1 = new TranslatableComponent(item1.getDescriptionId()).getString()
|
||||
String name1 = item1.getDescription().getString()
|
||||
.toLowerCase(locale);
|
||||
String name2 = new TranslatableComponent(item2.getDescriptionId()).getString()
|
||||
String name2 = item2.getDescription().getString()
|
||||
.toLowerCase(locale);
|
||||
return name1.compareTo(name2);
|
||||
});
|
||||
|
|
|
@ -22,12 +22,12 @@ import com.simibubi.create.content.schematics.item.SchematicItem;
|
|||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.config.CSchematics;
|
||||
import com.simibubi.create.foundation.utility.FilesHelper;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -163,9 +163,10 @@ public class ServerSchematicLoader {
|
|||
protected boolean validateSchematicSizeOnServer(ServerPlayer player, long size) {
|
||||
Integer maxFileSize = getConfig().maxTotalSchematicSize.get();
|
||||
if (size > maxFileSize * 1000) {
|
||||
player.sendMessage(new TranslatableComponent("create.schematics.uploadTooLarge")
|
||||
|
||||
player.sendMessage(Lang.translateDirect("schematics.uploadTooLarge")
|
||||
.append(new TextComponent(" (" + size / 1000 + " KB).")), player.getUUID());
|
||||
player.sendMessage(new TranslatableComponent("create.schematics.maxAllowedSize")
|
||||
player.sendMessage(Lang.translateDirect("schematics.maxAllowedSize")
|
||||
.append(new TextComponent(" " + maxFileSize + " KB")), player.getUUID());
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import net.minecraft.client.gui.components.AbstractWidget;
|
|||
import net.minecraft.client.renderer.Rect2i;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
|
@ -391,8 +390,8 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
|
|||
|
||||
if (te.hasCreativeCrate) {
|
||||
tooltip.add(Lang.translateDirect(_gunpowderLevel, "" + 100));
|
||||
tooltip.add(new TextComponent("(").append(new TranslatableComponent(AllBlocks.CREATIVE_CRATE.get()
|
||||
.getDescriptionId()))
|
||||
tooltip.add(new TextComponent("(").append(AllBlocks.CREATIVE_CRATE.get()
|
||||
.getName())
|
||||
.append(")")
|
||||
.withStyle(DARK_PURPLE));
|
||||
return tooltip;
|
||||
|
|
|
@ -16,7 +16,6 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -95,10 +94,9 @@ public class FilteringHandler {
|
|||
feedback = "apply";
|
||||
else if (ItemHandlerHelper.canItemStacksStack(toApply, filter))
|
||||
feedback = "apply_count";
|
||||
String translationKey = world.getBlockState(pos)
|
||||
Component formattedText = world.getBlockState(pos)
|
||||
.getBlock()
|
||||
.getDescriptionId();
|
||||
Component formattedText = new TranslatableComponent(translationKey);
|
||||
.getName();
|
||||
player.displayClientMessage(Lang.translateDirect("logistics.filter." + feedback, formattedText)
|
||||
.withStyle(ChatFormatting.WHITE), true);
|
||||
}
|
||||
|
|
|
@ -29,12 +29,12 @@ public class Lang {
|
|||
|
||||
@Deprecated // use Lang.translate(...).sendStatus(player)
|
||||
public static void sendStatus(Player player, String key, Object... args) {
|
||||
player.displayClientMessage(translateDirect(key, args), true);
|
||||
translate(key, args).sendStatus(player);
|
||||
}
|
||||
|
||||
@Deprecated // use Lang.translate(...).color(color).sendStatus(player)
|
||||
public static void sendStatus(Player player, int color, String key, Object... args) {
|
||||
player.displayClientMessage(translateDirect(key, args).withStyle(p -> p.withColor(color)), true);
|
||||
translate(key, args).color(color).sendStatus(player);
|
||||
}
|
||||
|
||||
public static String asId(String name) {
|
||||
|
|
Loading…
Reference in a new issue