Start on new block settings.
This commit is contained in:
parent
503ed7ee49
commit
133f64ac9f
9 changed files with 53 additions and 29 deletions
|
@ -31,7 +31,6 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.InventoryProvider;
|
import net.minecraft.block.InventoryProvider;
|
||||||
import net.minecraft.block.Material;
|
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -68,10 +67,6 @@ public abstract class BlockMachineBase extends BaseBlockEntityProvider implement
|
||||||
|
|
||||||
boolean hasCustomStates;
|
boolean hasCustomStates;
|
||||||
|
|
||||||
public BlockMachineBase() {
|
|
||||||
this(Block.Settings.of(Material.METAL).strength(2F, 2F));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockMachineBase(Block.Settings builder) {
|
public BlockMachineBase(Block.Settings builder) {
|
||||||
this(builder, false);
|
this(builder, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class ServerBoundPackets {
|
||||||
|
|
||||||
server.execute(() -> {
|
server.execute(() -> {
|
||||||
FluidConfiguration.FluidConfig fluidConfiguration = new FluidConfiguration.FluidConfig(compoundTag);
|
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.fluidConfiguration.updateFluidConfig(fluidConfiguration);
|
||||||
legacyMachineBase.markDirty();
|
legacyMachineBase.markDirty();
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class ServerBoundPackets {
|
||||||
NbtCompound tagCompound = packetBuffer.readNbt();
|
NbtCompound tagCompound = packetBuffer.readNbt();
|
||||||
|
|
||||||
server.execute(() -> {
|
server.execute(() -> {
|
||||||
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
|
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.getWorld().getBlockEntity(pos);
|
||||||
legacyMachineBase.getSlotConfiguration().read(tagCompound);
|
legacyMachineBase.getSlotConfiguration().read(tagCompound);
|
||||||
legacyMachineBase.markDirty();
|
legacyMachineBase.markDirty();
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class ServerBoundPackets {
|
||||||
boolean output = packetBuffer.readBoolean();
|
boolean output = packetBuffer.readBoolean();
|
||||||
|
|
||||||
server.execute(() -> {
|
server.execute(() -> {
|
||||||
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
|
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.getWorld().getBlockEntity(pos);
|
||||||
FluidConfiguration config = legacyMachineBase.fluidConfiguration;
|
FluidConfiguration config = legacyMachineBase.fluidConfiguration;
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -104,7 +104,7 @@ public class ServerBoundPackets {
|
||||||
boolean filter = packetBuffer.readBoolean();
|
boolean filter = packetBuffer.readBoolean();
|
||||||
|
|
||||||
server.execute(() -> {
|
server.execute(() -> {
|
||||||
MachineBaseBlockEntity machineBase = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
|
MachineBaseBlockEntity machineBase = (MachineBaseBlockEntity) player.getWorld().getBlockEntity(pos);
|
||||||
Validate.notNull(machineBase, "machine cannot be null");
|
Validate.notNull(machineBase, "machine cannot be null");
|
||||||
SlotConfiguration.SlotConfigHolder holder = machineBase.getSlotConfiguration().getSlotDetails(slotID);
|
SlotConfiguration.SlotConfigHolder holder = machineBase.getSlotConfiguration().getSlotDetails(slotID);
|
||||||
if (holder == null) {
|
if (holder == null) {
|
||||||
|
@ -127,7 +127,7 @@ public class ServerBoundPackets {
|
||||||
|
|
||||||
server.execute(() -> {
|
server.execute(() -> {
|
||||||
SlotConfiguration.SlotConfig slotConfig = new SlotConfiguration.SlotConfig(compoundTag);
|
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.getSlotConfiguration().getSlotDetails(slotConfig.getSlotID()).updateSlotConfig(slotConfig);
|
||||||
legacyMachineBase.markDirty();
|
legacyMachineBase.markDirty();
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ public class ServerBoundPackets {
|
||||||
BlockPos pos = packetBuffer.readBlockPos();
|
BlockPos pos = packetBuffer.readBlockPos();
|
||||||
server.execute(() -> {
|
server.execute(() -> {
|
||||||
Validate.isInstanceOf(ServerPlayerEntity.class, player, "something very very bad has happened");
|
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);
|
chunkLoaderManager.syncChunkLoaderToClient((ServerPlayerEntity) player, pos);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -157,7 +157,7 @@ public class ServerBoundPackets {
|
||||||
RedstoneConfiguration.State state = RedstoneConfiguration.State.values()[stateId];
|
RedstoneConfiguration.State state = RedstoneConfiguration.State.values()[stateId];
|
||||||
|
|
||||||
server.execute(() -> {
|
server.execute(() -> {
|
||||||
MachineBaseBlockEntity blockEntity = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
|
MachineBaseBlockEntity blockEntity = (MachineBaseBlockEntity) player.getWorld().getBlockEntity(pos);
|
||||||
if (blockEntity == null) return;
|
if (blockEntity == null) return;
|
||||||
|
|
||||||
blockEntity.getRedstoneConfiguration().setState(element, state);
|
blockEntity.getRedstoneConfiguration().setState(element, state);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
package reborncore.common.recipes;
|
package reborncore.common.recipes;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import net.minecraft.inventory.CraftingInventory;
|
import net.minecraft.class_8566;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.recipe.Ingredient;
|
import net.minecraft.recipe.Ingredient;
|
||||||
import net.minecraft.recipe.RecipeSerializer;
|
import net.minecraft.recipe.RecipeSerializer;
|
||||||
|
@ -66,7 +66,7 @@ public class PaddedShapedRecipe extends ShapedRecipe {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 i = 0; i <= craftingInventory.getWidth() - this.getWidth(); ++i) {
|
||||||
for(int j = 0; j <= craftingInventory.getHeight() - this.getHeight(); ++j) {
|
for(int j = 0; j <= craftingInventory.getHeight() - this.getHeight(); ++j) {
|
||||||
if (this.matchesPattern(craftingInventory, i, j, false)) {
|
if (this.matchesPattern(craftingInventory, i, j, false)) {
|
||||||
|
|
|
@ -46,6 +46,7 @@ import team.reborn.energy.api.EnergyStorageUtil;
|
||||||
import team.reborn.energy.api.base.SimpleBatteryItem;
|
import team.reborn.energy.api.base.SimpleBatteryItem;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +62,7 @@ public class ItemUtils {
|
||||||
if (a.getItem() != b.getItem()) {
|
if (a.getItem() != b.getItem()) {
|
||||||
return false;
|
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,
|
public static boolean isItemEqual(ItemStack a, ItemStack b, boolean matchNBT,
|
||||||
|
|
|
@ -47,9 +47,9 @@ public abstract class MixinItemEntity extends Entity {
|
||||||
|
|
||||||
@Inject(method = "tick", at = @At("RETURN"))
|
@Inject(method = "tick", at = @At("RETURN"))
|
||||||
public void tick(CallbackInfo info) {
|
public void tick(CallbackInfo info) {
|
||||||
if (!world.isClient && isTouchingWater() && !getStack().isEmpty()) {
|
if (!getWorld().isClient && isTouchingWater() && !getStack().isEmpty()) {
|
||||||
if (getStack().isIn(RebornCoreTags.WATER_EXPLOSION_ITEM)) {
|
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);
|
this.remove(RemovalReason.KILLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ package techreborn.blocks.misc;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||||
|
@ -41,6 +40,7 @@ import net.minecraft.world.explosion.Explosion;
|
||||||
import reborncore.common.BaseBlock;
|
import reborncore.common.BaseBlock;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.entities.EntityNukePrimed;
|
import techreborn.entities.EntityNukePrimed;
|
||||||
|
import techreborn.init.TRBlockSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Mark on 13/03/2016.
|
* Created by Mark on 13/03/2016.
|
||||||
|
@ -49,7 +49,7 @@ public class BlockNuke extends BaseBlock {
|
||||||
public static BooleanProperty OVERLAY = BooleanProperty.of("overlay");
|
public static BooleanProperty OVERLAY = BooleanProperty.of("overlay");
|
||||||
|
|
||||||
public BlockNuke() {
|
public BlockNuke() {
|
||||||
super(Block.Settings.of(Material.TNT));
|
super(TRBlockSettings.nuke());
|
||||||
this.setDefaultState(this.getStateManager().getDefaultState().with(OVERLAY, false));
|
this.setDefaultState(this.getStateManager().getDefaultState().with(OVERLAY, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,15 +24,11 @@
|
||||||
|
|
||||||
package techreborn.blocks.misc;
|
package techreborn.blocks.misc;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|
||||||
import net.minecraft.block.GlassBlock;
|
import net.minecraft.block.GlassBlock;
|
||||||
import net.minecraft.block.Material;
|
import techreborn.init.TRBlockSettings;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
|
||||||
|
|
||||||
public class BlockReinforcedGlass extends GlassBlock {
|
public class BlockReinforcedGlass extends GlassBlock {
|
||||||
|
|
||||||
public BlockReinforcedGlass() {
|
public BlockReinforcedGlass() {
|
||||||
super(FabricBlockSettings.of(Material.GLASS).strength(4f, 60f).sounds(BlockSoundGroup.STONE).nonOpaque());
|
super(TRBlockSettings.reinforcedGlass());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,9 @@
|
||||||
|
|
||||||
package techreborn.blocks.misc;
|
package techreborn.blocks.misc;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|
||||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.Material;
|
import techreborn.init.TRBlockSettings;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 20/02/2016.
|
* Created by modmuss50 on 20/02/2016.
|
||||||
|
@ -36,7 +34,7 @@ import net.minecraft.sound.BlockSoundGroup;
|
||||||
public class BlockRubberPlank extends Block {
|
public class BlockRubberPlank extends Block {
|
||||||
|
|
||||||
public BlockRubberPlank() {
|
public BlockRubberPlank() {
|
||||||
super(FabricBlockSettings.of(Material.WOOD).strength(2f, 2f).sounds(BlockSoundGroup.WOOD));
|
super(TRBlockSettings.rubberWood());
|
||||||
FlammableBlockRegistry.getDefaultInstance().add(this, 5, 20);
|
FlammableBlockRegistry.getDefaultInstance().add(this, 5, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
34
src/main/java/techreborn/init/TRBlockSettings.java
Normal file
34
src/main/java/techreborn/init/TRBlockSettings.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue