More 1.20 work.

This commit is contained in:
modmuss50 2023-05-11 20:41:47 +01:00 committed by modmuss
parent 133f64ac9f
commit 42d9a0445c
53 changed files with 317 additions and 243 deletions

View file

@ -25,7 +25,7 @@
package reborncore.common.recipes;
import com.google.gson.JsonObject;
import net.minecraft.class_8566;
import net.minecraft.inventory.RecipeInputInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeSerializer;
@ -66,7 +66,7 @@ public class PaddedShapedRecipe extends ShapedRecipe {
}
@Override
public boolean matches(class_8566 craftingInventory, World world) {
public boolean matches(RecipeInputInventory craftingInventory, World world) {
for(int i = 0; i <= craftingInventory.getWidth() - this.getWidth(); ++i) {
for(int j = 0; j <= craftingInventory.getHeight() - this.getHeight(); ++j) {
if (this.matchesPattern(craftingInventory, i, j, false)) {

View file

@ -3,7 +3,7 @@ accessWidener v2 named
accessible method net/minecraft/recipe/ShapedRecipe readSymbols (Lcom/google/gson/JsonObject;)Ljava/util/Map;
accessible method net/minecraft/recipe/ShapedRecipe getPattern (Lcom/google/gson/JsonArray;)[Ljava/lang/String;
accessible method net/minecraft/recipe/ShapedRecipe createPatternMatrix ([Ljava/lang/String;Ljava/util/Map;II)Lnet/minecraft/util/collection/DefaultedList;
accessible method net/minecraft/recipe/ShapedRecipe matchesPattern (Lnet/minecraft/class_8566;IIZ)Z
accessible method net/minecraft/recipe/ShapedRecipe matchesPattern (Lnet/minecraft/inventory/RecipeInputInventory;IIZ)Z
accessible class net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder$ShapedRecipeJsonProvider
accessible method net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder validate (Lnet/minecraft/util/Identifier;)V

View file

@ -8,9 +8,9 @@ mod_version=5.7.0
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20-pre1
yarn_version=1.20-pre1+build.2
yarn_version=1.20-pre1+build.7
loader_version=0.14.19
fapi_version=0.80.2+1.20
fapi_version=0.80.3+1.20
# Dependencies
energy_version=3.0.0

View file

@ -155,7 +155,7 @@ public final class GuiType<T extends BlockEntity> implements IMachineGuiHandler
private ExtendedScreenHandlerType.ExtendedFactory<BuiltScreenHandler> getScreenHandlerFactory() {
return (syncId, playerInventory, packetByteBuf) -> {
final BlockEntity blockEntity = playerInventory.player.world.getBlockEntity(packetByteBuf.readBlockPos());
final BlockEntity blockEntity = playerInventory.player.getWorld().getBlockEntity(packetByteBuf.readBlockPos());
BuiltScreenHandler screenHandler = ((BuiltScreenHandlerProvider) blockEntity).createScreenHandler(syncId, playerInventory.player);
//Set the screen handler type, not ideal but works lol
@ -183,7 +183,7 @@ public final class GuiType<T extends BlockEntity> implements IMachineGuiHandler
@Nullable
@Override
public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) {
final BlockEntity blockEntity = player.world.getBlockEntity(pos);
final BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
BuiltScreenHandler screenHandler = ((BuiltScreenHandlerProvider) blockEntity).createScreenHandler(syncId, player);
screenHandler.setType(screenHandlerType);
return screenHandler;

View file

@ -104,7 +104,7 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
return false;
if (inventory.getStack(OUTPUT_SLOT).isEmpty())
return true;
if (!inventory.getStack(OUTPUT_SLOT).isItemEqual(itemstack))
if (!inventory.getStack(OUTPUT_SLOT).isOf(itemstack.getItem()))
return false;
int result = inventory.getStack(OUTPUT_SLOT).getCount() + itemstack.getCount();
return result <= inventory.getStackLimit() && result <= inventory.getStack(OUTPUT_SLOT).getMaxCount();

View file

@ -69,7 +69,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
while (totalExperience > 0) {
int expToDrop = ExperienceOrbEntity.roundToOrbSize(totalExperience);
totalExperience -= expToDrop;
player.world.spawnEntity(new ExperienceOrbEntity(player.world, player.getX(), player.getY() + 0.5D, player.getZ() + 0.5D, expToDrop));
player.getWorld().spawnEntity(new ExperienceOrbEntity(player.getWorld(), player.getX(), player.getY() + 0.5D, player.getZ() + 0.5D, expToDrop));
}
}
experience = 0;
@ -98,7 +98,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
// Fast fail if there is no input, no point checking the recipes if the machine is empty
return ItemStack.EMPTY;
}
if (previousStack.isItemEqual(stack) && !previousValid){
if (previousStack.isOf(stack.getItem()) && !previousValid){
return ItemStack.EMPTY;
}
@ -127,7 +127,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
if (inventory.getStack(OUTPUT_SLOT).isEmpty()) {
inventory.setStack(OUTPUT_SLOT, resultStack.copy());
} else if (inventory.getStack(OUTPUT_SLOT).isItemEqual(resultStack)) {
} else if (inventory.getStack(OUTPUT_SLOT).isOf(resultStack.getItem())) {
inventory.getStack(OUTPUT_SLOT).increment(resultStack.getCount());
}
experience += getExperienceFor();
@ -158,7 +158,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
ItemStack outputSlotStack = inventory.getStack(OUTPUT_SLOT);
if (outputSlotStack.isEmpty())
return true;
if (!outputSlotStack.isItemEqual(outputStack))
if (!outputSlotStack.isOf(outputStack.getItem()))
return false;
int result = outputSlotStack.getCount() + outputStack.getCount();
return result <= inventory.getStackLimit() && result <= outputStack.getMaxCount();

View file

@ -115,7 +115,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
private static IInventoryAccess<FluidReplicatorBlockEntity> getInventoryAccess() {
return (slotID, stack, face, direction, blockEntity) -> {
if (slotID == 0) {
return stack.isItemEqual(TRContent.Parts.UU_MATTER.getStack());
return stack.isOf(TRContent.Parts.UU_MATTER.getStack().getItem());
}
return true;
};
@ -132,7 +132,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return new ScreenHandlerBuilder("fluidreplicator").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).fluidSlot(1, 124, 35).filterSlot(0, 55, 45, stack -> stack.isItemEqual(TRContent.Parts.UU_MATTER.getStack()))
.blockEntity(this).fluidSlot(1, 124, 35).filterSlot(0, 55, 45, stack -> stack.isOf(TRContent.Parts.UU_MATTER.getStack().getItem()))
.outputSlot(2, 124, 55).energySlot(3, 8, 72).sync(tank).syncEnergyValue().syncCrafterValue().addInventory()
.create(this, syncID);
}

View file

@ -26,7 +26,6 @@ package techreborn.blockentity.machine.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
@ -112,8 +111,8 @@ public class IndustrialBlastFurnaceBlockEntity extends GenericMachineBlockEntity
heat += BlockMachineCasing.getHeatFromState(part.getCachedState());
}
if (world.getBlockState(location.offset(Direction.UP, 1)).getMaterial().equals(Material.LAVA)
&& world.getBlockState(location.offset(Direction.UP, 2)).getMaterial().equals(Material.LAVA)) {
if (world.getBlockState(location.offset(Direction.UP, 1)).getBlock() == Blocks.LAVA
&& world.getBlockState(location.offset(Direction.UP, 2)).getBlock() == Blocks.LAVA) {
heat += 500;
}
return heat;

View file

@ -26,7 +26,6 @@ package techreborn.blockentity.machine.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
@ -71,7 +70,7 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
writer.translate(1, -1, -1)
.fill(0, 0, 0, 3, 1, 3, basic)
.ring(Direction.Axis.Y, 3, 1, 3, (view, pos) -> view.getBlockState(pos) == advanced, advanced, (view, pos) -> view.getBlockState(pos).getMaterial() == Material.WATER, Blocks.WATER.getDefaultState())
.ring(Direction.Axis.Y, 3, 1, 3, (view, pos) -> view.getBlockState(pos) == advanced, advanced, (view, pos) -> view.getBlockState(pos).getBlock() == Blocks.WATER, Blocks.WATER.getDefaultState())
.fill(0, 2, 0, 3, 3, 3, basic);
}

View file

@ -26,7 +26,6 @@ package techreborn.blockentity.machine.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
@ -71,7 +70,7 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
writer.translate(1, -1, -1)
.fill(0, 0, 0, 3, 1, 3, basic)
.ring(Direction.Axis.Y, 3, 1, 3, (view, pos) -> view.getBlockState(pos) == advanced, advanced, (view, pos) -> view.getBlockState(pos).getMaterial() == Material.WATER, Blocks.WATER.getDefaultState())
.ring(Direction.Axis.Y, 3, 1, 3, (view, pos) -> view.getBlockState(pos) == advanced, advanced, (view, pos) -> view.getBlockState(pos).getBlock() == Blocks.WATER, Blocks.WATER.getDefaultState())
.fill(0, 2, 0, 3, 3, 3, basic);
}

View file

@ -154,7 +154,7 @@ public class ElevatorBlockEntity extends PowerAcceptorBlockEntity implements ITo
}
public void teleportUp(final PlayerEntity player) {
if (!this.pos.isWithinDistance(player.getPos(), 5) && player.world == this.world) {
if (!this.pos.isWithinDistance(player.getPos(), 5) && player.getWorld() == this.world) {
// Ensure the player is close to the elevator and in the same world.
return;
}

View file

@ -87,7 +87,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
}
public int getValue(ItemStack itemStack) {
if (itemStack.isItemEqual(TRContent.Parts.SCRAP.getStack())) {
if (itemStack.isOf(TRContent.Parts.SCRAP.asItem())) {
return 200;
} else if (itemStack.getItem() == TRContent.SCRAP_BOX) {
return 2000;

View file

@ -24,12 +24,12 @@
package techreborn.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
import techreborn.init.TRBlockSettings;
import java.util.function.BiFunction;
@ -42,13 +42,7 @@ public class GenericMachineBlock extends BlockMachineBase {
BiFunction<BlockPos, BlockState, BlockEntity> blockEntityClass;
public GenericMachineBlock(IMachineGuiHandler gui, BiFunction<BlockPos, BlockState, BlockEntity> blockEntityClass) {
super();
this.blockEntityClass = blockEntityClass;
this.gui = gui;
}
public GenericMachineBlock(Block.Settings settings, IMachineGuiHandler gui, BiFunction<BlockPos, BlockState, BlockEntity> blockEntityClass) {
super(settings);
super(TRBlockSettings.genericMachine());
this.blockEntityClass = blockEntityClass;
this.gui = gui;
}

View file

@ -64,6 +64,7 @@ import techreborn.api.events.CableElectrocutionEvent;
import techreborn.blockentity.cable.CableBlockEntity;
import techreborn.config.TechRebornConfig;
import techreborn.init.ModSounds;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
import techreborn.init.TRDamageTypes;
@ -96,7 +97,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable {
public final TRContent.Cables type;
public CableBlock(TRContent.Cables type) {
super(Block.Settings.of(Material.STONE).strength(1f, 8f));
super(TRBlockSettings.cable());
this.type = type;
setDefaultState(this.getStateManager().getDefaultState().with(EAST, false).with(WEST, false).with(NORTH, false)
.with(SOUTH, false).with(UP, false).with(DOWN, false).with(WATERLOGGED, false).with(COVERED, false));

View file

@ -24,15 +24,12 @@
package techreborn.blocks.generator;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
@ -45,13 +42,14 @@ import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.api.ToolManager;
import techreborn.init.ModSounds;
import techreborn.init.TRBlockSettings;
import java.util.List;
public class BlockFusionCoil extends Block {
public BlockFusionCoil() {
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).sounds(BlockSoundGroup.METAL));
super(TRBlockSettings.fusionCoil());
}
@SuppressWarnings("deprecation")

View file

@ -40,12 +40,16 @@ import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.util.Torus;
import techreborn.blockentity.GuiType;
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
import techreborn.init.TRDamageTypes;
import java.util.List;
public class BlockFusionControlComputer extends BlockMachineBase {
public BlockFusionControlComputer() {
super(TRBlockSettings.fusionControlComputer());
}
@Override
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,

View file

@ -33,6 +33,7 @@ import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import techreborn.blockentity.GuiType;
import techreborn.blockentity.generator.SolarPanelBlockEntity;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent.SolarPanels;
/**
@ -43,7 +44,7 @@ public class BlockSolarPanel extends BlockMachineBase {
public final SolarPanels panelType;
public BlockSolarPanel(SolarPanels panel) {
super();
super(TRBlockSettings.solarPanel());
this.panelType = panel;
}

View file

@ -48,6 +48,7 @@ import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils;
import techreborn.blockentity.lighting.LampBlockEntity;
import techreborn.init.TRBlockSettings;
import java.util.function.ToIntFunction;
@ -61,7 +62,7 @@ public class LampBlock extends BaseBlockEntityProvider {
private static final int brightness = 15;
public LampBlock(int cost, double depth, double width) {
super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(createLightLevelFromBlockState()));
super(TRBlockSettings.lightBlock().luminance(createLightLevelFromBlockState()));
this.shape = genCuboidShapes(depth, width);
this.cost = cost;
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false));

View file

@ -27,7 +27,6 @@ package techreborn.blocks.machine.tier1;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -52,13 +51,14 @@ import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.util.StringUtils;
import techreborn.blockentity.GuiType;
import techreborn.blockentity.machine.tier1.PlayerDetectorBlockEntity;
import techreborn.init.TRBlockSettings;
public class PlayerDetectorBlock extends BlockMachineBase {
public static final EnumProperty<PlayerDetectorType> TYPE = EnumProperty.of("type", PlayerDetectorType.class);
public PlayerDetectorBlock() {
super(Block.Settings.of(Material.METAL).strength(2f, 2f), true);
super(TRBlockSettings.playerDetector(), true);
this.setDefaultState(this.getStateManager().getDefaultState().with(TYPE, PlayerDetectorType.ALL));
}

View file

@ -24,7 +24,10 @@
package techreborn.blocks.machine.tier1;
import net.minecraft.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -46,6 +49,7 @@ import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.util.WorldUtils;
import techreborn.blockentity.machine.tier1.ResinBasinBlockEntity;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
import java.util.function.BiFunction;
@ -59,7 +63,7 @@ public class ResinBasinBlock extends BaseBlockEntityProvider {
BiFunction<BlockPos, BlockState, BlockEntity> blockEntityClass;
public ResinBasinBlock(BiFunction<BlockPos, BlockState, BlockEntity> blockEntityClass) {
super(Block.Settings.of(Material.WOOD).strength(2F, 2F));
super(TRBlockSettings.resinBasin());
this.blockEntityClass = blockEntityClass;
this.setDefaultState(

View file

@ -50,6 +50,7 @@ import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils;
import techreborn.blockentity.machine.misc.AlarmBlockEntity;
import techreborn.init.TRBlockSettings;
import java.util.List;
@ -59,7 +60,7 @@ public class BlockAlarm extends BaseBlockEntityProvider {
protected final VoxelShape[] shape;
public BlockAlarm() {
super(Block.Settings.of(Material.STONE).strength(2f, 2f));
super(TRBlockSettings.alarm());
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false));
this.shape = GenCuboidShapes(3, 10);
BlockWrenchEventHandler.wrenchableBlocks.add(this);

View file

@ -41,9 +41,13 @@ import reborncore.api.ToolManager;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
import techreborn.init.ModSounds;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
public class BlockComputerCube extends BlockMachineBase {
public BlockComputerCube() {
super(TRBlockSettings.computerCube());
}
@Override
public IMachineGuiHandler getGui() {

View file

@ -24,22 +24,20 @@
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import reborncore.common.multiblock.BlockMultiblockBase;
import techreborn.blockentity.machine.multiblock.casing.MachineCasingBlockEntity;
import techreborn.init.TRBlockSettings;
public class BlockMachineCasing extends BlockMultiblockBase {
public final int heatCapacity;
public BlockMachineCasing(int heatCapacity) {
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).sounds(BlockSoundGroup.METAL).requiresTool());
super(TRBlockSettings.machineCasing());
this.heatCapacity = heatCapacity;
}

View file

@ -24,14 +24,12 @@
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;
import reborncore.common.BaseBlock;
import techreborn.init.TRBlockSettings;
public class BlockMachineFrame extends BaseBlock {
public BlockMachineFrame() {
super(FabricBlockSettings.of(Material.METAL).strength(1f, 1f).sounds(BlockSoundGroup.METAL));
super(TRBlockSettings.machineFrame());
}
}

View file

@ -24,18 +24,15 @@
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.FenceBlock;
import net.minecraft.block.MapColor;
import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.Direction;
import techreborn.init.TRBlockSettings;
public class BlockRefinedIronFence extends FenceBlock {
public BlockRefinedIronFence() {
super(FabricBlockSettings.of(Material.METAL, MapColor.OAK_TAN).strength(2.0F, 3.0F).sounds(BlockSoundGroup.METAL));
super(TRBlockSettings.refinedIronFence());
}
@Override

View file

@ -25,16 +25,14 @@
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;
import techreborn.init.TRBlockSettings;
public class BlockRubberLeaves extends LeavesBlock {
public BlockRubberLeaves() {
super(FabricBlockSettings.of(Material.LEAVES).hardness(0.2F).ticksRandomly().sounds(BlockSoundGroup.GRASS).nonOpaque());
super(TRBlockSettings.rubberLeaves());
FlammableBlockRegistry.getDefaultInstance().add(this, 30, 60);
}

View file

@ -25,19 +25,20 @@
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.minecraft.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PillarBlock;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
@ -50,6 +51,7 @@ import reborncore.common.util.WorldUtils;
import techreborn.config.TechRebornConfig;
import techreborn.events.TRRecipeHandler;
import techreborn.init.ModSounds;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
import techreborn.items.tool.TreeTapItem;
import techreborn.items.tool.basic.ElectricTreetapItem;
@ -64,10 +66,7 @@ public class BlockRubberLog extends PillarBlock {
public static BooleanProperty SHOULD_SAP = BooleanProperty.of("shouldsap");
public BlockRubberLog() {
super(Settings.of(Material.WOOD, (blockState) -> MapColor.SPRUCE_BROWN)
.strength(2.0F, 2f)
.sounds(BlockSoundGroup.WOOD)
.ticksRandomly());
super(TRBlockSettings.rubberLog());
this.setDefaultState(this.getDefaultState().with(SAP_SIDE, Direction.NORTH).with(HAS_SAP, false).with(SHOULD_SAP, true).with(AXIS, Direction.Axis.Y));
FlammableBlockRegistry.getDefaultInstance().add(this, 5, 5);
}

View file

@ -24,10 +24,8 @@
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Material;
import net.minecraft.block.SaplingBlock;
import net.minecraft.sound.BlockSoundGroup;
import techreborn.init.TRBlockSettings;
import techreborn.world.RubberSaplingGenerator;
/**
@ -36,6 +34,6 @@ import techreborn.world.RubberSaplingGenerator;
public class BlockRubberSapling extends SaplingBlock {
public BlockRubberSapling() {
super(new RubberSaplingGenerator(), FabricBlockSettings.of(Material.PLANT).sounds(BlockSoundGroup.GRASS).noCollision().ticksRandomly().breakInstantly());
super(new RubberSaplingGenerator(), TRBlockSettings.rubberSapling());
}
}

View file

@ -24,22 +24,11 @@
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;
import reborncore.common.BaseBlock;
import techreborn.init.TRBlockSettings;
public class BlockStorage extends BaseBlock {
public BlockStorage() {
this(false, 3f, 6f);
}
public BlockStorage(boolean isHot, float hardness, float resistance) {
super(isHot ? getDefaultSettings(hardness, resistance).luminance(15).nonOpaque() : getDefaultSettings(hardness, resistance));
}
public static FabricBlockSettings getDefaultSettings(float hardness, float resistance) {
return FabricBlockSettings.of(Material.METAL).strength(hardness, resistance).sounds(BlockSoundGroup.METAL).requiresTool();
super(TRBlockSettings.storageBlock(isHot, hardness, resistance));
}
}

View file

@ -25,8 +25,8 @@
package techreborn.blocks.misc;
import net.minecraft.block.ButtonBlock;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
/**
* @author drcrazy
@ -34,6 +34,6 @@ import techreborn.utils.InitUtils;
public class RubberButtonBlock extends ButtonBlock {
public RubberButtonBlock() {
super(InitUtils.setupRubberBlockSettings(true, 0.5F, 0.5F), TRContent.RUBBER_WOOD_SET_TYPE, 30, true);
super(TRBlockSettings.rubberButton(), TRContent.RUBBER_WOOD_SET_TYPE, 30, true);
}
}

View file

@ -25,8 +25,8 @@
package techreborn.blocks.misc;
import net.minecraft.block.DoorBlock;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
/**
* @author drcrazy
@ -34,6 +34,6 @@ import techreborn.utils.InitUtils;
public class RubberDoorBlock extends DoorBlock {
public RubberDoorBlock() {
super(InitUtils.setupRubberBlockSettings(3.0F, 3.0F), TRContent.RUBBER_WOOD_SET_TYPE);
super(TRBlockSettings.rubberDoor(), TRContent.RUBBER_WOOD_SET_TYPE);
}
}

View file

@ -25,6 +25,7 @@
package techreborn.blocks.misc;
import net.minecraft.block.PressurePlateBlock;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
@ -34,7 +35,7 @@ import techreborn.utils.InitUtils;
public class RubberPressurePlateBlock extends PressurePlateBlock {
public RubberPressurePlateBlock() {
super(PressurePlateBlock.ActivationRule.EVERYTHING, InitUtils.setupRubberBlockSettings(true, 0.5F, 0.5F), TRContent.RUBBER_WOOD_SET_TYPE);
super(PressurePlateBlock.ActivationRule.EVERYTHING, TRBlockSettings.rubberPressurePlate(), TRContent.RUBBER_WOOD_SET_TYPE);
}
}

View file

@ -25,8 +25,8 @@
package techreborn.blocks.misc;
import net.minecraft.block.TrapdoorBlock;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
/**
* @author drcrazy
@ -34,6 +34,6 @@ import techreborn.utils.InitUtils;
public class RubberTrapdoorBlock extends TrapdoorBlock {
public RubberTrapdoorBlock() {
super(InitUtils.setupRubberBlockSettings(3.0F, 3.0F), TRContent.RUBBER_WOOD_SET_TYPE);
super(TRBlockSettings.rubberTrapdoor(), TRContent.RUBBER_WOOD_SET_TYPE);
}
}

View file

@ -24,10 +24,8 @@
package techreborn.blocks.storage.energy;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -49,6 +47,7 @@ import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.ItemHandlerUtils;
import reborncore.common.util.WrenchUtils;
import techreborn.init.TRBlockSettings;
/**
@ -60,7 +59,7 @@ public abstract class EnergyStorageBlock extends BaseBlockEntityProvider {
public IMachineGuiHandler gui;
public EnergyStorageBlock(String name, IMachineGuiHandler gui) {
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f));
super(TRBlockSettings.energyStorage());
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH));
this.name = name;
this.gui = gui;

View file

@ -24,9 +24,7 @@
package techreborn.blocks.storage.energy;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -41,6 +39,7 @@ import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils;
import techreborn.blockentity.storage.energy.lesu.LSUStorageBlockEntity;
import techreborn.init.TRBlockSettings;
/**
* Energy storage block for LESU
@ -48,7 +47,7 @@ import techreborn.blockentity.storage.energy.lesu.LSUStorageBlockEntity;
public class LSUStorageBlock extends BaseBlockEntityProvider {
public LSUStorageBlock() {
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f));
super(TRBlockSettings.lsuStorage());
BlockWrenchEventHandler.wrenchableBlocks.add(this);
}

View file

@ -45,6 +45,7 @@ import reborncore.common.util.Tank;
import reborncore.common.util.WorldUtils;
import techreborn.blockentity.GuiType;
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
import techreborn.items.DynamicCellItem;
@ -53,7 +54,7 @@ public class TankUnitBlock extends BlockMachineBase {
public final TRContent.TankUnit unitType;
public TankUnitBlock(TRContent.TankUnit unitType) {
super();
super(TRBlockSettings.tankUnit());
this.unitType = unitType;
}

View file

@ -25,7 +25,6 @@
package techreborn.blocks.storage.item;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
@ -42,6 +41,7 @@ import reborncore.common.util.RebornInventory;
import reborncore.common.util.WorldUtils;
import techreborn.blockentity.GuiType;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.init.TRBlockSettings;
import techreborn.init.TRContent;
import techreborn.items.tool.WrenchItem;
@ -50,7 +50,7 @@ public class StorageUnitBlock extends BlockMachineBase {
public final TRContent.StorageUnit unitType;
public StorageUnitBlock(TRContent.StorageUnit unitType) {
super((Settings.of(unitType.name.equals("buffer") || unitType.name.equals("crude") ? Material.WOOD : Material.METAL).strength(2.0F, 2.0F)));
super(TRBlockSettings.storageUnit(unitType.name.equals("buffer") || unitType.name.equals("crude")));
this.unitType = unitType;
}

View file

@ -24,10 +24,8 @@
package techreborn.blocks.transformers;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -45,6 +43,7 @@ import reborncore.api.ToolManager;
import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils;
import techreborn.init.TRBlockSettings;
/**
* Created by Rushmead
@ -55,7 +54,7 @@ public abstract class BlockTransformer extends BaseBlockEntityProvider {
public String name;
public BlockTransformer(String name) {
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f));
super(TRBlockSettings.transformer());
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH));
this.name = name;
BlockWrenchEventHandler.wrenchableBlocks.add(this);

View file

@ -56,20 +56,20 @@ public class EntityNukePrimed extends TntEntity {
this.move(MovementType.SELF, this.getVelocity());
this.setVelocity(this.getVelocity().multiply(0.98D));
if (this.onGround) {
if (this.isOnGround()) {
this.setVelocity(this.getVelocity().multiply(0.7D, -0.5D, 0.7D));
}
setFuse(getFuse() - 1);
if (this.getFuse() <= 0) {
this.remove(RemovalReason.KILLED);
if (!this.world.isClient) {
if (!this.getWorld().isClient) {
this.explodeNuke();
}
} else {
this.updateWaterState();
if (this.world.isClient) {
this.world.addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D);
if (this.getWorld().isClient) {
this.getWorld().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D);
}
}
}
@ -78,7 +78,7 @@ public class EntityNukePrimed extends TntEntity {
if (!TechRebornConfig.nukeEnabled) {
return;
}
RebornExplosion nukeExplosion = new RebornExplosion(getBlockPos(), world, TechRebornConfig.nukeRadius);
RebornExplosion nukeExplosion = new RebornExplosion(getBlockPos(), getWorld(), TechRebornConfig.nukeRadius);
nukeExplosion.setLivingBase(getOwner());
nukeExplosion.applyExplosion();
}

View file

@ -39,7 +39,7 @@ public class TRRecipeHandler {
public static void unlockTRRecipes(ServerPlayerEntity playerMP) {
List<Recipe<?>> recipeList = new ArrayList<>();
for (Recipe<?> recipe : RecipeUtils.getRecipes(playerMP.world, RecipeType.CRAFTING)) {
for (Recipe<?> recipe : RecipeUtils.getRecipes(playerMP.getWorld(), RecipeType.CRAFTING)) {
if (isRecipeValid(recipe)) {
recipeList.add(recipe);
}

View file

@ -25,14 +25,12 @@
package techreborn.init;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import reborncore.common.fluid.*;
import techreborn.TechReborn;
@ -98,7 +96,7 @@ public enum ModFluids implements ItemConvertible {
flowingFluid = new RebornFluid(false, fluidSettings, () -> block, () -> bucket, () -> flowingFluid, () -> stillFluid) {
};
block = new RebornFluidBlock(stillFluid, FabricBlockSettings.of(Material.WATER).noCollision().hardness(100.0F).dropsNothing());
block = new RebornFluidBlock(stillFluid, TRBlockSettings.fluid());
bucket = new RebornBucketItem(stillFluid, new Item.Settings().recipeRemainder(Items.BUCKET).maxCount(1));
}

View file

@ -6,14 +6,19 @@ import net.minecraft.block.MapColor;
import net.minecraft.sound.BlockSoundGroup;
public class TRBlockSettings {
private static FabricBlockSettings metal() {
return FabricBlockSettings.create()
.sounds(BlockSoundGroup.METAL)
.mapColor(MapColor.IRON_GRAY)
.strength(2f, 2f);
}
public static FabricBlockSettings machine() {
return FabricBlockSettings.of()
.strength(2F, 2F)
.mapColor(MapColor.IRON_GRAY);
return metal();
}
public static FabricBlockSettings nuke() {
return FabricBlockSettings.of()
return FabricBlockSettings.create()
.strength(2F, 2F)
.mapColor(MapColor.BRIGHT_RED);
}
@ -24,11 +29,169 @@ public class TRBlockSettings {
.sounds(BlockSoundGroup.STONE);
}
private static FabricBlockSettings rubber(boolean noCollision, float hardness, float resistance) {
var settings = FabricBlockSettings.create()
.mapColor(MapColor.SPRUCE_BROWN)
.strength(hardness, resistance)
.sounds(BlockSoundGroup.WOOD);
if (noCollision) {
settings.noCollision();
}
return settings;
}
private static FabricBlockSettings rubber(float hardness, float resistance) {
return rubber(false, hardness, resistance);
}
public static FabricBlockSettings rubberWood() {
//TODO 1.20: remove cast with https://github.com/FabricMC/fabric/pull/3056
return (FabricBlockSettings) FabricBlockSettings.of()
.strength(2f, 2f)
.sounds(BlockSoundGroup.WOOD)
return rubber(2f, 2f)
.burnable();
}
public static FabricBlockSettings rubberLeaves() {
return FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
.mapColor(MapColor.SPRUCE_BROWN);
}
public static FabricBlockSettings rubberSapling() {
return FabricBlockSettings.copyOf(Blocks.OAK_SAPLING)
.mapColor(MapColor.SPRUCE_BROWN);
}
public static FabricBlockSettings rubberLog() {
return FabricBlockSettings.copyOf(Blocks.OAK_LOG)
.mapColor(MapColor.SPRUCE_BROWN);
}
public static FabricBlockSettings rubberTrapdoor() {
return rubber(3.0F, 3.0F);
}
public static FabricBlockSettings rubberDoor() {
return rubber(3.0F, 3.0F);
}
public static FabricBlockSettings rubberButton() {
return rubber(true, 0.5F, 0.5F);
}
public static FabricBlockSettings rubberPressurePlate() {
return rubber(true, 0.5F, 0.5F);
}
public static FabricBlockSettings refinedIronFence() {
return metal()
.strength(2.0F, 3.0F);
}
public static FabricBlockSettings storageBlock(boolean isHot, float hardness, float resistance) {
FabricBlockSettings settings = FabricBlockSettings.create()
.strength(hardness, resistance)
.mapColor(MapColor.IRON_GRAY) // TODO 1.20 maybe set the color based off the block?
.sounds(BlockSoundGroup.METAL);
if (isHot) {
settings = settings.luminance(15)
.nonOpaque();
}
return settings;
}
public static FabricBlockSettings ore(boolean deepslate) {
return FabricBlockSettings.create()
.requiresTool()
.sounds(deepslate ? BlockSoundGroup.DEEPSLATE : BlockSoundGroup.STONE)
.hardness(deepslate ? 4.5f : 3f)
.resistance(3f);
}
public static FabricBlockSettings machineFrame() {
return metal()
.strength(1f, 1f);
}
public static FabricBlockSettings machineCasing() {
return metal()
.strength(2f, 2f)
.requiresTool();
}
public static FabricBlockSettings energyStorage() {
return metal();
}
public static FabricBlockSettings lsuStorage() {
return metal();
}
public static FabricBlockSettings storageUnit(boolean wooden) {
if (!wooden) {
return metal();
}
return FabricBlockSettings.create()
.sounds(BlockSoundGroup.WOOD)
.mapColor(MapColor.OAK_TAN)
.strength(2f, 2f);
}
public static FabricBlockSettings fusionCoil() {
return metal();
}
public static FabricBlockSettings transformer() {
return metal();
}
public static FabricBlockSettings playerDetector() {
return metal();
}
public static FabricBlockSettings fluid() {
return FabricBlockSettings.copyOf(Blocks.WATER);
}
public static FabricBlockSettings computerCube() {
return metal();
}
public static FabricBlockSettings alarm() {
return metal();
}
public static FabricBlockSettings genericMachine() {
return metal();
}
public static FabricBlockSettings tankUnit() {
return metal();
}
public static FabricBlockSettings fusionControlComputer() {
return metal();
}
public static FabricBlockSettings solarPanel() {
return metal();
}
public static FabricBlockSettings cable() {
return metal().strength(1f, 8f);
}
public static FabricBlockSettings resinBasin() {
return FabricBlockSettings.create()
.mapColor(MapColor.OAK_TAN)
.sounds(BlockSoundGroup.WOOD)
.strength(2F, 2F);
}
public static FabricBlockSettings lightBlock() {
return FabricBlockSettings.copyOf(Blocks.REDSTONE_BLOCK)
.strength(2f, 2f);
}
}

View file

@ -28,14 +28,7 @@ import com.google.common.base.Preconditions;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.type.BlockSetTypeRegistry;
import net.fabricmc.fabric.api.object.builder.v1.block.type.WoodTypeRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSetType;
import net.minecraft.block.ExperienceDroppingBlock;
import net.minecraft.block.Material;
import net.minecraft.block.SlabBlock;
import net.minecraft.block.StairsBlock;
import net.minecraft.block.WallBlock;
import net.minecraft.block.WoodType;
import net.minecraft.block.*;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
@ -43,7 +36,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import net.minecraft.util.math.intprovider.UniformIntProvider;
@ -60,45 +52,19 @@ import techreborn.TechReborn;
import techreborn.blockentity.GuiType;
import techreborn.blockentity.generator.LightningRodBlockEntity;
import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
import techreborn.blockentity.generator.advanced.DieselGeneratorBlockEntity;
import techreborn.blockentity.generator.advanced.DragonEggSyphonBlockEntity;
import techreborn.blockentity.generator.advanced.GasTurbineBlockEntity;
import techreborn.blockentity.generator.advanced.SemiFluidGeneratorBlockEntity;
import techreborn.blockentity.generator.advanced.ThermalGeneratorBlockEntity;
import techreborn.blockentity.generator.advanced.*;
import techreborn.blockentity.generator.basic.SolidFuelGeneratorBlockEntity;
import techreborn.blockentity.generator.basic.WaterMillBlockEntity;
import techreborn.blockentity.generator.basic.WindMillBlockEntity;
import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity;
import techreborn.blockentity.machine.misc.DrainBlockEntity;
import techreborn.blockentity.machine.tier2.PumpBlockEntity;
import techreborn.blockentity.machine.multiblock.DistillationTowerBlockEntity;
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
import techreborn.blockentity.machine.multiblock.ImplosionCompressorBlockEntity;
import techreborn.blockentity.machine.multiblock.IndustrialBlastFurnaceBlockEntity;
import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity;
import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity;
import techreborn.blockentity.machine.multiblock.VacuumFreezerBlockEntity;
import techreborn.blockentity.machine.multiblock.*;
import techreborn.blockentity.machine.tier0.block.BlockBreakerBlockEntity;
import techreborn.blockentity.machine.tier0.block.BlockPlacerBlockEntity;
import techreborn.blockentity.machine.tier1.AlloySmelterBlockEntity;
import techreborn.blockentity.machine.tier1.AssemblingMachineBlockEntity;
import techreborn.blockentity.machine.tier1.AutoCraftingTableBlockEntity;
import techreborn.blockentity.machine.tier1.ChemicalReactorBlockEntity;
import techreborn.blockentity.machine.tier1.CompressorBlockEntity;
import techreborn.blockentity.machine.tier1.ElectricFurnaceBlockEntity;
import techreborn.blockentity.machine.tier1.ElevatorBlockEntity;
import techreborn.blockentity.machine.tier1.ExtractorBlockEntity;
import techreborn.blockentity.machine.tier1.GreenhouseControllerBlockEntity;
import techreborn.blockentity.machine.tier1.GrinderBlockEntity;
import techreborn.blockentity.machine.tier1.IndustrialElectrolyzerBlockEntity;
import techreborn.blockentity.machine.tier1.RecyclerBlockEntity;
import techreborn.blockentity.machine.tier1.ResinBasinBlockEntity;
import techreborn.blockentity.machine.tier1.RollingMachineBlockEntity;
import techreborn.blockentity.machine.tier1.ScrapboxinatorBlockEntity;
import techreborn.blockentity.machine.tier1.SolidCanningMachineBlockEntity;
import techreborn.blockentity.machine.tier1.WireMillBlockEntity;
import techreborn.blockentity.machine.tier1.*;
import techreborn.blockentity.machine.tier2.FishingStationBlockEntity;
import techreborn.blockentity.machine.tier2.LaunchpadBlockEntity;
import techreborn.blockentity.machine.tier2.PumpBlockEntity;
import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity;
import techreborn.blockentity.machine.tier3.IndustrialCentrifugeBlockEntity;
import techreborn.blockentity.machine.tier3.MatterFabricatorBlockEntity;
@ -114,18 +80,8 @@ import techreborn.blocks.machine.tier0.IronAlloyFurnaceBlock;
import techreborn.blocks.machine.tier0.IronFurnaceBlock;
import techreborn.blocks.machine.tier1.PlayerDetectorBlock;
import techreborn.blocks.machine.tier1.ResinBasinBlock;
import techreborn.blocks.misc.BlockAlarm;
import techreborn.blocks.misc.BlockMachineCasing;
import techreborn.blocks.misc.BlockMachineFrame;
import techreborn.blocks.misc.BlockStorage;
import techreborn.blocks.misc.TechRebornStairsBlock;
import techreborn.blocks.storage.energy.AdjustableSUBlock;
import techreborn.blocks.storage.energy.HighVoltageSUBlock;
import techreborn.blocks.storage.energy.InterdimensionalSUBlock;
import techreborn.blocks.storage.energy.LSUStorageBlock;
import techreborn.blocks.storage.energy.LapotronicSUBlock;
import techreborn.blocks.storage.energy.LowVoltageSUBlock;
import techreborn.blocks.storage.energy.MediumVoltageSUBlock;
import techreborn.blocks.misc.*;
import techreborn.blocks.storage.energy.*;
import techreborn.blocks.storage.fluid.TankUnitBlock;
import techreborn.blocks.storage.item.StorageUnitBlock;
import techreborn.blocks.transformers.BlockEVTransformer;
@ -142,14 +98,7 @@ import techreborn.items.armor.QuantumSuitItem;
import techreborn.utils.InitUtils;
import techreborn.world.OreDistribution;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -586,13 +535,7 @@ public class TRContent {
Ores(OreDistribution distribution, UniformIntProvider experienceDroppedFallback, boolean industrial) {
name = this.toString().toLowerCase(Locale.ROOT);
block = new ExperienceDroppingBlock(FabricBlockSettings.of(Material.STONE)
.requiresTool()
.sounds(name.startsWith("deepslate") ? BlockSoundGroup.DEEPSLATE : BlockSoundGroup.STONE)
.hardness(name.startsWith("deepslate") ? 4.5f : 3f)
.resistance(3f),
distribution != null ? distribution.experienceDropped : experienceDroppedFallback
);
block = new ExperienceDroppingBlock(TRBlockSettings.ore(name.startsWith("deepslate")));
this.industrial = industrial;
InitUtils.setup(block, name + "_ore");
tag = TagKey.of(RegistryKeys.ITEM, new Identifier("c",
@ -1647,6 +1590,6 @@ public class TRContent {
static {
ModRegistry.register();
TRItemGroup.ITEM_GROUP.getId();
TRItemGroup.register();
}
}

View file

@ -31,6 +31,11 @@ import net.minecraft.enchantment.Enchantments;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.*;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import reborncore.common.fluid.FluidUtils;
import reborncore.common.powerSystem.RcEnergyItem;
@ -41,14 +46,19 @@ import techreborn.items.tool.industrial.NanosaberItem;
import techreborn.utils.MaterialComparator;
import techreborn.utils.MaterialTypeComparator;
import java.util.*;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class TRItemGroup {
public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder(new Identifier(TechReborn.MOD_ID, "item_group"))
.icon(() -> new ItemStack(TRContent.NUKE))
.build();
private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, new Identifier(TechReborn.MOD_ID, "item_group"));
public static void register() {
Registry.register(Registries.ITEM_GROUP, ITEM_GROUP, FabricItemGroup.builder()
.displayName(Text.translatable("itemGroup.techreborn.item_group"))
.icon(() -> new ItemStack(TRContent.NUKE))
.build());
static {
ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP).register(TRItemGroup::entries);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(TRItemGroup::addBuildingBlocks);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.COLORED_BLOCKS).register(TRItemGroup::addColoredBlocks);

View file

@ -34,7 +34,6 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
import net.minecraft.block.BlockState;
import net.minecraft.block.FluidDrainable;
import net.minecraft.block.FluidFillable;
import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.FlowableFluid;
import net.minecraft.fluid.Fluid;
@ -113,7 +112,6 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
}
BlockState blockState = world.getBlockState(pos);
Material material = blockState.getMaterial();
boolean canPlace = blockState.canBucketPlace(fluid);
if (!blockState.isAir() && !canPlace && (!(blockState.getBlock() instanceof FluidFillable) || !((FluidFillable) blockState.getBlock()).canFillWithFluid(world, pos, blockState, fluid))) {
@ -134,7 +132,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
this.playEmptyingSound(player, world, pos, fluid);
}
} else {
if (!world.isClient && canPlace && !material.isLiquid()) {
if (!world.isClient && canPlace && !blockState.isLiquid()) {
world.breakBlock(pos, true);
}

View file

@ -25,11 +25,14 @@
package techreborn.items.tool;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.*;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.PickaxeItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.powerSystem.RcEnergyItem;
@ -57,7 +60,7 @@ public class JackhammerItem extends PickaxeItem implements RcEnergyItem {
if (getStoredEnergy(stack) < cost) return unpoweredSpeed;
if (ToolsUtil.JackHammerSkippedBlocks(state)) return unpoweredSpeed;
if (state.getMaterial() == Material.STONE) {
if (state.isIn(BlockTags.STONE_ORE_REPLACEABLES)) {
return miningSpeed;
} else {
return unpoweredSpeed;

View file

@ -44,8 +44,8 @@ public class WrenchItem extends Item implements IToolHandler {
@Override
public boolean handleTool(ItemStack stack, BlockPos pos, World world, PlayerEntity player, Direction side, boolean damage) {
if (!player.world.isClient && damage) {
stack.damage(1, player.world.random, (ServerPlayerEntity) player);
if (!player.getWorld().isClient && damage) {
stack.damage(1, player.getWorld().random, (ServerPlayerEntity) player);
}
return true;
}

View file

@ -25,7 +25,6 @@
package techreborn.items.tool.industrial;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -58,10 +57,10 @@ public class IndustrialDrillItem extends DrillItem {
return false;
}
BlockState blockState = worldIn.getBlockState(pos);
if (blockState.getMaterial() == Material.AIR) {
if (blockState.isAir()) {
return false;
}
if (blockState.getMaterial().isLiquid()) {
if (blockState.isLiquid()) {
return false;
}
float blockHardness = blockState.calcBlockBreakingDelta(playerIn, worldIn, pos);

View file

@ -26,7 +26,7 @@ package techreborn.multiblocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
@ -325,9 +325,9 @@ public class MultiBlockCasing extends RectangularMultiblockControllerBase {
protected void isBlockGoodForInterior(World world, int x, int y, int z) throws MultiblockValidationException {
BlockState state = world.getBlockState(new BlockPos(x, y, z));
if (state.getMaterial().equals(Material.AIR)) {
if (state.isAir()) {
} else if (state.getMaterial().equals(Material.LAVA)) {
} else if (state.getBlock() == Blocks.LAVA) {
hasLava = true;
} else {
super.isBlockGoodForInterior(world, x, y, z);

View file

@ -70,7 +70,7 @@ public class ServerboundPackets {
boolean ctrl = buf.readBoolean();
server.execute(() -> {
BlockEntity blockEntity = player.world.getBlockEntity(pos);
BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
if (blockEntity instanceof AdjustableSUBlockEntity) {
((AdjustableSUBlockEntity) blockEntity).handleGuiInputFromClient(buttonID, shift, ctrl);
}
@ -82,7 +82,7 @@ public class ServerboundPackets {
boolean locked = buf.readBoolean();
server.execute(() -> {
BlockEntity BlockEntity = player.world.getBlockEntity(machinePos);
BlockEntity BlockEntity = player.getWorld().getBlockEntity(machinePos);
if (BlockEntity instanceof AutoCraftingTableBlockEntity) {
((AutoCraftingTableBlockEntity) BlockEntity).locked = locked;
}
@ -94,7 +94,7 @@ public class ServerboundPackets {
BlockPos pos = buf.readBlockPos();
server.execute(() -> {
BlockEntity blockEntity = player.world.getBlockEntity(pos);
BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
if (blockEntity instanceof FusionControlComputerBlockEntity) {
((FusionControlComputerBlockEntity) blockEntity).changeSize(sizeDelta);
}
@ -106,7 +106,7 @@ public class ServerboundPackets {
boolean locked = buf.readBoolean();
server.execute(() -> {
BlockEntity BlockEntity = player.world.getBlockEntity(machinePos);
BlockEntity BlockEntity = player.getWorld().getBlockEntity(machinePos);
if (BlockEntity instanceof RollingMachineBlockEntity) {
((RollingMachineBlockEntity) BlockEntity).locked = locked;
}
@ -118,7 +118,7 @@ public class ServerboundPackets {
boolean locked = buf.readBoolean();
server.execute(() -> {
BlockEntity BlockEntity = player.world.getBlockEntity(machinePos);
BlockEntity BlockEntity = player.getWorld().getBlockEntity(machinePos);
if (BlockEntity instanceof StorageUnitBaseBlockEntity) {
((StorageUnitBaseBlockEntity) BlockEntity).setLocked(locked);
}
@ -149,7 +149,7 @@ public class ServerboundPackets {
boolean sync = buf.readBoolean();
server.execute(() -> {
BlockEntity blockEntity = player.world.getBlockEntity(pos);
BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
if (blockEntity instanceof ChunkLoaderBlockEntity) {
((ChunkLoaderBlockEntity) blockEntity).handleGuiInputFromClient(buttonID, sync ? player : null);
}
@ -160,7 +160,7 @@ public class ServerboundPackets {
BlockPos pos = buf.readBlockPos();
server.execute(() -> {
BlockEntity blockEntity = player.world.getBlockEntity(pos);
BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
if (blockEntity instanceof IronFurnaceBlockEntity) {
((IronFurnaceBlockEntity) blockEntity).handleGuiInputFromClient(player);
}
@ -172,7 +172,7 @@ public class ServerboundPackets {
int buttonAmount = buf.readInt();
server.execute(() -> {
BlockEntity blockEntity = player.world.getBlockEntity(pos);
BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
if (blockEntity instanceof PlayerDetectorBlockEntity) {
((PlayerDetectorBlockEntity) blockEntity).handleGuiInputFromClient(buttonAmount);
}
@ -184,7 +184,7 @@ public class ServerboundPackets {
int buttonAmount = buf.readInt();
server.execute(() -> {
BlockEntity blockEntity = player.world.getBlockEntity(pos);
BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
if (blockEntity instanceof LaunchpadBlockEntity) {
((LaunchpadBlockEntity) blockEntity).handleGuiInputFromClient(buttonAmount);
}
@ -207,7 +207,7 @@ public class ServerboundPackets {
int buttonAmount = buf.readInt();
server.execute(() -> {
BlockEntity blockEntity = player.world.getBlockEntity(pos);
BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
if (blockEntity instanceof PumpBlockEntity) {
((PumpBlockEntity) blockEntity).handleDepthGuiInputFromClient(buttonAmount);
}
@ -219,7 +219,7 @@ public class ServerboundPackets {
int buttonAmount = buf.readInt();
server.execute(() -> {
BlockEntity blockEntity = player.world.getBlockEntity(pos);
BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
if (blockEntity instanceof PumpBlockEntity) {
((PumpBlockEntity) blockEntity).handleRangeGuiInputFromClient(buttonAmount);
}

View file

@ -24,17 +24,12 @@
package techreborn.utils;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.MapColor;
import net.minecraft.block.Material;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.registry.Registry;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.registry.Registry;
import reborncore.RebornRegistry;
import techreborn.TechReborn;
@ -54,22 +49,6 @@ public class InitUtils {
return Registry.register(Registries.SOUND_EVENT, identifier, SoundEvent.of(identifier));
}
public static AbstractBlock.Settings setupRubberBlockSettings(boolean noCollision, float hardness, float resistance) {
FabricBlockSettings settings = FabricBlockSettings.of(Material.WOOD, MapColor.SPRUCE_BROWN);
settings.strength(hardness, resistance);
settings.sounds(BlockSoundGroup.WOOD);
if (noCollision) {
settings.noCollision();
}
settings.materialColor(MapColor.SPRUCE_BROWN);
return settings;
}
public static AbstractBlock.Settings setupRubberBlockSettings(float hardness, float resistance) {
return setupRubberBlockSettings(false, hardness, resistance);
}
public static boolean isDatagenRunning() {
return System.getProperty("fabric-api.datagen") != null;
}

View file

@ -172,10 +172,10 @@ public class ToolsUtil {
* @return {@code boolean} True if block shouldn't be breakable by JackHammer
*/
public static boolean JackHammerSkippedBlocks(BlockState blockState){
if (blockState.getMaterial() == Material.AIR) {
if (blockState.isAir()) {
return true;
}
if (blockState.getMaterial().isLiquid()) {
if (blockState.isLiquid()) {
return true;
}
if (blockState.isIn(ConventionalBlockTags.ORES)) {

View file

@ -3,7 +3,7 @@ accessWidener v2 named
accessible method net/minecraft/recipe/ShapedRecipe readSymbols (Lcom/google/gson/JsonObject;)Ljava/util/Map;
accessible method net/minecraft/recipe/ShapedRecipe getPattern (Lcom/google/gson/JsonArray;)[Ljava/lang/String;
accessible method net/minecraft/recipe/ShapedRecipe createPatternMatrix ([Ljava/lang/String;Ljava/util/Map;II)Lnet/minecraft/util/collection/DefaultedList;
accessible method net/minecraft/recipe/ShapedRecipe matchesPattern (Lnet/minecraft/class_8566;IIZ)Z
accessible method net/minecraft/recipe/ShapedRecipe matchesPattern (Lnet/minecraft/inventory/RecipeInputInventory;IIZ)Z
accessible class net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder$ShapedRecipeJsonProvider
accessible method net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder validate (Lnet/minecraft/util/Identifier;)V