mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 07:27:15 +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.compat.curios.Curios;
|
||||||
import com.simibubi.create.content.CreateItemGroup;
|
import com.simibubi.create.content.CreateItemGroup;
|
||||||
import com.simibubi.create.content.contraptions.TorquePropagator;
|
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.curiosities.weapons.BuiltinPotatoProjectileTypes;
|
||||||
import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler;
|
import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler;
|
||||||
import com.simibubi.create.content.logistics.block.display.AllDisplayBehaviours;
|
import com.simibubi.create.content.logistics.block.display.AllDisplayBehaviours;
|
||||||
|
@ -139,6 +140,7 @@ public class Create {
|
||||||
SchematicProcessor.register();
|
SchematicProcessor.register();
|
||||||
AllWorldFeatures.registerFeatures();
|
AllWorldFeatures.registerFeatures();
|
||||||
AllWorldFeatures.registerPlacementTypes();
|
AllWorldFeatures.registerPlacementTypes();
|
||||||
|
BoilerHeaters.registerDefaults();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement;
|
package com.simibubi.create.content.contraptions.components.structureMovement;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
public class AssemblyException extends Exception {
|
public class AssemblyException extends Exception {
|
||||||
|
@ -45,13 +45,12 @@ public class AssemblyException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssemblyException(String langKey, Object... objects) {
|
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) {
|
public static AssemblyException unmovableBlock(BlockPos pos, BlockState state) {
|
||||||
AssemblyException e = new AssemblyException("unmovableBlock", pos.getX(), pos.getY(), pos.getZ(),
|
AssemblyException e = new AssemblyException("unmovableBlock", pos.getX(), pos.getY(), pos.getZ(),
|
||||||
new TranslatableComponent(state.getBlock()
|
state.getBlock().getName());
|
||||||
.getDescriptionId()));
|
|
||||||
e.position = pos;
|
e.position = pos;
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import net.minecraft.world.level.ItemLike;
|
import net.minecraft.world.level.ItemLike;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
@ -73,8 +72,7 @@ public class FillingRecipe extends ProcessingRecipe<RecipeWrapper> implements IA
|
||||||
if (matchingFluidStacks.size() == 0)
|
if (matchingFluidStacks.size() == 0)
|
||||||
return new TextComponent("Invalid");
|
return new TextComponent("Invalid");
|
||||||
return Lang.translateDirect("recipe.assembly.spout_filling_fluid",
|
return Lang.translateDirect("recipe.assembly.spout_filling_fluid",
|
||||||
new TranslatableComponent(matchingFluidStacks.get(0)
|
matchingFluidStacks.get(0).getDisplayName().getString());
|
||||||
.getTranslationKey()).getString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -333,14 +333,14 @@ public class BoilerData {
|
||||||
for (int zOffset = 0; zOffset < controller.width; zOffset++) {
|
for (int zOffset = 0; zOffset < controller.width; zOffset++) {
|
||||||
BlockPos pos = controllerPos.offset(xOffset, -1, zOffset);
|
BlockPos pos = controllerPos.offset(xOffset, -1, zOffset);
|
||||||
BlockState blockState = level.getBlockState(pos);
|
BlockState blockState = level.getBlockState(pos);
|
||||||
float heat = BoilerHeaters.getActiveHeatOf(blockState);
|
float heat = BoilerHeaters.getActiveHeat(level, pos, blockState);
|
||||||
if (heat == 0) {
|
if (heat == 0) {
|
||||||
passiveHeat |= BoilerHeaters.canHeatPassively(blockState);
|
passiveHeat = true;
|
||||||
continue;
|
} else if (heat > 0) {
|
||||||
}
|
|
||||||
activeHeat += heat;
|
activeHeat += heat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
passiveHeat &= activeHeat == 0;
|
passiveHeat &= activeHeat == 0;
|
||||||
|
|
||||||
|
|
|
@ -1,39 +1,90 @@
|
||||||
package com.simibubi.create.content.contraptions.fluids.tank;
|
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.AllBlocks;
|
||||||
import com.simibubi.create.AllTags.AllBlockTags;
|
import com.simibubi.create.AllTags.AllBlockTags;
|
||||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
||||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
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.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) {
|
public static void registerHeater(IRegistryDelegate<Block> block, Heater heater) {
|
||||||
if (AllBlocks.BLAZE_BURNER.has(state))
|
BLOCK_HEATERS.put(block, heater);
|
||||||
return state.getValue(BlazeBurnerBlock.HEAT_LEVEL) != HeatLevel.NONE;
|
|
||||||
if (AllBlockTags.PASSIVE_BOILER_HEATERS.matches(state))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getActiveHeatOf(BlockState state) {
|
public static void registerHeaterProvider(HeaterProvider provider) {
|
||||||
if (AllBlocks.BLAZE_BURNER.has(state)) {
|
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 -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerDefaults() {
|
||||||
|
registerHeater(AllBlocks.BLAZE_BURNER.get().delegate, (level, pos, state) -> {
|
||||||
HeatLevel value = state.getValue(BlazeBurnerBlock.HEAT_LEVEL);
|
HeatLevel value = state.getValue(BlazeBurnerBlock.HEAT_LEVEL);
|
||||||
switch (value) {
|
if (value == HeatLevel.NONE) {
|
||||||
case FADING:
|
return -1;
|
||||||
case KINDLED:
|
}
|
||||||
return 1;
|
if (value == HeatLevel.SEETHING) {
|
||||||
case SEETHING:
|
|
||||||
return 2;
|
return 2;
|
||||||
default:
|
|
||||||
case SMOULDERING:
|
|
||||||
case NONE:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
if (value.isAtLeast(HeatLevel.FADING)) {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
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.ListTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.Nameable;
|
import net.minecraft.world.Nameable;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
@ -141,8 +140,8 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements Namea
|
||||||
@Override
|
@Override
|
||||||
public Component getName() {
|
public Component getName() {
|
||||||
return this.customName != null ? this.customName
|
return this.customName != null ? this.customName
|
||||||
: new TranslatableComponent(AllItems.COPPER_BACKTANK.get()
|
: AllItems.COPPER_BACKTANK.get()
|
||||||
.getDescriptionId());
|
.getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAirLevel() {
|
public int getAirLevel() {
|
||||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
@ -392,9 +391,9 @@ public class ToolboxTileEntity extends SmartTileEntity implements MenuProvider,
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return customName != null ? customName
|
return customName != null ? customName
|
||||||
: new TranslatableComponent(AllBlocks.TOOLBOXES.get(getColor())
|
: AllBlocks.TOOLBOXES.get(getColor())
|
||||||
.get()
|
.get()
|
||||||
.getDescriptionId());
|
.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,6 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
@ -544,8 +543,8 @@ public class BlueprintEntity extends HangingEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return new TranslatableComponent(AllItems.CRAFTING_BLUEPRINT.get()
|
return AllItems.CRAFTING_BLUEPRINT.get()
|
||||||
.getDescriptionId());
|
.getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.network.chat.Component;
|
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.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
|
@ -54,13 +54,13 @@ public abstract class ZapperItem extends Item {
|
||||||
public void appendHoverText(ItemStack stack, Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
public void appendHoverText(ItemStack stack, Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
||||||
if (stack.hasTag() && stack.getTag()
|
if (stack.hasTag() && stack.getTag()
|
||||||
.contains("BlockUsed")) {
|
.contains("BlockUsed")) {
|
||||||
String usedblock = NbtUtils.readBlockState(stack.getTag()
|
MutableComponent usedBlock = NbtUtils.readBlockState(stack.getTag()
|
||||||
.getCompound("BlockUsed"))
|
.getCompound("BlockUsed"))
|
||||||
.getBlock()
|
.getBlock()
|
||||||
.getDescriptionId();
|
.getName();
|
||||||
ItemDescription.add(tooltip,
|
ItemDescription.add(tooltip,
|
||||||
Lang.translateDirect("terrainzapper.usingBlock",
|
Lang.translateDirect("terrainzapper.usingBlock",
|
||||||
new TranslatableComponent(usedblock).withStyle(ChatFormatting.GRAY))
|
usedBlock.withStyle(ChatFormatting.GRAY))
|
||||||
.withStyle(ChatFormatting.DARK_GRAY));
|
.withStyle(ChatFormatting.DARK_GRAY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -752,8 +752,8 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave
|
||||||
.withStyle(ChatFormatting.WHITE));
|
.withStyle(ChatFormatting.WHITE));
|
||||||
for (ItemStack item : allStacks) {
|
for (ItemStack item : allStacks) {
|
||||||
tooltip.add(componentSpacing.plainCopy()
|
tooltip.add(componentSpacing.plainCopy()
|
||||||
.append(Lang.translateDirect("tooltip.brass_tunnel.contains_entry", new TranslatableComponent(item.getItem()
|
.append(Lang.translateDirect("tooltip.brass_tunnel.contains_entry", new TranslatableComponent(item.getDescriptionId())
|
||||||
.getDescriptionId(item)).getString(), item.getCount()))
|
.getString(), item.getCount()))
|
||||||
.withStyle(ChatFormatting.GRAY));
|
.withStyle(ChatFormatting.GRAY));
|
||||||
}
|
}
|
||||||
tooltip.add(componentSpacing.plainCopy()
|
tooltip.add(componentSpacing.plainCopy()
|
||||||
|
|
|
@ -719,8 +719,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
.withStyle(ChatFormatting.YELLOW)));
|
.withStyle(ChatFormatting.YELLOW)));
|
||||||
if (!item.isEmpty()) {
|
if (!item.isEmpty()) {
|
||||||
tooltip.add(componentSpacing.plainCopy()
|
tooltip.add(componentSpacing.plainCopy()
|
||||||
.append(Lang.translateDirect("tooltip.chute.contains", new TranslatableComponent(item.getItem()
|
.append(Lang.translateDirect("tooltip.chute.contains", new TranslatableComponent(item.getDescriptionId())
|
||||||
.getDescriptionId(item)).getString(), item.getCount()))
|
.getString(), item.getCount()))
|
||||||
.withStyle(ChatFormatting.GREEN));
|
.withStyle(ChatFormatting.GREEN));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.simibubi.create.foundation.utility.Couple;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
@ -139,7 +138,7 @@ public class LinkedControllerItem extends Item implements MenuProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return new TranslatableComponent(getDescriptionId());
|
return getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
@ -165,7 +164,7 @@ public class FilterItem extends Item implements MenuProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return new TranslatableComponent(getDescriptionId());
|
return getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStackHandler getFilterItems(ItemStack stack) {
|
public static ItemStackHandler getFilterItems(ItemStack stack) {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
@ -167,7 +166,7 @@ public class ScheduleItem extends Item implements MenuProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return new TranslatableComponent(getDescriptionId());
|
return getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -88,9 +88,9 @@ public class MaterialChecklist {
|
||||||
List<Item> keys = new ArrayList<>(Sets.union(required.keySet(), damageRequired.keySet()));
|
List<Item> keys = new ArrayList<>(Sets.union(required.keySet(), damageRequired.keySet()));
|
||||||
Collections.sort(keys, (item1, item2) -> {
|
Collections.sort(keys, (item1, item2) -> {
|
||||||
Locale locale = Locale.ENGLISH;
|
Locale locale = Locale.ENGLISH;
|
||||||
String name1 = new TranslatableComponent(item1.getDescriptionId()).getString()
|
String name1 = item1.getDescription().getString()
|
||||||
.toLowerCase(locale);
|
.toLowerCase(locale);
|
||||||
String name2 = new TranslatableComponent(item2.getDescriptionId()).getString()
|
String name2 = item2.getDescription().getString()
|
||||||
.toLowerCase(locale);
|
.toLowerCase(locale);
|
||||||
return name1.compareTo(name2);
|
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.AllConfigs;
|
||||||
import com.simibubi.create.foundation.config.CSchematics;
|
import com.simibubi.create.foundation.config.CSchematics;
|
||||||
import com.simibubi.create.foundation.utility.FilesHelper;
|
import com.simibubi.create.foundation.utility.FilesHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtIo;
|
import net.minecraft.nbt.NbtIo;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
@ -163,9 +163,10 @@ public class ServerSchematicLoader {
|
||||||
protected boolean validateSchematicSizeOnServer(ServerPlayer player, long size) {
|
protected boolean validateSchematicSizeOnServer(ServerPlayer player, long size) {
|
||||||
Integer maxFileSize = getConfig().maxTotalSchematicSize.get();
|
Integer maxFileSize = getConfig().maxTotalSchematicSize.get();
|
||||||
if (size > maxFileSize * 1000) {
|
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());
|
.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());
|
.append(new TextComponent(" " + maxFileSize + " KB")), player.getUUID());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.client.renderer.Rect2i;
|
import net.minecraft.client.renderer.Rect2i;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
|
@ -391,8 +390,8 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
|
||||||
|
|
||||||
if (te.hasCreativeCrate) {
|
if (te.hasCreativeCrate) {
|
||||||
tooltip.add(Lang.translateDirect(_gunpowderLevel, "" + 100));
|
tooltip.add(Lang.translateDirect(_gunpowderLevel, "" + 100));
|
||||||
tooltip.add(new TextComponent("(").append(new TranslatableComponent(AllBlocks.CREATIVE_CRATE.get()
|
tooltip.add(new TextComponent("(").append(AllBlocks.CREATIVE_CRATE.get()
|
||||||
.getDescriptionId()))
|
.getName())
|
||||||
.append(")")
|
.append(")")
|
||||||
.withStyle(DARK_PURPLE));
|
.withStyle(DARK_PURPLE));
|
||||||
return tooltip;
|
return tooltip;
|
||||||
|
|
|
@ -16,7 +16,6 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -95,10 +94,9 @@ public class FilteringHandler {
|
||||||
feedback = "apply";
|
feedback = "apply";
|
||||||
else if (ItemHandlerHelper.canItemStacksStack(toApply, filter))
|
else if (ItemHandlerHelper.canItemStacksStack(toApply, filter))
|
||||||
feedback = "apply_count";
|
feedback = "apply_count";
|
||||||
String translationKey = world.getBlockState(pos)
|
Component formattedText = world.getBlockState(pos)
|
||||||
.getBlock()
|
.getBlock()
|
||||||
.getDescriptionId();
|
.getName();
|
||||||
Component formattedText = new TranslatableComponent(translationKey);
|
|
||||||
player.displayClientMessage(Lang.translateDirect("logistics.filter." + feedback, formattedText)
|
player.displayClientMessage(Lang.translateDirect("logistics.filter." + feedback, formattedText)
|
||||||
.withStyle(ChatFormatting.WHITE), true);
|
.withStyle(ChatFormatting.WHITE), true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,12 @@ public class Lang {
|
||||||
|
|
||||||
@Deprecated // use Lang.translate(...).sendStatus(player)
|
@Deprecated // use Lang.translate(...).sendStatus(player)
|
||||||
public static void sendStatus(Player player, String key, Object... args) {
|
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)
|
@Deprecated // use Lang.translate(...).color(color).sendStatus(player)
|
||||||
public static void sendStatus(Player player, int color, String key, Object... args) {
|
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) {
|
public static String asId(String name) {
|
||||||
|
|
Loading…
Reference in a new issue