Start on new block settings.

This commit is contained in:
modmuss50 2023-05-10 23:03:58 +01:00 committed by modmuss
parent 503ed7ee49
commit 133f64ac9f
9 changed files with 53 additions and 29 deletions

View file

@ -31,7 +31,6 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.InventoryProvider;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -68,10 +67,6 @@ public abstract class BlockMachineBase extends BaseBlockEntityProvider implement
boolean hasCustomStates;
public BlockMachineBase() {
this(Block.Settings.of(Material.METAL).strength(2F, 2F));
}
public BlockMachineBase(Block.Settings builder) {
this(builder, false);
}

View file

@ -47,7 +47,7 @@ public class ServerBoundPackets {
server.execute(() -> {
FluidConfiguration.FluidConfig fluidConfiguration = new FluidConfiguration.FluidConfig(compoundTag);
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.getWorld().getBlockEntity(pos);
legacyMachineBase.fluidConfiguration.updateFluidConfig(fluidConfiguration);
legacyMachineBase.markDirty();
@ -67,7 +67,7 @@ public class ServerBoundPackets {
NbtCompound tagCompound = packetBuffer.readNbt();
server.execute(() -> {
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.getWorld().getBlockEntity(pos);
legacyMachineBase.getSlotConfiguration().read(tagCompound);
legacyMachineBase.markDirty();
@ -82,7 +82,7 @@ public class ServerBoundPackets {
boolean output = packetBuffer.readBoolean();
server.execute(() -> {
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.getWorld().getBlockEntity(pos);
FluidConfiguration config = legacyMachineBase.fluidConfiguration;
if (config == null) {
return;
@ -104,7 +104,7 @@ public class ServerBoundPackets {
boolean filter = packetBuffer.readBoolean();
server.execute(() -> {
MachineBaseBlockEntity machineBase = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
MachineBaseBlockEntity machineBase = (MachineBaseBlockEntity) player.getWorld().getBlockEntity(pos);
Validate.notNull(machineBase, "machine cannot be null");
SlotConfiguration.SlotConfigHolder holder = machineBase.getSlotConfiguration().getSlotDetails(slotID);
if (holder == null) {
@ -127,7 +127,7 @@ public class ServerBoundPackets {
server.execute(() -> {
SlotConfiguration.SlotConfig slotConfig = new SlotConfiguration.SlotConfig(compoundTag);
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.getWorld().getBlockEntity(pos);
legacyMachineBase.getSlotConfiguration().getSlotDetails(slotConfig.getSlotID()).updateSlotConfig(slotConfig);
legacyMachineBase.markDirty();
@ -140,7 +140,7 @@ public class ServerBoundPackets {
BlockPos pos = packetBuffer.readBlockPos();
server.execute(() -> {
Validate.isInstanceOf(ServerPlayerEntity.class, player, "something very very bad has happened");
ChunkLoaderManager chunkLoaderManager = ChunkLoaderManager.get(player.world);
ChunkLoaderManager chunkLoaderManager = ChunkLoaderManager.get(player.getWorld());
chunkLoaderManager.syncChunkLoaderToClient((ServerPlayerEntity) player, pos);
});
});
@ -157,7 +157,7 @@ public class ServerBoundPackets {
RedstoneConfiguration.State state = RedstoneConfiguration.State.values()[stateId];
server.execute(() -> {
MachineBaseBlockEntity blockEntity = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
MachineBaseBlockEntity blockEntity = (MachineBaseBlockEntity) player.getWorld().getBlockEntity(pos);
if (blockEntity == null) return;
blockEntity.getRedstoneConfiguration().setState(element, state);

View file

@ -25,7 +25,7 @@
package reborncore.common.recipes;
import com.google.gson.JsonObject;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.class_8566;
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(CraftingInventory craftingInventory, World world) {
public boolean matches(class_8566 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

@ -46,6 +46,7 @@ import team.reborn.energy.api.EnergyStorageUtil;
import team.reborn.energy.api.base.SimpleBatteryItem;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
/**
@ -61,7 +62,7 @@ public class ItemUtils {
if (a.getItem() != b.getItem()) {
return false;
}
return !matchNBT || ItemStack.areNbtEqual(a, b);
return !matchNBT || Objects.equals(a.getNbt(), b.getNbt());
}
public static boolean isItemEqual(ItemStack a, ItemStack b, boolean matchNBT,

View file

@ -47,9 +47,9 @@ public abstract class MixinItemEntity extends Entity {
@Inject(method = "tick", at = @At("RETURN"))
public void tick(CallbackInfo info) {
if (!world.isClient && isTouchingWater() && !getStack().isEmpty()) {
if (!getWorld().isClient && isTouchingWater() && !getStack().isEmpty()) {
if (getStack().isIn(RebornCoreTags.WATER_EXPLOSION_ITEM)) {
world.createExplosion(this, getX(), getY(), getZ(), 2F, World.ExplosionSourceType.NONE);
getWorld().createExplosion(this, getX(), getY(), getZ(), 2F, World.ExplosionSourceType.NONE);
this.remove(RemovalReason.KILLED);
}
}

View file

@ -27,7 +27,6 @@ package techreborn.blocks.misc;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
@ -41,6 +40,7 @@ import net.minecraft.world.explosion.Explosion;
import reborncore.common.BaseBlock;
import techreborn.config.TechRebornConfig;
import techreborn.entities.EntityNukePrimed;
import techreborn.init.TRBlockSettings;
/**
* Created by Mark on 13/03/2016.
@ -49,7 +49,7 @@ public class BlockNuke extends BaseBlock {
public static BooleanProperty OVERLAY = BooleanProperty.of("overlay");
public BlockNuke() {
super(Block.Settings.of(Material.TNT));
super(TRBlockSettings.nuke());
this.setDefaultState(this.getStateManager().getDefaultState().with(OVERLAY, false));
}

View file

@ -24,15 +24,11 @@
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.GlassBlock;
import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;
import techreborn.init.TRBlockSettings;
public class BlockReinforcedGlass extends GlassBlock {
public BlockReinforcedGlass() {
super(FabricBlockSettings.of(Material.GLASS).strength(4f, 60f).sounds(BlockSoundGroup.STONE).nonOpaque());
super(TRBlockSettings.reinforcedGlass());
}
}

View file

@ -24,11 +24,9 @@
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.Block;
import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;
import techreborn.init.TRBlockSettings;
/**
* Created by modmuss50 on 20/02/2016.
@ -36,7 +34,7 @@ import net.minecraft.sound.BlockSoundGroup;
public class BlockRubberPlank extends Block {
public BlockRubberPlank() {
super(FabricBlockSettings.of(Material.WOOD).strength(2f, 2f).sounds(BlockSoundGroup.WOOD));
super(TRBlockSettings.rubberWood());
FlammableBlockRegistry.getDefaultInstance().add(this, 5, 20);
}
}

View file

@ -0,0 +1,34 @@
package techreborn.init;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Blocks;
import net.minecraft.block.MapColor;
import net.minecraft.sound.BlockSoundGroup;
public class TRBlockSettings {
public static FabricBlockSettings machine() {
return FabricBlockSettings.of()
.strength(2F, 2F)
.mapColor(MapColor.IRON_GRAY);
}
public static FabricBlockSettings nuke() {
return FabricBlockSettings.of()
.strength(2F, 2F)
.mapColor(MapColor.BRIGHT_RED);
}
public static FabricBlockSettings reinforcedGlass() {
return FabricBlockSettings.copyOf(Blocks.GLASS)
.strength(4f, 60f)
.sounds(BlockSoundGroup.STONE);
}
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)
.burnable();
}
}