Use modern java features where we can, optimise imports.

This commit is contained in:
modmuss50 2021-05-29 20:32:05 +01:00
parent 52e4767247
commit 31e7b357dc
135 changed files with 342 additions and 794 deletions

View file

@ -74,7 +74,7 @@ public class TechReborn implements ModInitializer {
// Done to force the class to load
//noinspection ResultOfMethodCallIgnored
ModRecipes.GRINDER.getName();
ModRecipes.GRINDER.name();
ClientboundPackets.init();
ServerboundPackets.init();

View file

@ -30,7 +30,6 @@ import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
import net.minecraft.client.item.ModelPredicateProvider;
import net.minecraft.client.item.UnclampedModelPredicateProvider;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.model.BakedModel;
@ -49,6 +48,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import org.jetbrains.annotations.Nullable;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.multiblock.MultiblockRenderer;
import reborncore.common.util.ItemUtils;
@ -70,7 +70,6 @@ import techreborn.items.armor.BatpackItem;
import techreborn.items.tool.ChainsawItem;
import techreborn.items.tool.industrial.NanosaberItem;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

View file

@ -28,45 +28,13 @@ package techreborn.api.generator;
import net.minecraft.fluid.Fluid;
import techreborn.utils.FluidUtils;
public class FluidGeneratorRecipe {
private final EFluidGenerator generatorType;
private final Fluid fluid;
private final int energyPerMb;
public FluidGeneratorRecipe(Fluid fluid, int energyPerMb, EFluidGenerator generatorType) {
this.fluid = fluid;
this.energyPerMb = energyPerMb;
this.generatorType = generatorType;
}
public Fluid getFluid() {
return fluid;
}
public record FluidGeneratorRecipe(Fluid fluid, int energyPerMb,
EFluidGenerator generatorType) {
public int getEnergyPerBucket() {
return energyPerMb * 1000;
}
public EFluidGenerator getGeneratorType() {
return generatorType;
}
@Override
public String toString() {
return "FluidGeneratorRecipe [generatorType=" + generatorType + ", fluid=" + fluid + ", energyPerMb="
+ energyPerMb + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + energyPerMb;
result = prime * result + ((fluid == null) ? 0 : fluid.hashCode());
result = prime * result + ((generatorType == null) ? 0 : generatorType.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)

View file

@ -39,7 +39,7 @@ public class FluidGeneratorRecipeList {
}
public boolean addRecipe(FluidGeneratorRecipe fluidGeneratorRecipe) {
if (!this.getRecipeForFluid(fluidGeneratorRecipe.getFluid()).isPresent())
if (!this.getRecipeForFluid(fluidGeneratorRecipe.fluid()).isPresent())
return this.getRecipes().add(fluidGeneratorRecipe);
return false;
}
@ -49,7 +49,7 @@ public class FluidGeneratorRecipeList {
}
public Optional<FluidGeneratorRecipe> getRecipeForFluid(Fluid fluid) {
return this.recipes.stream().filter(recipe -> FluidUtils.fluidEquals(recipe.getFluid(), fluid)).findAny();
return this.recipes.stream().filter(recipe -> FluidUtils.fluidEquals(recipe.fluid(), fluid)).findAny();
}
public HashSet<FluidGeneratorRecipe> getRecipes() {

View file

@ -66,8 +66,7 @@ public class BlastFurnaceRecipe extends RebornRecipe {
@Override
public boolean canCraft(final BlockEntity blockEntity) {
if (blockEntity instanceof IndustrialBlastFurnaceBlockEntity) {
final IndustrialBlastFurnaceBlockEntity blastFurnace = (IndustrialBlastFurnaceBlockEntity) blockEntity;
if (blockEntity instanceof final IndustrialBlastFurnaceBlockEntity blastFurnace) {
return blastFurnace.getHeat() >= heat;
}
return false;

View file

@ -73,8 +73,7 @@ public class FusionReactorRecipe extends RebornRecipe {
@Override
public boolean canCraft(final BlockEntity blockEntity) {
if (blockEntity instanceof FusionControlComputerBlockEntity) {
final FusionControlComputerBlockEntity reactor = (FusionControlComputerBlockEntity) blockEntity;
if (blockEntity instanceof final FusionControlComputerBlockEntity reactor) {
return reactor.getSize() >= minSize;
}
return false;

View file

@ -27,6 +27,7 @@ package techreborn.blockentity.cable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
@ -36,7 +37,6 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
@ -180,9 +180,7 @@ public class CableBlockEntity extends BlockEntity
continue;
}
if (blockEntity instanceof CableBlockEntity) {
CableBlockEntity cableBlockEntity = (CableBlockEntity) blockEntity;
if (blockEntity instanceof CableBlockEntity cableBlockEntity) {
if (cableBlockEntity.getTier() != this.getTier()) {
continue;
}

View file

@ -138,19 +138,19 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
}
private int getEnergySlot() {
return slots.stream().filter(slot -> slot.getType() == SlotType.ENERGY).findFirst().orElse(null).getId();
return slots.stream().filter(slot -> slot.type() == SlotType.ENERGY).findFirst().orElse(null).id();
}
private int countOfSlotType(SlotType type) {
return (int) slots.stream()
.filter(slot -> slot.getType() == type)
.filter(slot -> slot.type() == type)
.count();
}
private int[] slotIds(SlotType type) {
return slots.stream()
.filter(slot -> slot.getType() == type)
.mapToInt(DataDrivenSlot::getId)
.filter(slot -> slot.type() == type)
.mapToInt(DataDrivenSlot::id)
.toArray();
}

View file

@ -30,7 +30,7 @@ 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 org.jetbrains.annotations.NotNull;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.screen.builder.BlockEntityScreenHandlerBuilder;
import reborncore.common.util.serialization.SerializationUtil;
@ -39,7 +39,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
public class DataDrivenSlot {
public record DataDrivenSlot(int id, int x, int y, @NotNull SlotType type) {
public static List<DataDrivenSlot> read(JsonArray jsonArray) {
AtomicInteger idCount = new AtomicInteger();
@ -49,35 +49,6 @@ public class DataDrivenSlot {
.collect(Collectors.toList());
}
private final int id;
private final int x;
private final int y;
private final SlotType type;
public DataDrivenSlot(int id, int x, int y, SlotType type) {
this.id = id;
this.x = x;
this.y = y;
this.type = type;
Validate.notNull(type);
}
public int getId() {
return id;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public SlotType getType() {
return type;
}
public void add(BlockEntityScreenHandlerBuilder inventoryBuilder) {
type.getSlotBiConsumer().accept(inventoryBuilder, this);
}
@ -85,10 +56,10 @@ public class DataDrivenSlot {
@Environment(EnvType.CLIENT)
public void draw(MatrixStack matrixStack, GuiBase<?> guiBase, GuiBase.Layer layer) {
//TODO find a better way to do this
if (getType() == SlotType.OUTPUT) {
guiBase.drawOutputSlot(matrixStack, getX(), getY(), layer);
if (type() == SlotType.OUTPUT) {
guiBase.drawOutputSlot(matrixStack, x(), y(), layer);
} else {
guiBase.drawSlot(matrixStack, getX(), getY(), layer);
guiBase.drawSlot(matrixStack, x(), y(), layer);
}
}
}

View file

@ -32,13 +32,13 @@ import java.util.function.BiConsumer;
public enum SlotType {
//Im really not a fan of the way I add the slots to the builder here
INPUT((builder, slot) -> {
builder.slot(slot.getId(), slot.getX(), slot.getY());
builder.slot(slot.id(), slot.x(), slot.y());
}),
OUTPUT((builder, slot) -> {
builder.outputSlot(slot.getId(), slot.getX(), slot.getY());
builder.outputSlot(slot.id(), slot.x(), slot.y());
}),
ENERGY((builder, slot) -> {
builder.energySlot(slot.getId(), slot.getX(), slot.getY());
builder.energySlot(slot.id(), slot.x(), slot.y());
});
public static SlotType fromString(String string) {

View file

@ -105,7 +105,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
}
if (!tank.getFluidAmount().isEmpty()) {
if (currentRecipe == null || !FluidUtils.fluidEquals(currentRecipe.getFluid(), tank.getFluid()))
if (currentRecipe == null || !FluidUtils.fluidEquals(currentRecipe.fluid(), tank.getFluid()))
currentRecipe = getRecipes().getRecipeForFluid(tank.getFluid()).orElse(null);
if (currentRecipe != null) {

View file

@ -65,12 +65,10 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
}
Block BEBlock = getCachedState().getBlock();
if (!(BEBlock instanceof BlockMachineBase)) {
if (!(BEBlock instanceof BlockMachineBase machineBaseBlock)) {
return;
}
BlockMachineBase machineBaseBlock = (BlockMachineBase) BEBlock;
if (onStatusHoldTicks == 0 || getEnergy() <= 0) {
machineBaseBlock.setActive(false, world, pos);
onStatusHoldTicks = -1;

View file

@ -82,8 +82,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
return;
}
Block panelBlock = world.getBlockState(pos).getBlock();
if (panelBlock instanceof BlockSolarPanel) {
BlockSolarPanel solarPanelBlock = (BlockSolarPanel) panelBlock;
if (panelBlock instanceof BlockSolarPanel solarPanelBlock) {
panel = solarPanelBlock.panelType;
}
}
@ -133,17 +132,11 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
}
public int getGenerationRate() {
int rate = 0;
switch (getSunState()) {
case DAYGEN:
rate = getPanel().generationRateD;
break;
case NIGHTGEN:
rate = getPanel().generationRateN;
}
return rate;
return switch (getSunState()) {
case DAYGEN -> getPanel().generationRateD;
case NIGHTGEN -> getPanel().generationRateN;
default -> 0;
};
}

View file

@ -122,8 +122,7 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
public void updateState() {
final BlockState BlockStateContainer = world.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getBlock() instanceof final BlockMachineBase blockMachineBase) {
boolean active = burnTime > 0 && getFreeSpace() > 0.0f;
if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != active) {
blockMachineBase.setActive(active, world, pos);

View file

@ -125,8 +125,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
private void updateState() {
BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) state.getBlock();
if (state.getBlock() instanceof BlockMachineBase blockMachineBase) {
if (state.get(BlockMachineBase.ACTIVE) != burnTime > 0)
blockMachineBase.setActive(burnTime > 0, world, pos);
}

View file

@ -59,8 +59,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
}
public void handleGuiInputFromClient(PlayerEntity playerIn) {
if (playerIn instanceof ServerPlayerEntity) {
ServerPlayerEntity player = (ServerPlayerEntity) playerIn;
if (playerIn instanceof ServerPlayerEntity player) {
int totalExperience = (int) experience;
while (totalExperience > 0) {
int expToDrop = ExperienceOrbEntity.roundToOrbSize(totalExperience);

View file

@ -26,14 +26,13 @@ package techreborn.blockentity.machine.misc;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.sound.SoundCategory;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
@ -94,15 +93,9 @@ public class AlarmBlockEntity extends BlockEntity
if (world.isReceivingRedstonePower(getPos())) {
BlockAlarm.setActive(true, world, pos);
switch (selectedSound) {
case 1:
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F);
break;
case 2:
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_2, SoundCategory.BLOCKS, 4F, 1F);
break;
case 3:
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
break;
case 1 -> world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F);
case 2 -> world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_2, SoundCategory.BLOCKS, 4F, 1F);
case 3 -> world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
}
} else {
BlockAlarm.setActive(false, world, pos);

View file

@ -40,6 +40,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
import reborncore.client.screen.BuiltScreenHandlerProvider;
@ -56,7 +57,6 @@ import techreborn.init.ModSounds;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

View file

@ -131,8 +131,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
private void updateState() {
Block furnaceBlock = getWorld().getBlockState(pos).getBlock();
if (furnaceBlock instanceof BlockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) furnaceBlock;
if (furnaceBlock instanceof BlockMachineBase blockMachineBase) {
boolean isActive = currentRecipe != null || canCraftAgain();
blockMachineBase.setActive(isActive, world, pos);
}

View file

@ -178,8 +178,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
return;
}
isRunning = active;
if (this.getWorld().getBlockState(this.getPos()).getBlock() instanceof BlockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) this.getWorld().getBlockState(this.getPos()).getBlock();
if (this.getWorld().getBlockState(this.getPos()).getBlock() instanceof BlockMachineBase blockMachineBase) {
blockMachineBase.setActive(active, this.getWorld(), this.getPos());
}
this.getWorld().updateListeners(this.getPos(), this.getWorld().getBlockState(this.getPos()), this.getWorld().getBlockState(this.getPos()), 3);

View file

@ -27,11 +27,9 @@ package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.RebornInventory;
import techreborn.blockentity.machine.GenericMachineBlockEntity;

View file

@ -34,6 +34,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
import reborncore.client.screen.BuiltScreenHandlerProvider;
@ -46,8 +47,6 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import org.jetbrains.annotations.Nullable;
public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
public RebornInventory<ChunkLoaderBlockEntity> inventory = new RebornInventory<>(0, "ChunkLoaderBlockEntity", 64, this);

View file

@ -28,9 +28,9 @@ import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.PersistentState;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import reborncore.common.util.NBTSerializable;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
public class IDSUManager extends PersistentState {

View file

@ -50,10 +50,9 @@ public class LSUStorageBlockEntity extends MachineBaseBlockEntity
network.addElement(this);
for (Direction direction : Direction.values()) {
BlockEntity be = world.getBlockEntity(pos.offset(direction));
if (!(be instanceof LSUStorageBlockEntity)) {
if (!(be instanceof LSUStorageBlockEntity lesuStorage)) {
continue;
}
LSUStorageBlockEntity lesuStorage = (LSUStorageBlockEntity) be;
if (lesuStorage.network != null) {
lesuStorage.network.merge(network);
}

View file

@ -36,6 +36,7 @@ import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.api.IListInfoProvider;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
@ -49,7 +50,6 @@ import reborncore.common.util.WorldUtils;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implements InventoryProvider, IToolDrop, IListInfoProvider, BuiltScreenHandlerProvider {

View file

@ -54,6 +54,7 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import org.jetbrains.annotations.Nullable;
import reborncore.api.ToolManager;
import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils;
@ -65,8 +66,6 @@ import techreborn.init.ModSounds;
import techreborn.init.TRContent;
import techreborn.utils.damageSources.ElectrialShockSource;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
@ -106,20 +105,14 @@ public class CableBlock extends BlockWithEntity implements Waterloggable {
}
public BooleanProperty getProperty(Direction facing) {
switch (facing) {
case WEST:
return WEST;
case NORTH:
return NORTH;
case SOUTH:
return SOUTH;
case UP:
return UP;
case DOWN:
return DOWN;
default:
return EAST;
}
return switch (facing) {
case WEST -> WEST;
case NORTH -> NORTH;
case SOUTH -> SOUTH;
case UP -> UP;
case DOWN -> DOWN;
default -> EAST;
};
}
private BlockState makeConnections(World world, BlockPos pos) {
@ -250,11 +243,10 @@ public class CableBlock extends BlockWithEntity implements Waterloggable {
if (blockEntity == null) {
return;
}
if (!(blockEntity instanceof CableBlockEntity)) {
if (!(blockEntity instanceof CableBlockEntity blockEntityCable)) {
return;
}
CableBlockEntity blockEntityCable = (CableBlockEntity) blockEntity;
if (blockEntityCable.getEnergy() <= 0) {
return;
}

View file

@ -42,14 +42,13 @@ import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.api.ToolManager;
import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils;
import techreborn.blockentity.lighting.LampBlockEntity;
import org.jetbrains.annotations.Nullable;
import java.util.function.ToIntFunction;
public class LampBlock extends BaseBlockEntityProvider {

View file

@ -45,13 +45,13 @@ import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.api.ToolManager;
import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils;
import techreborn.blockentity.machine.misc.AlarmBlockEntity;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class BlockAlarm extends BaseBlockEntityProvider {

View file

@ -45,11 +45,11 @@ public class BlockMachineCasing extends BlockMultiblockBase {
public static int getHeatFromState(BlockState state) {
Block block = state.getBlock();
if (!(block instanceof BlockMachineCasing)) {
return 0;
if (block instanceof BlockMachineCasing casing) {
return casing.heatCapacity;
}
BlockMachineCasing casing = (BlockMachineCasing) block;
return casing.heatCapacity;
return 0;
}
@Override

View file

@ -75,13 +75,12 @@ public class BlockNuke extends BaseBlock {
@Override
public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) {
if (!worldIn.isClient && entityIn instanceof ProjectileEntity) {
ProjectileEntity entityarrow = (ProjectileEntity) entityIn;
if (!worldIn.isClient && entityIn instanceof ProjectileEntity projectileEntity) {
LivingEntity shooter = null;
if (entityarrow.getOwner() instanceof LivingEntity) {
shooter = (LivingEntity) entityarrow.getOwner();
if (projectileEntity.getOwner() instanceof LivingEntity) {
shooter = (LivingEntity) projectileEntity.getOwner();
}
if (entityarrow.isOnFire()) {
if (projectileEntity.isOnFire()) {
ignite(worldIn, pos, state, shooter);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
}

View file

@ -58,8 +58,7 @@ public class LSUStorageBlock extends BaseBlockEntityProvider {
if (state.getBlock() == newState.getBlock()) {
return;
}
if (worldIn.getBlockEntity(pos) instanceof LSUStorageBlockEntity) {
LSUStorageBlockEntity blockEntity = (LSUStorageBlockEntity) worldIn.getBlockEntity(pos);
if (worldIn.getBlockEntity(pos) instanceof LSUStorageBlockEntity blockEntity) {
if (blockEntity != null) {
blockEntity.removeFromNetwork();
}
@ -75,8 +74,7 @@ public class LSUStorageBlock extends BaseBlockEntityProvider {
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity player, ItemStack itemstack) {
super.onPlaced(world, pos, state, player, itemstack);
if (world.getBlockEntity(pos) instanceof LSUStorageBlockEntity) {
LSUStorageBlockEntity blockEntity = (LSUStorageBlockEntity) world.getBlockEntity(pos);
if (world.getBlockEntity(pos) instanceof LSUStorageBlockEntity blockEntity) {
if (blockEntity != null) {
blockEntity.rebuildNetwork();
}

View file

@ -75,10 +75,9 @@ public class TankUnitBlock extends BlockMachineBase {
// Assuming ItemFluidInfo is 1 BUCKET, for now only allow exact amount or less
// I am only going to trust cells or buckets, they are known to be 1 BUCKET size, too suss of other items not abiding by that.
if ((itemInHand instanceof DynamicCellItem || itemInHand instanceof BucketItem)
&& tankUnitEntity != null && itemInHand instanceof ItemFluidInfo) {
&& tankUnitEntity != null && itemInHand instanceof ItemFluidInfo itemFluid) {
// Get fluid information from item
ItemFluidInfo itemFluid = (ItemFluidInfo) itemInHand;
Fluid fluid = itemFluid.getFluid(stackInHand);
int amount = stackInHand.getCount();
@ -154,14 +153,11 @@ public class TankUnitBlock extends BlockMachineBase {
boolean isSameItemFluid(ItemStack i1, ItemStack i2){
// Only care about cells, buckets don't stack
if(!(i1.getItem() instanceof DynamicCellItem && i2.getItem() instanceof DynamicCellItem)){
return false;
if(i1.getItem() instanceof DynamicCellItem dc1 && i2.getItem() instanceof DynamicCellItem dc2){
return dc1.getFluid(i1).matchesType(dc2.getFluid(i2));
}
DynamicCellItem dc1 = (DynamicCellItem)i1.getItem();
DynamicCellItem dc2 = (DynamicCellItem)i2.getItem();
return dc1.getFluid(i1).matchesType(dc2.getFluid(i2));
return false;
}
@Override

View file

@ -42,6 +42,7 @@ import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.RebornCore;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.client.screen.BuiltScreenHandlerProvider;
@ -73,7 +74,6 @@ import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.client.gui.*;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;

View file

@ -24,7 +24,6 @@
package techreborn.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText;

View file

@ -24,7 +24,6 @@
package techreborn.client.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;

View file

@ -24,7 +24,6 @@
package techreborn.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText;

View file

@ -49,15 +49,9 @@ public class GuiSolar extends GuiBase<BuiltScreenHandler> {
builder.drawMultiEnergyBar(matrixStack, this, 156, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxStoredPower(), mouseX, mouseY, 0, layer);
switch (blockEntity.getSunState()) {
case SolarPanelBlockEntity.DAYGEN:
builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.daygen"), 10, 20, 15129632);
break;
case SolarPanelBlockEntity.NIGHTGEN:
builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.nightgen"), 10, 20, 7566195);
break;
case SolarPanelBlockEntity.ZEROGEN:
builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.zerogen"), 10, 20, 12066591);
break;
case SolarPanelBlockEntity.DAYGEN -> builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.daygen"), 10, 20, 15129632);
case SolarPanelBlockEntity.NIGHTGEN -> builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.nightgen"), 10, 20, 7566195);
case SolarPanelBlockEntity.ZEROGEN -> builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.zerogen"), 10, 20, 12066591);
}
builder.drawText(matrixStack, this, new LiteralText("Generating: " + blockEntity.getGenerationRate() + " E/t"), 10, 30, 0);

View file

@ -46,10 +46,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockRenderView;
import org.jetbrains.annotations.Nullable;
import reborncore.common.fluid.container.ItemFluidInfo;
import reborncore.common.util.Color;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@ -66,8 +66,7 @@ public abstract class BaseDynamicFluidBakedModel implements BakedModel, FabricBa
@Override
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
Fluid fluid = Fluids.EMPTY;
if (stack.getItem() instanceof ItemFluidInfo) {
ItemFluidInfo fluidInfo = (ItemFluidInfo) stack.getItem();
if (stack.getItem() instanceof ItemFluidInfo fluidInfo) {
fluid = fluidInfo.getFluid(stack);
}

View file

@ -62,16 +62,9 @@ public class StorageUnitRenderer implements BlockEntityRenderer<StorageUnitBaseB
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion((direction.getHorizontal() - 2) * 90F));
matrices.scale(0.5F, 0.5F, 0.5F);
switch (direction) {
case NORTH:
case WEST:
matrices.translate(1, 1, 0);
break;
case SOUTH:
matrices.translate(-1, 1, -2);
break;
case EAST:
matrices.translate(-1, 1, 2);
break;
case NORTH, WEST -> matrices.translate(1, 1, 0);
case SOUTH -> matrices.translate(-1, 1, -2);
case EAST -> matrices.translate(-1, 1, 2);
}
int lightAbove = WorldRenderer.getLightmapCoordinates(storage.getWorld(), storage.getPos().offset(storage.getFacing()));
MinecraftClient.getInstance().getItemRenderer().renderItem(stack, ModelTransformation.Mode.FIXED, lightAbove, OverlayTexture.DEFAULT_UV, matrices, vertexConsumers, 0);

View file

@ -80,12 +80,12 @@ public class TurbineRenderer implements BlockEntityRenderer<WindMillBlockEntity>
new ModelPart.Cuboid(0, 6, -1.0F, -1.0F, -2.0F, 2F, 2F, 1F, 0F, 0F, 0F, false, 64F, 64F)
};
base = new ModelPart(Arrays.asList(baseCuboids), new HashMap<String, ModelPart>() {
base = new ModelPart(Arrays.asList(baseCuboids), new HashMap<>() {
{
ModelPart.Cuboid[] blade1Cuboids = {
new ModelPart.Cuboid(0, 9, -24.0F, -1.0F, -0.5F, 24F, 2F, 1F, 0F, 0F, 0F, false, 64F, 64F)
};
ModelPart blade1 = new ModelPart(Arrays.asList(blade1Cuboids) , Collections.emptyMap());
ModelPart blade1 = new ModelPart(Arrays.asList(blade1Cuboids), Collections.emptyMap());
blade1.setPivot(0.0F, 0.0F, 0.0F);
setRotation(blade1, -0.5236F, 0.0F, 0.0F);
put("blade1", blade1);
@ -93,7 +93,7 @@ public class TurbineRenderer implements BlockEntityRenderer<WindMillBlockEntity>
ModelPart.Cuboid[] blade2Cuboids = {
new ModelPart.Cuboid(0, 9, -24.0F, -1.0F, -0.5F, 24F, 2F, 1F, 0F, 0F, 0F, false, 64F, 64F)
};
ModelPart blade2 = new ModelPart(Arrays.asList(blade2Cuboids) , Collections.emptyMap());
ModelPart blade2 = new ModelPart(Arrays.asList(blade2Cuboids), Collections.emptyMap());
blade2.setPivot(0.0F, 0.0F, 0.0F);
setRotation(blade2, -0.5236F, 0.0F, 2.0944F);
put("blade2", blade2);
@ -101,7 +101,7 @@ public class TurbineRenderer implements BlockEntityRenderer<WindMillBlockEntity>
ModelPart.Cuboid[] blade3Cuboids = {
new ModelPart.Cuboid(0, 9, -24.0F, -2.0F, -1.075F, 24F, 2F, 1F, 0F, 0F, 0F, false, 64F, 64F)
};
ModelPart blade3 = new ModelPart(Arrays.asList(blade3Cuboids) , Collections.emptyMap());
ModelPart blade3 = new ModelPart(Arrays.asList(blade3Cuboids), Collections.emptyMap());
blade3.setPivot(0.0F, 0.0F, 0.0F);
setRotation(blade3, -0.5236F, 0.0F, -2.0944F);
put("blade3", blade3);

View file

@ -105,6 +105,6 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
@Override
public Identifier getRecipeCategory() {
return recipe.getRebornRecipeType().getName();
return recipe.getRebornRecipeType().name();
}
}

View file

@ -159,25 +159,25 @@ public class ReiPlugin implements REIPluginV0 {
@Override
public void registerOthers(RecipeHelper recipeHelper) {
recipeHelper.registerWorkingStations(ModRecipes.ALLOY_SMELTER.getName(), EntryStack.create(Machine.ALLOY_SMELTER), EntryStack.create(Machine.IRON_ALLOY_FURNACE));
recipeHelper.registerWorkingStations(ModRecipes.ASSEMBLING_MACHINE.getName(), EntryStack.create(Machine.ASSEMBLY_MACHINE));
recipeHelper.registerWorkingStations(ModRecipes.BLAST_FURNACE.getName(), EntryStack.create(Machine.INDUSTRIAL_BLAST_FURNACE));
recipeHelper.registerWorkingStations(ModRecipes.CENTRIFUGE.getName(), EntryStack.create(Machine.INDUSTRIAL_CENTRIFUGE));
recipeHelper.registerWorkingStations(ModRecipes.CHEMICAL_REACTOR.getName(), EntryStack.create(Machine.CHEMICAL_REACTOR));
recipeHelper.registerWorkingStations(ModRecipes.COMPRESSOR.getName(), EntryStack.create(Machine.COMPRESSOR));
recipeHelper.registerWorkingStations(ModRecipes.DISTILLATION_TOWER.getName(), EntryStack.create(Machine.DISTILLATION_TOWER));
recipeHelper.registerWorkingStations(ModRecipes.EXTRACTOR.getName(), EntryStack.create(Machine.EXTRACTOR));
recipeHelper.registerWorkingStations(ModRecipes.FLUID_REPLICATOR.getName(), EntryStack.create(Machine.FLUID_REPLICATOR));
recipeHelper.registerWorkingStations(ModRecipes.FUSION_REACTOR.getName(), EntryStack.create(Machine.FUSION_CONTROL_COMPUTER));
recipeHelper.registerWorkingStations(ModRecipes.GRINDER.getName(), EntryStack.create(Machine.GRINDER));
recipeHelper.registerWorkingStations(ModRecipes.IMPLOSION_COMPRESSOR.getName(), EntryStack.create(Machine.IMPLOSION_COMPRESSOR));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_ELECTROLYZER.getName(), EntryStack.create(Machine.INDUSTRIAL_ELECTROLYZER));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_GRINDER.getName(), EntryStack.create(Machine.INDUSTRIAL_GRINDER));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_SAWMILL.getName(), EntryStack.create(Machine.INDUSTRIAL_SAWMILL));
recipeHelper.registerWorkingStations(ModRecipes.ROLLING_MACHINE.getName(), EntryStack.create(Machine.ROLLING_MACHINE));
recipeHelper.registerWorkingStations(ModRecipes.SOLID_CANNING_MACHINE.getName(), EntryStack.create(Machine.SOLID_CANNING_MACHINE));
recipeHelper.registerWorkingStations(ModRecipes.VACUUM_FREEZER.getName(), EntryStack.create(Machine.VACUUM_FREEZER));
recipeHelper.registerWorkingStations(ModRecipes.WIRE_MILL.getName(), EntryStack.create(Machine.WIRE_MILL));
recipeHelper.registerWorkingStations(ModRecipes.ALLOY_SMELTER.name(), EntryStack.create(Machine.ALLOY_SMELTER), EntryStack.create(Machine.IRON_ALLOY_FURNACE));
recipeHelper.registerWorkingStations(ModRecipes.ASSEMBLING_MACHINE.name(), EntryStack.create(Machine.ASSEMBLY_MACHINE));
recipeHelper.registerWorkingStations(ModRecipes.BLAST_FURNACE.name(), EntryStack.create(Machine.INDUSTRIAL_BLAST_FURNACE));
recipeHelper.registerWorkingStations(ModRecipes.CENTRIFUGE.name(), EntryStack.create(Machine.INDUSTRIAL_CENTRIFUGE));
recipeHelper.registerWorkingStations(ModRecipes.CHEMICAL_REACTOR.name(), EntryStack.create(Machine.CHEMICAL_REACTOR));
recipeHelper.registerWorkingStations(ModRecipes.COMPRESSOR.name(), EntryStack.create(Machine.COMPRESSOR));
recipeHelper.registerWorkingStations(ModRecipes.DISTILLATION_TOWER.name(), EntryStack.create(Machine.DISTILLATION_TOWER));
recipeHelper.registerWorkingStations(ModRecipes.EXTRACTOR.name(), EntryStack.create(Machine.EXTRACTOR));
recipeHelper.registerWorkingStations(ModRecipes.FLUID_REPLICATOR.name(), EntryStack.create(Machine.FLUID_REPLICATOR));
recipeHelper.registerWorkingStations(ModRecipes.FUSION_REACTOR.name(), EntryStack.create(Machine.FUSION_CONTROL_COMPUTER));
recipeHelper.registerWorkingStations(ModRecipes.GRINDER.name(), EntryStack.create(Machine.GRINDER));
recipeHelper.registerWorkingStations(ModRecipes.IMPLOSION_COMPRESSOR.name(), EntryStack.create(Machine.IMPLOSION_COMPRESSOR));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_ELECTROLYZER.name(), EntryStack.create(Machine.INDUSTRIAL_ELECTROLYZER));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_GRINDER.name(), EntryStack.create(Machine.INDUSTRIAL_GRINDER));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_SAWMILL.name(), EntryStack.create(Machine.INDUSTRIAL_SAWMILL));
recipeHelper.registerWorkingStations(ModRecipes.ROLLING_MACHINE.name(), EntryStack.create(Machine.ROLLING_MACHINE));
recipeHelper.registerWorkingStations(ModRecipes.SOLID_CANNING_MACHINE.name(), EntryStack.create(Machine.SOLID_CANNING_MACHINE));
recipeHelper.registerWorkingStations(ModRecipes.VACUUM_FREEZER.name(), EntryStack.create(Machine.VACUUM_FREEZER));
recipeHelper.registerWorkingStations(ModRecipes.WIRE_MILL.name(), EntryStack.create(Machine.WIRE_MILL));
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.THERMAL_GENERATOR.name), EntryStack.create(Machine.THERMAL_GENERATOR));
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.GAS_TURBINE.name), EntryStack.create(Machine.GAS_TURBINE));
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.DIESEL_GENERATOR.name), EntryStack.create(Machine.DIESEL_GENERATOR));
@ -240,7 +240,7 @@ public class ReiPlugin implements REIPluginV0 {
};
}
recipeHelper.registerRecipes(recipeType.getName(), (Predicate<Recipe>) recipe -> {
recipeHelper.registerRecipes(recipeType.name(), (Predicate<Recipe>) recipe -> {
if (recipe instanceof RebornRecipe) {
return ((RebornRecipe) recipe).getRebornRecipeType() == recipeType;
}
@ -253,11 +253,9 @@ public class ReiPlugin implements REIPluginV0 {
BaseBoundsHandler baseBoundsHandler = BaseBoundsHandler.getInstance();
baseBoundsHandler.registerExclusionZones(GuiBase.class, () -> {
Screen currentScreen = MinecraftClient.getInstance().currentScreen;
if (currentScreen instanceof GuiBase) {
GuiBase<?> guiBase = (GuiBase<?>) currentScreen;
if (currentScreen instanceof GuiBase<?> guiBase) {
int height = 0;
if (guiBase.tryAddUpgrades() && guiBase.be instanceof IUpgradeable) {
IUpgradeable upgradeable = (IUpgradeable) guiBase.be;
if (guiBase.tryAddUpgrades() && guiBase.be instanceof IUpgradeable upgradeable) {
if (upgradeable.canBeUpgraded()) {
height = 80;
}
@ -286,18 +284,10 @@ public class ReiPlugin implements REIPluginV0 {
}
switch (direction) {
case RIGHT:
helper.drawTexture(matrices, x, y, direction.xActive, direction.yActive, j, 10);
break;
case LEFT:
helper.drawTexture(matrices, x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
break;
case UP:
helper.drawTexture(matrices, x, y + 16 - j, direction.xActive, direction.yActive + 16 - j, 10, j);
break;
case DOWN:
helper.drawTexture(matrices, x, y, direction.xActive, direction.yActive, 10, j);
break;
case RIGHT -> helper.drawTexture(matrices, x, y, direction.xActive, direction.yActive, j, 10);
case LEFT -> helper.drawTexture(matrices, x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
case UP -> helper.drawTexture(matrices, x, y + 16 - j, direction.xActive, direction.yActive + 16 - j, 10, j);
case DOWN -> helper.drawTexture(matrices, x, y, direction.xActive, direction.yActive, 10, j);
}
});
}
@ -342,7 +332,7 @@ public class ReiPlugin implements REIPluginV0 {
drawTexture(matrices, bounds.x, bounds.y, displayPower.xBar - 15, displayPower.yBar - 1, width, height);
int innerDisplayHeight;
if (animation.animationType != EntryAnimationType.NONE) {
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight) / 1f);
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight));
if (animation.animationType == EntryAnimationType.DOWNWARDS)
innerDisplayHeight = innerHeight - innerDisplayHeight;
} else innerDisplayHeight = innerHeight;
@ -379,7 +369,7 @@ public class ReiPlugin implements REIPluginV0 {
drawTexture(matrices, bounds.x, bounds.y, 194, 82, width, height);
int innerDisplayHeight;
if (animation.animationType != EntryAnimationType.NONE) {
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight) / 1f);
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight));
if (animation.animationType == EntryAnimationType.DOWNWARDS)
innerDisplayHeight = innerHeight - innerDisplayHeight;
} else innerDisplayHeight = innerHeight;
@ -423,14 +413,7 @@ public class ReiPlugin implements REIPluginV0 {
protected void drawCurrentEntry(MatrixStack matrices, int mouseX, int mouseY, float delta) {}
}
public static class EntryAnimation {
private final EntryAnimationType animationType;
private final long duration;
private EntryAnimation(EntryAnimationType animationType, long duration) {
this.animationType = animationType;
this.duration = duration;
}
public record EntryAnimation(EntryAnimationType animationType, long duration) {
public static EntryAnimation upwards(long duration) {
return new EntryAnimation(EntryAnimationType.UPWARDS, duration);

View file

@ -43,7 +43,7 @@ public class FluidGeneratorRecipeDisplay implements RecipeDisplay {
this.category = category;
this.inputs = Lists.newArrayList();
this.totalEnergy = recipe.getEnergyPerBucket();
inputs.add(Collections.singletonList(EntryStack.create(recipe.getFluid(), 1000)));
inputs.add(Collections.singletonList(EntryStack.create(recipe.fluid(), 1000)));
}
@Override

View file

@ -57,12 +57,12 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplic
@Override
public Identifier getIdentifier() {
return rebornRecipeType.getName();
return rebornRecipeType.name();
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.getName().toString());
return I18n.translate(rebornRecipeType.name().toString());
}
@Override

View file

@ -86,7 +86,7 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
@Override
public Identifier getRecipeCategory() {
return recipe.getRebornRecipeType().getName();
return recipe.getRebornRecipeType().name();
}
@Override

View file

@ -48,12 +48,12 @@ public abstract class AbstractMachineCategory<R extends RebornRecipe> implements
@Override
public Identifier getIdentifier() {
return rebornRecipeType.getName();
return rebornRecipeType.name();
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.getName().toString());
return I18n.translate(rebornRecipeType.name().toString());
}
@Override

View file

@ -43,12 +43,12 @@ public class RollingMachineCategory extends DefaultCraftingCategory {
@Override
public Identifier getIdentifier() {
return rebornRecipeType.getName();
return rebornRecipeType.name();
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.getName().toString());
return I18n.translate(rebornRecipeType.name().toString());
}
@Override

View file

@ -37,6 +37,6 @@ public class RollingMachineDisplay extends DefaultShapedDisplay {
@Override
public Identifier getRecipeCategory() {
return ModRecipes.ROLLING_MACHINE.getName();
return ModRecipes.ROLLING_MACHINE.name();
}
}

View file

@ -30,7 +30,6 @@ import net.minecraft.item.Item;
import net.minecraft.item.Item.Settings;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.Identifier;
import reborncore.RebornRegistry;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;

View file

@ -35,7 +35,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.registry.Registry;
import reborncore.common.BaseBlockEntityProvider;
import techreborn.TechReborn;
import techreborn.init.TRContent;
import techreborn.items.UpgradeItem;
import techreborn.utils.ToolTipAssistUtils;
@ -70,8 +69,7 @@ public class StackToolTipHandler implements ItemTooltipCallback {
ToolTipAssistUtils.addInfo(item.getTranslationKey(), tooltipLines);
}
if (item instanceof UpgradeItem) {
UpgradeItem upgrade = (UpgradeItem) item;
if (item instanceof UpgradeItem upgrade) {
ToolTipAssistUtils.addInfo(item.getTranslationKey(), tooltipLines, false);
tooltipLines.addAll(ToolTipAssistUtils.getUpgradeStats(TRContent.Upgrades.valueOf(upgrade.name.toUpperCase()), stack.getCount(), Screen.hasShiftDown()));

View file

@ -28,10 +28,10 @@ import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.minecraft.item.ItemConvertible;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.loot.entry.LootPoolEntry;
import net.minecraft.loot.function.SetCountLootFunction;
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent.Ingots;
import techreborn.init.TRContent.Parts;
@ -94,24 +94,21 @@ public class ModLoot {
if (TechRebornConfig.enableOverworldLoot) {
switch (stringId) {
case "minecraft:chests/abandoned_mineshaft":
case "minecraft:chests/desert_pyramid":
case "minecraft:chests/igloo_chest":
case "minecraft:chests/jungle_temple":
case "minecraft:chests/simple_dungeon":
case "minecraft:chests/village/village_weaponsmith":
case "minecraft:chests/village/village_armorer":
case "minecraft:chests/village/village_toolsmith":
supplier.withPool(poolBasic);
break;
case "minecraft:chests/stronghold_corridor":
case "minecraft:chests/stronghold_crossing":
case "minecraft:chests/stronghold_library":
supplier.withPool(poolAdvanced);
break;
case "minecraft:chests/woodland_mansion":
supplier.withPool(poolIndustrial);
break;
case "minecraft:chests/abandoned_mineshaft",
"minecraft:chests/desert_pyramid",
"minecraft:chests/igloo_chest",
"minecraft:chests/jungle_temple",
"minecraft:chests/simple_dungeon",
"minecraft:chests/village/village_weaponsmith",
"minecraft:chests/village/village_armorer",
"minecraft:chests/village/village_toolsmith"
-> supplier.withPool(poolBasic);
case "minecraft:chests/stronghold_corridor",
"minecraft:chests/stronghold_crossing",
"minecraft:chests/stronghold_library"
-> supplier.withPool(poolAdvanced);
case "minecraft:chests/woodland_mansion"
-> supplier.withPool(poolIndustrial);
}
}

View file

@ -73,7 +73,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Supplier;
public class TRBlockEntities {
@ -146,7 +145,7 @@ public class TRBlockEntities {
public static <T extends BlockEntity> BlockEntityType<T> register(BiFunction<BlockPos, BlockState, T> supplier, String name, Block... blocks) {
Validate.isTrue(blocks.length > 0, "no blocks for blockEntity entity type!");
return register(new Identifier(TechReborn.MOD_ID, name).toString(), FabricBlockEntityTypeBuilder.create((pos, state) -> supplier.apply(pos, state), blocks));
return register(new Identifier(TechReborn.MOD_ID, name).toString(), FabricBlockEntityTypeBuilder.create(supplier::apply, blocks));
}
public static <T extends BlockEntity> BlockEntityType<T> register(String id, FabricBlockEntityTypeBuilder<T> builder) {

View file

@ -35,6 +35,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.structure.rule.RuleTest;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
import reborncore.api.blockentity.IUpgrade;
import reborncore.common.fluid.FluidValue;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
@ -83,8 +84,6 @@ import techreborn.items.UpgradeItem;
import techreborn.items.armor.QuantumSuitItem;
import techreborn.items.tool.MiningLevel;
import techreborn.utils.InitUtils;
import org.jetbrains.annotations.Nullable;
import techreborn.world.DataDrivenFeature;
import java.util.*;

View file

@ -32,7 +32,6 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
@ -73,9 +72,9 @@ public class TemplateProcessor {
}
private void processFile(Path inputFile, Path outputFile, Map<String, String> values) throws IOException {
String input = new String(Files.readAllBytes(inputFile), StandardCharsets.UTF_8);
String input = Files.readString(inputFile);
String output = replaceValues(input, values);
Files.write(outputFile, output.getBytes(StandardCharsets.UTF_8));
Files.writeString(outputFile, output);
}
private static String replaceValues(String input, Map<String, String> values) {

View file

@ -57,6 +57,7 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.text.WordUtils;
import org.jetbrains.annotations.Nullable;
import reborncore.common.fluid.FluidUtil;
import reborncore.common.fluid.container.ItemFluidInfo;
import reborncore.common.util.ItemNBTHelper;
@ -64,8 +65,6 @@ import techreborn.TechReborn;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;
import org.jetbrains.annotations.Nullable;
/**
* Created by modmuss50 on 17/05/2016.
*/

View file

@ -40,12 +40,12 @@ import net.minecraft.util.dynamic.GlobalPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.common.chunkloading.ChunkLoaderManager;
import reborncore.common.util.ChatUtils;
import techreborn.TechReborn;
import techreborn.utils.MessageIDs;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Optional;

View file

@ -34,14 +34,14 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import reborncore.api.blockentity.IUpgrade;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.recipes.IUpgradeHandler;
import techreborn.TechReborn;
import techreborn.init.TRContent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class UpgradeItem extends Item implements IUpgrade {

View file

@ -32,8 +32,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
import reborncore.api.items.ArmorRemoveHandler;
import reborncore.api.items.ArmorBlockEntityTicker;
import reborncore.api.items.ArmorRemoveHandler;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.ItemUtils;
import team.reborn.energy.Energy;

View file

@ -40,8 +40,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
import reborncore.api.items.ArmorRemoveHandler;
import reborncore.api.items.ArmorBlockEntityTicker;
import reborncore.api.items.ArmorRemoveHandler;
import reborncore.api.items.ItemStackModifiers;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.ItemUtils;

View file

@ -41,11 +41,11 @@ import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import techreborn.TechReborn;
import techreborn.blockentity.cable.CableBlockEntity;
import techreborn.blocks.cable.CableBlock;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class PaintingToolItem extends Item {

View file

@ -41,6 +41,7 @@ import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.common.util.ItemUtils;
import team.reborn.energy.Energy;
import team.reborn.energy.EnergyTier;
@ -50,7 +51,6 @@ import techreborn.utils.MessageIDs;
import techreborn.utils.TagUtils;
import techreborn.utils.ToolsUtil;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;

View file

@ -85,10 +85,9 @@ public class IndustrialDrillItem extends DrillItem {
if (!ItemUtils.isActive(stack)) {
return super.postMine(stack, worldIn, stateIn, pos, entityLiving);
}
if (!(entityLiving instanceof PlayerEntity)) {
if (!(entityLiving instanceof PlayerEntity playerIn)) {
return super.postMine(stack, worldIn, stateIn, pos, entityLiving);
}
PlayerEntity playerIn = (PlayerEntity) entityLiving;
for (BlockPos additionalPos : ToolsUtil.getAOEMiningBlocks(worldIn, pos, entityLiving, 1)) {
if (shouldBreak(playerIn, worldIn, pos, additionalPos)) {
ToolsUtil.breakBlock(stack, worldIn, additionalPos, entityLiving, cost);

View file

@ -43,6 +43,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.api.items.ItemStackModifiers;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.ItemDurabilityExtensions;
@ -56,7 +57,6 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.utils.MessageIDs;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabilityExtensions, ItemStackModifiers {

View file

@ -43,6 +43,7 @@ import net.minecraft.util.Formatting;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils;
@ -57,7 +58,6 @@ import techreborn.init.TRContent;
import techreborn.items.tool.MiningLevel;
import techreborn.utils.InitUtils;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurabilityExtensions, DynamicAttributeTool {

View file

@ -64,12 +64,11 @@ public class FluidUtils {
ItemStack outputStack = inventory.getStack(outputSlot);
if (inputStack.isEmpty()) return false;
if (!(inputStack.getItem() instanceof ItemFluidInfo)) return false;
if (!(inputStack.getItem() instanceof ItemFluidInfo itemFluidInfo)) return false;
if (FluidUtils.isContainerEmpty(inputStack)) return false;
if (outputStack.getCount() >= outputStack.getMaxCount()) return false;
if (!outputStack.isEmpty() && !FluidUtils.isContainerEmpty(outputStack)) return false;
ItemFluidInfo itemFluidInfo = (ItemFluidInfo) inputStack.getItem();
if (!outputStack.isEmpty() && !outputStack.isItemEqual(itemFluidInfo.getEmpty())) return false;
FluidInstance tankFluidInstance = tank.getFluidInstance(null);
@ -109,11 +108,9 @@ public class FluidUtils {
if (!outputStack.isEmpty()) {
if (outputStack.getCount() >= outputStack.getMaxCount()) return false;
if (!(outputStack.getItem() instanceof ItemFluidInfo)) return false;
if (!(outputStack.getItem() instanceof ItemFluidInfo outputFluidInfo)) return false;
if (!outputStack.isItemEqual(itemFluidInfo.getEmpty())) return false;
ItemFluidInfo outputFluidInfo = (ItemFluidInfo) outputStack.getItem();
if (outputFluidInfo.getFluid(outputStack) != sourceFluid.getFluid()) {
return false;
}
@ -138,9 +135,9 @@ public class FluidUtils {
public static boolean isContainerEmpty(ItemStack stack) {
if (stack.isEmpty())
return false;
if (!(stack.getItem() instanceof ItemFluidInfo))
return false;
ItemFluidInfo itemFluidInfo = (ItemFluidInfo) stack.getItem();
return itemFluidInfo.getFluid(stack) == Fluids.EMPTY;
if (stack.getItem() instanceof ItemFluidInfo itemFluidInfo)
return itemFluidInfo.getFluid(stack) == Fluids.EMPTY;
return false;
}
}

View file

@ -28,9 +28,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeType;
import net.minecraft.world.World;
import techreborn.items.DynamicCellItem;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

View file

@ -25,7 +25,6 @@
package techreborn.utils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -72,9 +71,9 @@ public class TagRemapper {
final char quote = '"';
return path -> {
try {
String recipe = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
String recipe = Files.readString(path);
recipe = recipe.replaceAll(quote + rename.getOldTagName() + quote, quote + rename.getNewTagName() + quote);
Files.write(path, recipe.getBytes(StandardCharsets.UTF_8));
Files.writeString(path, recipe);
} catch (IOException e) {
throw new RuntimeException(e);
}

View file

@ -52,19 +52,13 @@ public class ToolTipAssistUtils {
boolean shouldStackCalculate = count > 1;
switch (upgradeType) {
case OVERCLOCKER:
case OVERCLOCKER -> {
tips.add(getPositive(I18n.translate("techreborn.tooltip.upgrade.speed_increase"), calculateValue(TechRebornConfig.overclockerSpeed * 100, count, shiftHeld), "%"));
tips.add(getNegative(I18n.translate("techreborn.tooltip.upgrade.energy_increase"), calculateValue(TechRebornConfig.overclockerPower * 100, count, shiftHeld), "%"));
break;
case TRANSFORMER:
shouldStackCalculate = false;
break;
case ENERGY_STORAGE:
tips.add(getPositive(I18n.translate("techreborn.tooltip.upgrade.storage_increase"), calculateValue(TechRebornConfig.energyStoragePower, count, shiftHeld), " E"));
break;
case SUPERCONDUCTOR:
tips.add(getPositive(I18n.translate("techreborn.tooltip.upgrade.flow_increase"), calculateValue(Math.pow(2, (TechRebornConfig.superConductorCount + 2)) * 100, count, shiftHeld), "%"));
break;
}
case TRANSFORMER -> shouldStackCalculate = false;
case ENERGY_STORAGE -> tips.add(getPositive(I18n.translate("techreborn.tooltip.upgrade.storage_increase"), calculateValue(TechRebornConfig.energyStoragePower, count, shiftHeld), " E"));
case SUPERCONDUCTOR -> tips.add(getPositive(I18n.translate("techreborn.tooltip.upgrade.flow_increase"), calculateValue(Math.pow(2, (TechRebornConfig.superConductorCount + 2)) * 100, count, shiftHeld), "%"));
}
// Add reminder that they can use shift to calculate the entire stack

View file

@ -36,9 +36,9 @@ import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import team.reborn.energy.Energy;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Random;
@ -91,11 +91,10 @@ public class ToolsUtil {
* @return Set of BlockPos to process by tool block break logic
*/
public static Set<BlockPos> getAOEMiningBlocks(World worldIn, BlockPos pos, @Nullable LivingEntity entityLiving, int radius, boolean placeDummyBlocks) {
if (!(entityLiving instanceof PlayerEntity)) {
if (!(entityLiving instanceof PlayerEntity playerIn)) {
return ImmutableSet.of();
}
Set<BlockPos> targetBlocks = new HashSet<>();
PlayerEntity playerIn = (PlayerEntity) entityLiving;
if (placeDummyBlocks) {
//Put a dirt block down to raytrace with to stop it raytracing past the intended block
@ -133,30 +132,30 @@ public class ToolsUtil {
int maxZ = 0;
switch (playerDirection) {
case SOUTH:
case SOUTH -> {
minZ = -1;
maxZ = 1 + (radius - 1) * 2;
minX = -radius;
maxX = radius;
break;
case NORTH:
}
case NORTH -> {
minZ = -1 - (radius - 1) * 2;
maxZ = 1;
minX = -radius;
maxX = radius;
break;
case WEST:
}
case WEST -> {
minZ = -radius;
maxZ = radius;
minX = -1 - (radius - 1) * 2;
maxX = 1;
break;
case EAST:
}
case EAST -> {
minZ = -radius;
maxZ = radius;
minX = -1;
maxX = 1 + (radius - 1) * 2;
break;
}
}
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {

View file

@ -32,11 +32,7 @@ import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.minecraft.util.Util;
import net.minecraft.world.biome.Biome;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.function.Predicate;
public class BiomeSelectorDeserialiser {

View file

@ -32,11 +32,9 @@ import net.minecraft.block.Blocks;
import net.minecraft.structure.rule.BlockStateMatchRuleTest;
import net.minecraft.structure.rule.RuleTest;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import net.minecraft.util.collection.DataPool;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.math.intprovider.UniformIntProvider;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStep;
@ -50,12 +48,10 @@ import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider;
import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider;
import net.minecraft.world.gen.trunk.StraightTrunkPlacer;
import org.apache.logging.log4j.util.TriConsumer;
import reborncore.common.util.IdentifiableObject;
import techreborn.blocks.misc.BlockRubberLog;
import techreborn.init.TRContent;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -140,7 +136,7 @@ public class DefaultWorldGen {
Path dir = Paths.get("..\\src\\main\\resources\\data\\techreborn\\techreborn\\features");
try {
Files.write(dir.resolve(defaultFeature.getIdentifier().getPath() + ".json"), json.getBytes(StandardCharsets.UTF_8));
Files.writeString(dir.resolve(defaultFeature.getIdentifier().getPath() + ".json"), json);
} catch (IOException e) {
e.printStackTrace();
}

View file

@ -25,14 +25,11 @@
package techreborn.world;
import com.mojang.serialization.Lifecycle;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.biome.v1.ModificationPhase;
import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.MutableRegistry;