1.17: TechReborn compiles and runs, big thanks to @petabyteboy

Co-authored-by: Milan Pässler <milan@petabyte.dev>
This commit is contained in:
modmuss50 2021-05-29 13:19:29 +01:00
parent c661de5254
commit b33f4be5f4
212 changed files with 952 additions and 2025 deletions

View file

@ -62,6 +62,18 @@ public class BiObseravable<A, B> {
return b;
}
public boolean hasA() {
return a != null;
}
public boolean hasB() {
return b != null;
}
public boolean hasBoth() {
return hasA() && hasB();
}
private void fireListeners() {
if (a == null || b == null) {
return;

View file

@ -153,9 +153,9 @@ dependencies {
api project(":RebornCore")
include project(":RebornCore")
optionalDependency "me.shedaniel:RoughlyEnoughItems:5.8.9"
disabledOptionalDependency "me.shedaniel:RoughlyEnoughItems:5.8.9"
disabledOptionalDependency ('com.github.emilyploszaj:trinkets:2.6.7')
optionalDependency "com.github.dexman545:autoswitch-api:-SNAPSHOT"
disabledOptionalDependency "com.github.dexman545:autoswitch-api:-SNAPSHOT"
}
def optionalDependency(String dep) {

View file

@ -31,6 +31,7 @@ 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;
import net.minecraft.client.render.model.ModelBakeSettings;
@ -182,7 +183,7 @@ public class TechRebornClient implements ClientModInitializer {
registerPredicateProvider(
BatpackItem.class,
new Identifier("techreborn:empty"),
(item, stack, world, entity) -> {
(item, stack, world, entity, seed) -> {
if (!stack.isEmpty() && Energy.of(stack).getEnergy() == 0) {
return 1.0F;
}
@ -193,7 +194,7 @@ public class TechRebornClient implements ClientModInitializer {
registerPredicateProvider(
BatteryItem.class,
new Identifier("techreborn:empty"),
(item, stack, world, entity) -> {
(item, stack, world, entity, seed) -> {
if (!stack.isEmpty() && Energy.of(stack).getEnergy() == 0) {
return 1.0F;
}
@ -204,7 +205,7 @@ public class TechRebornClient implements ClientModInitializer {
registerPredicateProvider(
FrequencyTransmitterItem.class,
new Identifier("techreborn:coords"),
(item, stack, world, entity) -> {
(item, stack, world, entity, seed) -> {
if (!stack.isEmpty() && stack.hasTag() && stack.getTag() != null && stack.getTag().contains("x")
&& stack.getTag().contains("y") && stack.getTag().contains("z") && stack.getTag().contains("dim")) {
return 1.0F;
@ -216,7 +217,7 @@ public class TechRebornClient implements ClientModInitializer {
registerPredicateProvider(
ChainsawItem.class,
new Identifier("techreborn:animated"),
(item, stack, world, entity) -> {
(item, stack, world, entity, seed) -> {
if (!stack.isEmpty() && Energy.of(stack).getEnergy() >= item.getCost() && entity != null && entity.getMainHandStack().equals(stack)) {
return 1.0F;
}
@ -227,7 +228,7 @@ public class TechRebornClient implements ClientModInitializer {
registerPredicateProvider(
NanosaberItem.class,
new Identifier("techreborn:active"),
(item, stack, world, entity) -> {
(item, stack, world, entity, seed) -> {
if (ItemUtils.isActive(stack)) {
if (Energy.of(stack).getMaxStored() - Energy.of(stack).getEnergy() >= 0.9 * Energy.of(stack).getMaxStored()) {
return 0.5F;
@ -247,13 +248,14 @@ public class TechRebornClient implements ClientModInitializer {
}
//Need the item instance in a few places, this makes it easier
private interface ItemModelPredicateProvider<T extends Item> extends ModelPredicateProvider {
private interface ItemModelPredicateProvider<T extends Item> extends UnclampedModelPredicateProvider {
float call(T item, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity);
float call(T item, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity, int seed);
@Override
default float call(ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity) {
return call((T) stack.getItem(), stack, world, entity);
default float unclampedCall(ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity, int seed) {
return call((T) stack.getItem(), stack, world, entity, seed);
}
}
}

View file

@ -36,8 +36,10 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Tickable;
import net.minecraft.block.entity.BlockEntityTicker;
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 reborncore.api.IListInfoProvider;
import reborncore.api.IToolDrop;
@ -63,19 +65,19 @@ import java.util.List;
*/
public class CableBlockEntity extends BlockEntity
implements Tickable, IListInfoProvider, IToolDrop, EnergyStorage {
implements BlockEntityTicker<CableBlockEntity>, IListInfoProvider, IToolDrop, EnergyStorage {
private double energy = 0;
private TRContent.Cables cableType = null;
private ArrayList<EnergySide> sendingFace = new ArrayList<>();
private BlockState cover = null;
public CableBlockEntity() {
super(TRBlockEntities.CABLE);
public CableBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.CABLE, pos, state);
}
public CableBlockEntity(TRContent.Cables type) {
super(TRBlockEntities.CABLE);
public CableBlockEntity(BlockPos pos, BlockState state, TRContent.Cables type) {
super(TRBlockEntities.CABLE, pos, state);
this.cableType = type;
}
@ -134,8 +136,8 @@ public class CableBlockEntity extends BlockEntity
}
@Override
public void readNbt(BlockState blockState, NbtCompound compound) {
super.readNbt(blockState, compound);
public void readNbt(NbtCompound compound) {
super.readNbt(compound);
if (compound.contains("energy")) {
energy = compound.getDouble("energy");
}
@ -158,8 +160,11 @@ public class CableBlockEntity extends BlockEntity
// Tickable
@Override
public void tick() {
if (world == null || world.isClient) {
public void tick(World world, BlockPos pos, BlockState state, CableBlockEntity blockEntity2) {
if (world == null) {
return;
}
if (world.isClient) {
return;
}
@ -174,12 +179,7 @@ public class CableBlockEntity extends BlockEntity
for (Direction face : Direction.values()) {
BlockEntity blockEntity = world.getBlockEntity(pos.offset(face));
if (blockEntity == null) {
continue;
}
if (!Energy.valid(blockEntity)) {
if (blockEntity == null || !Energy.valid(blockEntity)) {
continue;
}

View file

@ -28,15 +28,18 @@ import com.google.common.collect.ImmutableSet;
import com.google.gson.JsonObject;
import net.fabricmc.loader.launch.common.FabricLauncherBase;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.text.WordUtils;
import org.jetbrains.annotations.Nullable;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BlockEntityScreenHandlerBuilder;
import reborncore.client.screen.builder.BuiltScreenHandler;
@ -48,13 +51,12 @@ import reborncore.common.util.serialization.SerializationUtil;
import techreborn.blockentity.machine.GenericMachineBlockEntity;
import techreborn.init.ModRecipes;
import org.jetbrains.annotations.Nullable;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
import java.util.function.BiFunction;
public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.DataDrivenBlockEntity> implements Supplier<BlockEntity> {
public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.DataDrivenBlockEntity> implements BiFunction<BlockPos, BlockState, BlockEntity> {
private final Identifier identifier;
private final Block block;
@ -89,12 +91,12 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
@Nullable
@Override
public DataDrivenBlockEntity instantiate() {
return new DataDrivenBlockEntity(this);
public DataDrivenBlockEntity instantiate(BlockPos pos, BlockState state) {
return new DataDrivenBlockEntity(this, pos, state);
}
public BuiltScreenHandler createScreenHandler(DataDrivenBlockEntity blockEntity, int syncID, PlayerEntity player) {
BlockEntityScreenHandlerBuilder builder = new ScreenHandlerBuilder(identifier.getPath()).player(player.inventory)
BlockEntityScreenHandlerBuilder builder = new ScreenHandlerBuilder(identifier.getPath()).player(player.getInventory())
.inventory().hotbar().addInventory().blockEntity(blockEntity);
slots.forEach(dataDrivenSlot -> dataDrivenSlot.add(builder));
@ -106,16 +108,16 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
//Used by the GenericMachineBlock
@Override
public BlockEntity get() {
return instantiate();
public BlockEntity apply(BlockPos pos, BlockState state) {
return instantiate(pos, state);
}
public static class DataDrivenBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
private final DataDrivenBEProvider provider;
private DataDrivenBlockEntity(DataDrivenBEProvider provider) {
super(provider, provider.getSimpleName(), provider.maxInput, provider.energy, provider.block, provider.getEnergySlot());
private DataDrivenBlockEntity(DataDrivenBEProvider provider, BlockPos pos, BlockState state) {
super(provider, pos, state, provider.getSimpleName(), provider.maxInput, provider.energy, provider.block, provider.getEnergySlot());
this.provider = provider;
RebornRecipeType<?> recipeType = ModRecipes.byName(provider.identifier);

View file

@ -28,10 +28,13 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.Nullable;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.container.ItemFluidInfo;
@ -62,8 +65,8 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
*/
double pendingWithdraw = 0.0;
public BaseFluidGeneratorBlockEntity(BlockEntityType<?> blockEntityType, EFluidGenerator type, String blockEntityName, FluidValue tankCapacity, int euTick) {
super(blockEntityType);
public BaseFluidGeneratorBlockEntity(BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state, EFluidGenerator type, String blockEntityName, FluidValue tankCapacity, int euTick) {
super(blockEntityType, pos, state);
recipes = GeneratorRecipeHelper.getFluidRecipesForGenerator(type);
Validate.notNull(recipes, "null recipe list for " + type.getRecipeID());
tank = new Tank(blockEntityName, tankCapacity, this);
@ -74,8 +77,8 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
@SuppressWarnings("deprecation")
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
return;
@ -167,8 +170,8 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
}
@Override
public void readNbt(BlockState blockState, NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
public void readNbt(NbtCompound tagCompound) {
super.readNbt(tagCompound);
tank.read(tagCompound);
}

View file

@ -25,15 +25,17 @@
package techreborn.blockentity.generator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Heightmap;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import team.reborn.energy.EnergySide;
@ -46,13 +48,13 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
private int onStatusHoldTicks = -1;
public LightningRodBlockEntity() {
super(TRBlockEntities.LIGHTNING_ROD);
public LightningRodBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.LIGHTNING_ROD, pos, state);
}
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null){
return;

View file

@ -24,8 +24,10 @@
package techreborn.blockentity.generator;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -37,8 +39,8 @@ import techreborn.init.TRContent;
public class PlasmaGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements BuiltScreenHandlerProvider {
public PlasmaGeneratorBlockEntity() {
super(TRBlockEntities.PLASMA_GENERATOR, EFluidGenerator.PLASMA, "PlasmaGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.plasmaGeneratorEnergyPerTick);
public PlasmaGeneratorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.PLASMA_GENERATOR, pos, state, EFluidGenerator.PLASMA, "PlasmaGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.plasmaGeneratorEnergyPerTick);
}
@Override
@ -58,7 +60,7 @@ public class PlasmaGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity im
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("plasmagenerator").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("plasmagenerator").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)

View file

@ -33,10 +33,13 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
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.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.powerSystem.PowerSystem;
@ -65,12 +68,12 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
private SolarPanels panel;
public SolarPanelBlockEntity() {
super(TRBlockEntities.SOLAR_PANEL);
public SolarPanelBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.SOLAR_PANEL, pos, state);
}
public SolarPanelBlockEntity(SolarPanels panel) {
super(TRBlockEntities.SOLAR_PANEL);
public SolarPanelBlockEntity(BlockPos pos, BlockState state, SolarPanels panel) {
super(TRBlockEntities.SOLAR_PANEL, pos, state);
this.panel = panel;
}
@ -147,8 +150,8 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
// Overrides
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
return;
@ -264,13 +267,13 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
}
@Override
public void readNbt(BlockState blockState, NbtCompound tag) {
public void readNbt(NbtCompound tag) {
if (world == null) {
// We are in BlockEntity.create method during chunk load.
this.checkOverfill = false;
}
updatePanel();
super.readNbt(blockState, tag);
super.readNbt(tag);
}
// MachineBaseBlockEntity
@ -288,7 +291,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("solar_panel").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("solar_panel").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).syncEnergyValue()
.sync(this::getSunState, this::setSunState)
.addInventory().create(this, syncID);

View file

@ -24,8 +24,10 @@
package techreborn.blockentity.generator.advanced;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -38,8 +40,8 @@ import techreborn.init.TRContent;
public class DieselGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements BuiltScreenHandlerProvider {
public DieselGeneratorBlockEntity() {
super(TRBlockEntities.DIESEL_GENERATOR, EFluidGenerator.DIESEL, "DieselGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.dieselGeneratorEnergyPerTick);
public DieselGeneratorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.DIESEL_GENERATOR, pos, state, EFluidGenerator.DIESEL, "DieselGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.dieselGeneratorEnergyPerTick);
}
@Override
@ -59,7 +61,7 @@ public class DieselGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity im
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("dieselgenerator").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("dieselgenerator").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)

View file

@ -24,12 +24,15 @@
package techreborn.blockentity.generator.advanced;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.RebornInventory;
@ -44,8 +47,8 @@ public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
public RebornInventory<DragonEggSyphonBlockEntity> inventory = new RebornInventory<>(3, "DragonEggSyphonBlockEntity", 64, this);
private long lastOutput = 0;
public DragonEggSyphonBlockEntity() {
super(TRBlockEntities.DRAGON_EGG_SYPHON);
public DragonEggSyphonBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.DRAGON_EGG_SYPHON, pos, state);
}
private boolean tryAddingEnergy(int amount) {
@ -59,8 +62,8 @@ public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
// PowerAcceptorBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
return;

View file

@ -24,8 +24,10 @@
package techreborn.blockentity.generator.advanced;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -38,8 +40,8 @@ import techreborn.init.TRContent;
public class GasTurbineBlockEntity extends BaseFluidGeneratorBlockEntity implements BuiltScreenHandlerProvider {
public GasTurbineBlockEntity() {
super(TRBlockEntities.GAS_TURBINE, EFluidGenerator.GAS, "GasTurbineBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.gasTurbineEnergyPerTick);
public GasTurbineBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.GAS_TURBINE, pos, state, EFluidGenerator.GAS, "GasTurbineBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.gasTurbineEnergyPerTick);
}
@Override
@ -59,7 +61,7 @@ public class GasTurbineBlockEntity extends BaseFluidGeneratorBlockEntity impleme
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("gasturbine").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("gasturbine").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)

View file

@ -24,8 +24,10 @@
package techreborn.blockentity.generator.advanced;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -38,8 +40,8 @@ import techreborn.init.TRContent;
public class SemiFluidGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements BuiltScreenHandlerProvider {
public SemiFluidGeneratorBlockEntity() {
super(TRBlockEntities.SEMI_FLUID_GENERATOR, EFluidGenerator.SEMIFLUID, "SemiFluidGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.semiFluidGeneratorEnergyPerTick);
public SemiFluidGeneratorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.SEMI_FLUID_GENERATOR, pos, state, EFluidGenerator.SEMIFLUID, "SemiFluidGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.semiFluidGeneratorEnergyPerTick);
}
@Override
@ -59,7 +61,7 @@ public class SemiFluidGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("semifluidgenerator").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("semifluidgenerator").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)

View file

@ -24,8 +24,10 @@
package techreborn.blockentity.generator.advanced;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -38,8 +40,8 @@ import techreborn.init.TRContent;
public class ThermalGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements BuiltScreenHandlerProvider {
public ThermalGeneratorBlockEntity() {
super(TRBlockEntities.THERMAL_GEN, EFluidGenerator.THERMAL, "ThermalGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.thermalGeneratorEnergyPerTick);
public ThermalGeneratorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.THERMAL_GEN, pos, state, EFluidGenerator.THERMAL, "ThermalGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.thermalGeneratorEnergyPerTick);
}
@Override
@ -59,7 +61,7 @@ public class ThermalGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity i
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("thermalgenerator").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("thermalgenerator").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)

View file

@ -31,11 +31,15 @@ import net.minecraft.item.BucketItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
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.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.RebornInventory;
@ -44,7 +48,6 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
@ -59,8 +62,8 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
public boolean lastTickBurning;
ItemStack burnItem;
public SolidFuelGeneratorBlockEntity() {
super(TRBlockEntities.SOLID_FUEL_GENEREATOR);
public SolidFuelGeneratorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.SOLID_FUEL_GENEREATOR, pos, state);
}
public static int getItemBurnTime(@NotNull ItemStack stack) {
@ -75,8 +78,8 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
}
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null){
return;
}
@ -180,7 +183,7 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("generator").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("generator").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).fuelSlot(0, 80, 54).energySlot(1, 8, 72).syncEnergyValue()
.sync(this::getBurnTime, this::setBurnTime)
.sync(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(this, syncID);

View file

@ -24,11 +24,15 @@
package techreborn.blockentity.generator.basic;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import team.reborn.energy.EnergySide;
@ -43,13 +47,13 @@ public class WaterMillBlockEntity extends PowerAcceptorBlockEntity implements IT
int waterblocks = 0;
public WaterMillBlockEntity() {
super(TRBlockEntities.WATER_MILL);
public WaterMillBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.WATER_MILL, pos, state);
}
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world.getTime() % 20 == 0) {
checkForWater();
}

View file

@ -24,9 +24,13 @@
package techreborn.blockentity.generator.basic;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import team.reborn.energy.EnergySide;
import techreborn.config.TechRebornConfig;
@ -42,13 +46,13 @@ public class WindMillBlockEntity extends PowerAcceptorBlockEntity implements ITo
public float bladeAngle;
public float spinSpeed;
public WindMillBlockEntity() {
super(TRBlockEntities.WIND_MILL);
public WindMillBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.WIND_MILL, pos, state);
}
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
return;

View file

@ -28,30 +28,31 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import team.reborn.energy.EnergySide;
import techreborn.blocks.lighting.LampBlock;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
public class LampBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop {
private static final int capacity = 33;
public LampBlockEntity() {
super(TRBlockEntities.LAMP);
public LampBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.LAMP, pos, state);
}
// PowerAcceptorBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient) {
return;
}
BlockState state = world.getBlockState(pos);
Block b = state.getBlock();
if (!(b instanceof LampBlock)) {
return;
@ -70,7 +71,7 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity implements IToolDr
@Override
protected boolean canAcceptEnergy(EnergySide side) {
return side == EnergySide.UNKNOWN || getFacing().getOpposite() == Direction.values()[side.ordinal()];
return side == EnergySide.UNKNOWN || getFacing().getOpposite() != Direction.values()[side.ordinal()];
}
@Override
@ -93,22 +94,9 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity implements IToolDr
return 32;
}
//MachineBaseBlockEntity
@Override
public Direction getFacing(){
if (world == null){
return Direction.NORTH;
}
return LampBlock.getFacing(world.getBlockState(pos));
}
// IToolDrop
@Override
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
// I know it is weird. But world is nullable
if (world == null) {
return new ItemStack(TRContent.Machine.LAMP_INCANDESCENT.block);
}
return new ItemStack(world.getBlockState(pos).getBlock());
}
}

View file

@ -25,12 +25,16 @@
package techreborn.blockentity.machine;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.RebornInventory;
@ -57,8 +61,8 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
* @param toolDrop Block Block to drop with wrench
* @param energySlot int Energy slot to use to charge machine from battery
*/
public GenericMachineBlockEntity(BlockEntityType<?> blockEntityType, String name, int maxInput, int maxEnergy, Block toolDrop, int energySlot) {
super(blockEntityType);
public GenericMachineBlockEntity(BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state, String name, int maxInput, int maxEnergy, Block toolDrop, int energySlot) {
super(blockEntityType, pos, state);
this.name = "BlockEntity" + name;
this.maxInput = maxInput;
this.maxEnergy = maxEnergy;
@ -82,8 +86,8 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
// PowerAcceptorBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient) {
return;
}

View file

@ -31,6 +31,8 @@ import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
import reborncore.common.blockentity.MachineBaseBlockEntity;
@ -50,8 +52,8 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
Block toolDrop;
boolean active = false;
public AbstractIronMachineBlockEntity(BlockEntityType<?> blockEntityTypeIn, int fuelSlot, Block toolDrop) {
super(blockEntityTypeIn);
public AbstractIronMachineBlockEntity(BlockEntityType<?> blockEntityTypeIn, BlockPos pos, BlockState state, int fuelSlot, Block toolDrop) {
super(blockEntityTypeIn, pos, state);
this.fuelSlot = fuelSlot;
// default value for vanilla smelting recipes is 200
this.totalCookingTime = (int) (200 / TechRebornConfig.cookingScale);
@ -132,8 +134,8 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
// MachineBaseBlockEntity
@Override
public void readNbt(BlockState blockState, NbtCompound compoundTag) {
super.readNbt(blockState, compoundTag);
public void readNbt(NbtCompound compoundTag) {
super.readNbt(compoundTag);
burnTime = compoundTag.getInt("BurnTime");
totalBurnTime = compoundTag.getInt("TotalBurnTime");
progress = compoundTag.getInt("Progress");
@ -149,8 +151,8 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
}
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world.isClient) {
return;
}

View file

@ -24,8 +24,10 @@
package techreborn.blockentity.machine.iron;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -44,8 +46,8 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
int input2 = 1;
int output = 2;
public IronAlloyFurnaceBlockEntity() {
super(TRBlockEntities.IRON_ALLOY_FURNACE, 3, TRContent.Machine.IRON_ALLOY_FURNACE.block);
public IronAlloyFurnaceBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.IRON_ALLOY_FURNACE, pos, state, 3, TRContent.Machine.IRON_ALLOY_FURNACE.block);
this.inventory = new RebornInventory<>(4, "IronAlloyFurnaceBlockEntity", 64, this);
}
@ -134,7 +136,7 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("alloyfurnace").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("alloyfurnace").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this)
.slot(0, 47, 17)
.slot(1, 65, 17)

View file

@ -34,6 +34,7 @@ import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.SmeltingRecipe;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -52,8 +53,8 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
private Recipe<?> lastRecipe = null;
public IronFurnaceBlockEntity() {
super(TRBlockEntities.IRON_FURNACE, 2, TRContent.Machine.IRON_FURNACE.block);
public IronFurnaceBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.IRON_FURNACE, pos, state, 2, TRContent.Machine.IRON_FURNACE.block);
this.inventory = new RebornInventory<>(3, "IronFurnaceBlockEntity", 64, this);
}
@ -143,8 +144,8 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
}
@Override
public void readNbt(BlockState blockState, NbtCompound compoundTag) {
super.readNbt(blockState, compoundTag);
public void readNbt(NbtCompound compoundTag) {
super.readNbt(compoundTag);
experience = compoundTag.getFloat("Experience");
}
@ -171,7 +172,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("ironfurnace").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("ironfurnace").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this)
.fuelSlot(2, 56, 53).slot(0, 56, 17).outputSlot(1, 116, 35)
.sync(this::getBurnTime, this::setBurnTime)

View file

@ -26,13 +26,16 @@ 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.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.util.Tickable;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.common.util.ChatUtils;
import techreborn.blocks.misc.BlockAlarm;
@ -42,11 +45,11 @@ import techreborn.init.TRContent;
import techreborn.utils.MessageIDs;
public class AlarmBlockEntity extends BlockEntity
implements Tickable, IToolDrop {
implements BlockEntityTicker<AlarmBlockEntity>, IToolDrop {
private int selectedSound = 1;
public AlarmBlockEntity() {
super(TRBlockEntities.ALARM);
public AlarmBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.ALARM, pos, state);
}
public void rightClick() {
@ -75,16 +78,16 @@ public class AlarmBlockEntity extends BlockEntity
}
@Override
public void readNbt(BlockState blockState, NbtCompound compound) {
public void readNbt(NbtCompound compound) {
if (compound != null && compound.contains("selectedSound")) {
selectedSound = compound.getInt("selectedSound");
}
super.readNbt(blockState, compound);
super.readNbt(compound);
}
// Tickable
@Override
public void tick() {
public void tick(World world, BlockPos pos, BlockState state, AlarmBlockEntity blockEntity) {
if (world == null || world.isClient()) return;
if (world.getTime() % 25 != 0) return;

View file

@ -24,13 +24,17 @@
package techreborn.blockentity.machine.misc;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
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.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.RebornInventory;
import team.reborn.energy.EnergySide;
@ -43,14 +47,14 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
public RebornInventory<ChargeOMatBlockEntity> inventory = new RebornInventory<>(6, "ChargeOMatBlockEntity", 64, this);
public ChargeOMatBlockEntity() {
super(TRBlockEntities.CHARGE_O_MAT);
public ChargeOMatBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.CHARGE_O_MAT, pos, state);
}
// PowerAcceptorBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient) {
return;
@ -102,7 +106,7 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
// BuiltScreenHandlerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("chargebench").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("chargebench").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).energySlot(0, 62, 25).energySlot(1, 98, 25).energySlot(2, 62, 45).energySlot(3, 98, 45)
.energySlot(4, 62, 65).energySlot(5, 98, 65).syncEnergyValue().addInventory().create(this, syncID);
}

View file

@ -29,31 +29,33 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.FluidDrainable;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.fluid.container.ItemFluidInfo;
import reborncore.common.util.Tank;
import techreborn.TechReborn;
import techreborn.init.TRBlockEntities;
import org.jetbrains.annotations.Nullable;
public class DrainBlockEntity extends MachineBaseBlockEntity {
protected Tank internalTank = new Tank("tank", FluidValue.BUCKET, this);
public DrainBlockEntity() {
this(TRBlockEntities.DRAIN);
public DrainBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.DRAIN, pos, state);
}
public DrainBlockEntity(BlockEntityType<?> blockEntityTypeIn) {
super(blockEntityTypeIn);
public DrainBlockEntity(BlockEntityType<?> blockEntityTypeIn, BlockPos pos, BlockState state) {
super(blockEntityTypeIn, pos, state);
}
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world.isClient) {
return;
}
@ -81,11 +83,12 @@ public class DrainBlockEntity extends MachineBaseBlockEntity {
Block aboveBlock = aboveBlockState.getBlock();
if (aboveBlock instanceof FluidDrainable) {
Fluid drainFluid = ((FluidDrainable) aboveBlock).tryDrainFluid(world, above, aboveBlockState);
if (drainFluid != Fluids.EMPTY) {
ItemStack fluidContainer = ((FluidDrainable) aboveBlock).tryDrainFluid(world, above, aboveBlockState);
if (fluidContainer.getItem() instanceof ItemFluidInfo) {
Fluid drainFluid = ((ItemFluidInfo) fluidContainer.getItem()).getFluid(fluidContainer);
internalTank.setFluidInstance(new FluidInstance(drainFluid, FluidValue.BUCKET));
} else {
TechReborn.LOGGER.debug("Could not get Fluid from ItemStack " + fluidContainer.getItem());
}
}
}

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.machine.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
@ -41,8 +43,8 @@ import techreborn.init.TRContent;
public class DistillationTowerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public DistillationTowerBlockEntity() {
super(TRBlockEntities.DISTILLATION_TOWER, "DistillationTower", TechRebornConfig.distillationTowerMaxInput, TechRebornConfig.distillationTowerMaxEnergy, TRContent.Machine.DISTILLATION_TOWER.block, 6);
public DistillationTowerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.DISTILLATION_TOWER, pos, state, "DistillationTower", TechRebornConfig.distillationTowerMaxInput, TechRebornConfig.distillationTowerMaxEnergy, TRContent.Machine.DISTILLATION_TOWER.block, 6);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2, 3, 4, 5};
this.inventory = new RebornInventory<>(7, "DistillationTowerBlockEntity", 64, this);
@ -61,7 +63,7 @@ public class DistillationTowerBlockEntity extends GenericMachineBlockEntity impl
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("Distillationtower").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("Distillationtower").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 35, 27).slot(1, 35, 47).outputSlot(2, 79, 37).outputSlot(3, 99, 37)
.outputSlot(4, 119, 37).outputSlot(5, 139, 37).energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue()
.addInventory().create(this, syncID);

View file

@ -26,12 +26,15 @@ package techreborn.blockentity.machine.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluids;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
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.blockentity.MultiblockWriter;
import reborncore.common.fluid.FluidValue;
import reborncore.common.recipes.RecipeCrafter;
@ -45,8 +48,6 @@ import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;
import org.jetbrains.annotations.Nullable;
/**
* @author drcrazy
*/
@ -56,8 +57,8 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
public Tank tank;
int ticksSinceLastChange;
public FluidReplicatorBlockEntity() {
super(TRBlockEntities.FLUID_REPLICATOR, "FluidReplicator", TechRebornConfig.fluidReplicatorMaxInput, TechRebornConfig.fluidReplicatorMaxEnergy, TRContent.Machine.FLUID_REPLICATOR.block, 3);
public FluidReplicatorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.FLUID_REPLICATOR, pos, state, "FluidReplicator", TechRebornConfig.fluidReplicatorMaxInput, TechRebornConfig.fluidReplicatorMaxEnergy, TRContent.Machine.FLUID_REPLICATOR.block, 3);
this.inventory = new RebornInventory<>(4, "FluidReplicatorBlockEntity", 64, this, getInventoryAccess());
this.crafter = new RecipeCrafter(ModRecipes.FLUID_REPLICATOR, this, 1, 0, this.inventory, new int[]{0}, null);
this.tank = new Tank("FluidReplicatorBlockEntity", FluidReplicatorBlockEntity.TANK_CAPACITY, this);
@ -72,7 +73,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
// TileGenericMachine
@Override
public void tick() {
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
if (world == null){
return;
}
@ -81,15 +82,11 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
if (!world.isClient && ticksSinceLastChange >= 10) {
if (!inventory.getStack(1).isEmpty()) {
FluidUtils.fillContainers(tank, inventory, 1, 2);
if (tank.isEmpty()){
// need to set to empty fluid due to #2352
tank.setFluid(Fluids.EMPTY);
}
}
ticksSinceLastChange = 0;
}
super.tick();
super.tick(world, pos, state, blockEntity);
}
@Override
@ -99,8 +96,8 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
// TilePowerAcceptor
@Override
public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
public void readNbt(final NbtCompound tagCompound) {
super.readNbt(tagCompound);
tank.read(tagCompound);
}
@ -130,7 +127,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return new ScreenHandlerBuilder("fluidreplicator").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("fluidreplicator").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).fluidSlot(1, 124, 35).filterSlot(0, 55, 45, stack -> stack.isItemEqualIgnoreDamage(TRContent.Parts.UU_MATTER.getStack()))
.outputSlot(2, 124, 55).energySlot(3, 8, 72).sync(tank).syncEnergyValue().syncCrafterValue().addInventory()
.create(this, syncID);

View file

@ -32,9 +32,11 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
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.blockentity.MultiblockWriter;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.ingredient.RebornIngredient;
@ -65,8 +67,8 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
boolean checkNBTRecipe = false;
long lastTick = -1;
public FusionControlComputerBlockEntity() {
super(TRBlockEntities.FUSION_CONTROL_COMPUTER, "FusionControlComputer", -1, -1, TRContent.Machine.FUSION_CONTROL_COMPUTER.block, -1);
public FusionControlComputerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.FUSION_CONTROL_COMPUTER, pos, state, "FusionControlComputer", -1, -1, TRContent.Machine.FUSION_CONTROL_COMPUTER.block, -1);
checkOverfill = false;
this.inventory = new RebornInventory<>(3, "FusionControlComputerBlockEntity", 64, this);
}
@ -249,8 +251,8 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
// PowerAcceptorBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient) {
return;
@ -352,8 +354,8 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
}
@Override
public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
public void readNbt(final NbtCompound tagCompound) {
super.readNbt(tagCompound);
this.craftingTickTime = tagCompound.getInt("craftingTickTime");
this.neededPower = tagCompound.getInt("neededPower");
this.hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting");
@ -399,7 +401,7 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
// BuiltScreenHandlerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("fusionreactor").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("fusionreactor").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).syncEnergyValue()
.sync(this::getCraftingTickTime, this::setCraftingTickTime)
.sync(this::getSize, this::setSize)

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.machine.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
@ -41,8 +43,8 @@ import techreborn.init.TRContent;
public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public ImplosionCompressorBlockEntity() {
super(TRBlockEntities.IMPLOSION_COMPRESSOR, "ImplosionCompressor", TechRebornConfig.implosionCompressorMaxInput, TechRebornConfig.implosionCompressorMaxEnergy, TRContent.Machine.IMPLOSION_COMPRESSOR.block, 4);
public ImplosionCompressorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.IMPLOSION_COMPRESSOR, pos, state, "ImplosionCompressor", TechRebornConfig.implosionCompressorMaxInput, TechRebornConfig.implosionCompressorMaxEnergy, TRContent.Machine.IMPLOSION_COMPRESSOR.block, 4);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2, 3};
this.inventory = new RebornInventory<>(5, "ImplosionCompressorBlockEntity", 64, this);
@ -60,7 +62,7 @@ public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity im
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("implosioncompressor").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("implosioncompressor").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 50, 27).slot(1, 50, 47).outputSlot(2, 92, 36).outputSlot(3, 110, 36)
.energySlot(4, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
}

View file

@ -54,8 +54,8 @@ public class IndustrialBlastFurnaceBlockEntity extends GenericMachineBlockEntity
private int cachedHeat;
public IndustrialBlastFurnaceBlockEntity() {
super(TRBlockEntities.INDUSTRIAL_BLAST_FURNACE, "IndustrialBlastFurnace", TechRebornConfig.industrialBlastFurnaceMaxInput, TechRebornConfig.industrialBlastFurnaceMaxEnergy, TRContent.Machine.INDUSTRIAL_BLAST_FURNACE.block, 4);
public IndustrialBlastFurnaceBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.INDUSTRIAL_BLAST_FURNACE, pos, state, "IndustrialBlastFurnace", TechRebornConfig.industrialBlastFurnaceMaxInput, TechRebornConfig.industrialBlastFurnaceMaxEnergy, TRContent.Machine.INDUSTRIAL_BLAST_FURNACE.block, 4);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2, 3};
this.inventory = new RebornInventory<>(5, "IndustrialBlastFurnaceBlockEntity", 64, this);
@ -134,7 +134,7 @@ public class IndustrialBlastFurnaceBlockEntity extends GenericMachineBlockEntity
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("blastfurnace").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("blastfurnace").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 50, 27).slot(1, 50, 47).outputSlot(2, 93, 37).outputSlot(3, 113, 37)
.energySlot(4, 8, 72).syncEnergyValue().syncCrafterValue()
.sync(this::getHeat, this::setHeat).addInventory().create(this, syncID);

View file

@ -29,10 +29,14 @@ 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;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
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.blockentity.MultiblockWriter;
import reborncore.common.fluid.FluidValue;
import reborncore.common.recipes.RecipeCrafter;
@ -45,16 +49,14 @@ import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;
import org.jetbrains.annotations.Nullable;
public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
public Tank tank;
int ticksSinceLastChange;
public IndustrialGrinderBlockEntity() {
super(TRBlockEntities.INDUSTRIAL_GRINDER, "IndustrialGrinder", TechRebornConfig.industrialGrinderMaxInput, TechRebornConfig.industrialGrinderMaxEnergy, TRContent.Machine.INDUSTRIAL_GRINDER.block, 7);
public IndustrialGrinderBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.INDUSTRIAL_GRINDER, pos, state, "IndustrialGrinder", TechRebornConfig.industrialGrinderMaxInput, TechRebornConfig.industrialGrinderMaxEnergy, TRContent.Machine.INDUSTRIAL_GRINDER.block, 7);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2, 3, 4, 5};
this.inventory = new RebornInventory<>(8, "IndustrialGrinderBlockEntity", 64, this);
@ -75,7 +77,7 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
// TilePowerAcceptor
@Override
public void tick() {
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
if (world == null){
return;
}
@ -89,12 +91,12 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
ticksSinceLastChange = 0;
}
super.tick();
super.tick(world, pos, state, blockEntity);
}
@Override
public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
public void readNbt(final NbtCompound tagCompound) {
super.readNbt(tagCompound);
tank.read(tagCompound);
}
@ -116,7 +118,7 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
// fluidSlot first to support automation and shift-click
return new ScreenHandlerBuilder("industrialgrinder").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("industrialgrinder").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).fluidSlot(1, 34, 35).slot(0, 84, 43).outputSlot(2, 126, 18).outputSlot(3, 126, 36)
.outputSlot(4, 126, 54).outputSlot(5, 126, 72).outputSlot(6, 34, 55).energySlot(7, 8, 72)
.sync(tank).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);

View file

@ -29,10 +29,14 @@ 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;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
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.blockentity.MultiblockWriter;
import reborncore.common.fluid.FluidValue;
import reborncore.common.recipes.RecipeCrafter;
@ -45,16 +49,14 @@ import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;
import org.jetbrains.annotations.Nullable;
public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
public Tank tank;
int ticksSinceLastChange;
public IndustrialSawmillBlockEntity() {
super(TRBlockEntities.INDUSTRIAL_SAWMILL, "IndustrialSawmill", TechRebornConfig.industrialSawmillMaxInput, TechRebornConfig.industrialSawmillMaxEnergy, TRContent.Machine.INDUSTRIAL_SAWMILL.block, 6);
public IndustrialSawmillBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.INDUSTRIAL_SAWMILL, pos, state, "IndustrialSawmill", TechRebornConfig.industrialSawmillMaxInput, TechRebornConfig.industrialSawmillMaxEnergy, TRContent.Machine.INDUSTRIAL_SAWMILL.block, 6);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2, 3, 4};
this.inventory = new RebornInventory<>(7, "SawmillBlockEntity", 64, this);
@ -75,7 +77,7 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
// TileGenericMachine
@Override
public void tick() {
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
if (world == null) {
return;
}
@ -89,14 +91,14 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
ticksSinceLastChange = 0;
}
super.tick();
super.tick(world, pos, state, blockEntity);
}
// TilePowerAcceptor
@Override
public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
public void readNbt(final NbtCompound tagCompound) {
super.readNbt(tagCompound);
tank.read(tagCompound);
}
@ -117,7 +119,7 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("industrialsawmill").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("industrialsawmill").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).fluidSlot(1, 34, 35).slot(0, 84, 43).outputSlot(2, 126, 25).outputSlot(3, 126, 43)
.outputSlot(4, 126, 61).outputSlot(5, 34, 55).energySlot(6, 8, 72).sync(tank).syncEnergyValue().syncCrafterValue()
.addInventory().create(this, syncID);

View file

@ -26,6 +26,7 @@ package techreborn.blockentity.machine.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
@ -42,8 +43,8 @@ import techreborn.init.TRContent;
public class VacuumFreezerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public VacuumFreezerBlockEntity() {
super(TRBlockEntities.VACUUM_FREEZER, "VacuumFreezer", TechRebornConfig.vacuumFreezerMaxInput, TechRebornConfig.vacuumFreezerMaxEnergy, TRContent.Machine.VACUUM_FREEZER.block, 2);
public VacuumFreezerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.VACUUM_FREEZER, pos, state, "VacuumFreezer", TechRebornConfig.vacuumFreezerMaxInput, TechRebornConfig.vacuumFreezerMaxEnergy, TRContent.Machine.VACUUM_FREEZER.block, 2);
final int[] inputs = new int[]{0};
final int[] outputs = new int[]{1};
this.inventory = new RebornInventory<>(3, "VacuumFreezerBlockEntity", 64, this);
@ -61,10 +62,10 @@ public class VacuumFreezerBlockEntity extends GenericMachineBlockEntity implemen
.fill(0, 2, 0, 3, 3, 3, advanced);
}
// IContainerProvider
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("vacuumfreezer").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("vacuumfreezer").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
.syncCrafterValue().addInventory().create(this, syncID);
}

View file

@ -24,6 +24,10 @@
package techreborn.blockentity.machine.multiblock.casing;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.multiblock.MultiblockControllerBase;
import reborncore.common.multiblock.rectangular.RectangularMultiblockBlockEntityBase;
import techreborn.init.TRBlockEntities;
@ -31,8 +35,8 @@ import techreborn.multiblocks.MultiBlockCasing;
public class MachineCasingBlockEntity extends RectangularMultiblockBlockEntityBase {
public MachineCasingBlockEntity() {
super(TRBlockEntities.MACHINE_CASINGS);
public MachineCasingBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.MACHINE_CASINGS, pos, state);
}
@Override
@ -86,7 +90,7 @@ public class MachineCasingBlockEntity extends RectangularMultiblockBlockEntityBa
}
@Override
public void tick() {
public void tick(World world, BlockPos pos, BlockState state, BlockEntity blockEntity) {
}
}

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -38,8 +40,8 @@ import techreborn.init.TRContent;
public class AlloySmelterBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public AlloySmelterBlockEntity() {
super(TRBlockEntities.ALLOY_SMELTER, "AlloySmelter", TechRebornConfig.alloySmelterMaxInput, TechRebornConfig.alloySmelterMaxEnergy, TRContent.Machine.ALLOY_SMELTER.block, 3);
public AlloySmelterBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.ALLOY_SMELTER, pos, state, "AlloySmelter", TechRebornConfig.alloySmelterMaxInput, TechRebornConfig.alloySmelterMaxEnergy, TRContent.Machine.ALLOY_SMELTER.block, 3);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2};
this.inventory = new RebornInventory<>(4, "AlloySmelterBlockEntity", 64, this);
@ -49,7 +51,7 @@ public class AlloySmelterBlockEntity extends GenericMachineBlockEntity implement
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("alloysmelter").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("alloysmelter").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this)
.slot(0, 34, 47)
.slot(1, 126, 47)

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -38,8 +40,8 @@ import techreborn.init.TRContent;
public class AssemblingMachineBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public AssemblingMachineBlockEntity() {
super(TRBlockEntities.ASSEMBLY_MACHINE, "AssemblingMachine", TechRebornConfig.assemblingMachineMaxInput, TechRebornConfig.assemblingMachineMaxEnergy, TRContent.Machine.ASSEMBLY_MACHINE.block, 3);
public AssemblingMachineBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.ASSEMBLY_MACHINE, pos, state, "AssemblingMachine", TechRebornConfig.assemblingMachineMaxInput, TechRebornConfig.assemblingMachineMaxEnergy, TRContent.Machine.ASSEMBLY_MACHINE.block, 3);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2};
this.inventory = new RebornInventory<>(4, "AssemblingMachineBlockEntity", 64, this);
@ -49,7 +51,7 @@ public class AssemblingMachineBlockEntity extends GenericMachineBlockEntity impl
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("assemblingmachine").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("assemblingmachine").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 55, 35).slot(1, 55, 55).outputSlot(2, 101, 45).energySlot(3, 8, 72)
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
}

View file

@ -27,7 +27,6 @@ package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.recipe.CraftingRecipe;
@ -36,13 +35,16 @@ import net.minecraft.recipe.RecipeType;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.collection.DefaultedList;
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 reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
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.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.recipes.ExtendedRecipeRemainder;
import reborncore.common.util.ItemUtils;
@ -69,7 +71,6 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
public RebornInventory<AutoCraftingTableBlockEntity> inventory = new RebornInventory<>(11, "AutoCraftingTableBlockEntity", 64, this);
private final int OUTPUT_SLOT = 9;
private final int EXTRA_OUTPUT_SLOT = 10;
public int progress;
public int maxProgress = 120;
public int euTick = 10;
@ -78,16 +79,10 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
CraftingInventory inventoryCrafting = null;
CraftingRecipe lastRecipe = null;
Item[] layoutInv = {
null, null, null,
null, null, null,
null, null, null,
};
public boolean locked = true;
public boolean locked = false;
public AutoCraftingTableBlockEntity() {
super(TRBlockEntities.AUTO_CRAFTING_TABLE);
public AutoCraftingTableBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.AUTO_CRAFTING_TABLE, pos, state);
}
@Nullable
@ -98,11 +93,6 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
if (lastRecipe != null && lastRecipe.matches(crafting, world)) return lastRecipe;
Item[] currentInvLayout = getCraftingLayout(crafting);
if(Arrays.equals(layoutInv, currentInvLayout)) return null;
layoutInv = currentInvLayout;
Optional<CraftingRecipe> testRecipe = world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, crafting, world);
if (testRecipe.isPresent()) {
lastRecipe = testRecipe.get();
@ -112,20 +102,6 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
return null;
}
private Item[] getCraftingLayout(CraftingInventory craftingInventory){
Item[] layout = {
null, null, null,
null, null, null,
null, null, null,
};
for (int i = 0; i < 9; i++) {
layout[i] = craftingInventory.getStack(i).getItem();
}
return layout;
}
private CraftingInventory getCraftingInventory() {
if (inventoryCrafting == null) {
inventoryCrafting = new CraftingInventory(new ScreenHandler(null, -1) {
@ -149,20 +125,11 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
CraftingInventory crafting = getCraftingInventory();
if (crafting.isEmpty()) return false;
// Don't allow recipe to change (Keep at least one of each slot stocked, assuming it's actually a recipe)
if(locked){
for(int i = 0; i < 9; i++){
if(crafting.getStack(i).getCount() == 1){
return false;
}
}
}
if (!recipe.matches(crafting, world)) return false;
if (!hasOutputSpace(recipe.getOutput(), OUTPUT_SLOT)) return false;
DefaultedList<ItemStack> remainingStacks = recipe.getRemainder(crafting);
DefaultedList<ItemStack> remainingStacks = world.getRecipeManager().getRemainingStacks(RecipeType.CRAFTING, crafting, world);
for (ItemStack stack : remainingStacks){
if (!stack.isEmpty() && !hasRoomForExtraItem(stack)) return false;
}
@ -350,8 +317,8 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
// TilePowerAcceptor
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient) {
return;
}
@ -411,11 +378,11 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
}
@Override
public void readNbt(BlockState blockState, NbtCompound tag) {
public void readNbt(NbtCompound tag) {
if (tag.contains("locked")) {
locked = tag.getBoolean("locked");
}
super.readNbt(blockState, tag);
super.readNbt(tag);
}
// MachineBaseBlockEntity
@ -450,7 +417,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
// BuiltScreenHandlerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return new ScreenHandlerBuilder("autocraftingtable").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("autocraftingtable").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this)
.slot(0, 28, 25).slot(1, 46, 25).slot(2, 64, 25)
.slot(3, 28, 43).slot(4, 46, 43).slot(5, 64, 43)

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -38,8 +40,8 @@ import techreborn.init.TRContent;
public class ChemicalReactorBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public ChemicalReactorBlockEntity() {
super(TRBlockEntities.CHEMICAL_REACTOR, "ChemicalReactor", TechRebornConfig.chemicalReactorMaxInput, TechRebornConfig.chemicalReactorMaxEnergy, TRContent.Machine.CHEMICAL_REACTOR.block, 3);
public ChemicalReactorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.CHEMICAL_REACTOR, pos, state, "ChemicalReactor", TechRebornConfig.chemicalReactorMaxInput, TechRebornConfig.chemicalReactorMaxEnergy, TRContent.Machine.CHEMICAL_REACTOR.block, 3);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2};
this.inventory = new RebornInventory<>(4, "ChemicalReactorBlockEntity", 64, this);
@ -49,7 +51,7 @@ public class ChemicalReactorBlockEntity extends GenericMachineBlockEntity implem
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("chemicalreactor").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("chemicalreactor").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).energySlot(3, 8, 72)
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
}

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -38,8 +40,8 @@ import techreborn.init.TRContent;
public class CompressorBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public CompressorBlockEntity() {
super(TRBlockEntities.COMPRESSOR, "Compressor", TechRebornConfig.compressorMaxInput, TechRebornConfig.compressorMaxEnergy, TRContent.Machine.COMPRESSOR.block, 2);
public CompressorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.COMPRESSOR, pos, state, "Compressor", TechRebornConfig.compressorMaxInput, TechRebornConfig.compressorMaxEnergy, TRContent.Machine.COMPRESSOR.block, 2);
final int[] inputs = new int[]{0};
final int[] outputs = new int[]{1};
this.inventory = new RebornInventory<>(3, "CompressorBlockEntity", 64, this);
@ -49,7 +51,7 @@ public class CompressorBlockEntity extends GenericMachineBlockEntity implements
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("compressor").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("compressor").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
.syncCrafterValue().addInventory().create(this, syncID);
}

View file

@ -25,15 +25,19 @@
package techreborn.blockentity.machine.tier1;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.SmeltingRecipe;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
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.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.recipes.RecipeCrafter;
@ -59,8 +63,8 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
// Energy cost per tick of cooking
final int EnergyPerTick = 1;
public ElectricFurnaceBlockEntity() {
super(TRBlockEntities.ELECTRIC_FURNACE);
public ElectricFurnaceBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.ELECTRIC_FURNACE, pos, state);
}
private void setInvDirty(boolean isDirty) {
@ -189,8 +193,8 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
// TilePowerAcceptor
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
charge(2);
if (world == null || world.isClient) {
@ -265,7 +269,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
// BuiltScreenHandlerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("electricfurnace").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("electricfurnace").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
.sync(this::getCookTime, this::setCookTime).sync(this::getCookTimeTotal, this::setCookTimeTotal).addInventory().create(this, syncID);
}

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -38,8 +40,8 @@ import techreborn.init.TRContent;
public class ExtractorBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public ExtractorBlockEntity() {
super(TRBlockEntities.EXTRACTOR, "Extractor", TechRebornConfig.extractorMaxInput, TechRebornConfig.extractorMaxEnergy, TRContent.Machine.EXTRACTOR.block, 2);
public ExtractorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.EXTRACTOR, pos, state, "Extractor", TechRebornConfig.extractorMaxInput, TechRebornConfig.extractorMaxEnergy, TRContent.Machine.EXTRACTOR.block, 2);
final int[] inputs = new int[]{0};
final int[] outputs = new int[]{1};
this.inventory = new RebornInventory<>(3, "ExtractorBlockEntity", 64, this);
@ -49,7 +51,7 @@ public class ExtractorBlockEntity extends GenericMachineBlockEntity implements B
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("extractor").player(player.inventory).inventory().hotbar().addInventory().blockEntity(this)
return new ScreenHandlerBuilder("extractor").player(player.getInventory()).inventory().hotbar().addInventory().blockEntity(this)
.slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue().syncCrafterValue()
.addInventory().create(this, syncID);
}

View file

@ -32,11 +32,13 @@ import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
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.blockentity.MultiblockWriter;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.ItemUtils;
@ -59,8 +61,8 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
private int ticksToNextMultiblockCheck = 0;
private boolean growthBoost = false;
public GreenhouseControllerBlockEntity() {
super(TRBlockEntities.GREENHOUSE_CONTROLLER);
public GreenhouseControllerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.GREENHOUSE_CONTROLLER, pos, state);
}
private void workCycle() {
@ -182,7 +184,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
// PowerAcceptorBlockEntity
@Override
public void tick() {
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
if (world == null){
return;
}
@ -190,7 +192,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
multiblockCenter = pos.offset(getFacing().getOpposite(), 5);
}
charge(6);
super.tick();
super.tick(world, pos, state, blockEntity);
if (world.isClient) {
return;
@ -272,7 +274,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
// BuiltScreenHandlerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return new ScreenHandlerBuilder("greenhousecontroller").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("greenhousecontroller").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this)
.outputSlot(0, 30, 22).outputSlot(1, 48, 22)
.outputSlot(2, 30, 40).outputSlot(3, 48, 40)

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -40,8 +42,8 @@ import techreborn.items.DynamicCellItem;
public class IndustrialElectrolyzerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public IndustrialElectrolyzerBlockEntity() {
super(TRBlockEntities.INDUSTRIAL_ELECTROLYZER, "IndustrialElectrolyzer", TechRebornConfig.industrialElectrolyzerMaxInput, TechRebornConfig.industrialElectrolyzerMaxEnergy, TRContent.Machine.INDUSTRIAL_ELECTROLYZER.block, 6);
public IndustrialElectrolyzerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.INDUSTRIAL_ELECTROLYZER, pos, state, "IndustrialElectrolyzer", TechRebornConfig.industrialElectrolyzerMaxInput, TechRebornConfig.industrialElectrolyzerMaxEnergy, TRContent.Machine.INDUSTRIAL_ELECTROLYZER.block, 6);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2, 3, 4, 5};
this.inventory = new RebornInventory<>(7, "IndustrialElectrolyzerBlockEntity", 64, this);
@ -51,7 +53,7 @@ public class IndustrialElectrolyzerBlockEntity extends GenericMachineBlockEntity
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("industrialelectrolyzer").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("industrialelectrolyzer").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this)
.filterSlot(1, 47, 72, stack -> ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
.filterSlot(0, 81, 72, stack -> !ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))

View file

@ -28,7 +28,10 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.WorldUtils;
import team.reborn.energy.EnergySide;
@ -44,8 +47,8 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
public String owenerUdid = "";
boolean redstone = false;
public PlayerDectectorBlockEntity() {
super(TRBlockEntities.PLAYER_DETECTOR);
public PlayerDectectorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.PLAYER_DETECTOR, pos, state);
}
public boolean isProvidingPower() {
@ -54,8 +57,8 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
// PowerAcceptorBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
return;
@ -117,8 +120,8 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
}
@Override
public void readNbt(BlockState blockState, NbtCompound tag) {
super.readNbt(blockState, tag);
public void readNbt(NbtCompound tag) {
super.readNbt(tag);
owenerUdid = tag.getString("ownerID");
}

View file

@ -24,9 +24,11 @@
package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import reborncore.api.blockentity.IUpgrade;
import reborncore.client.screen.BuiltScreenHandlerProvider;
@ -41,8 +43,8 @@ import techreborn.init.TRContent;
public class RecyclerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public RecyclerBlockEntity() {
super(TRBlockEntities.RECYCLER, "Recycler", TechRebornConfig.recyclerMaxInput, TechRebornConfig.recyclerMaxEnergy, TRContent.Machine.RECYCLER.block, 2);
public RecyclerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.RECYCLER, pos, state, "Recycler", TechRebornConfig.recyclerMaxInput, TechRebornConfig.recyclerMaxEnergy, TRContent.Machine.RECYCLER.block, 2);
final int[] inputs = new int[]{0};
final int[] outputs = new int[]{1};
this.inventory = new RebornInventory<>(3, "RecyclerBlockEntity", 64, this);
@ -60,9 +62,9 @@ public class RecyclerBlockEntity extends GenericMachineBlockEntity implements Bu
// BuiltScreenHandlerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return new ScreenHandlerBuilder("recycler").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("recycler").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 55, 45, RecyclerBlockEntity::canRecycle)
.outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
.syncCrafterValue().addInventory().create(this, syncID);
.addInventory().create(this, syncID);
}
}

View file

@ -55,13 +55,21 @@ public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
private int pouringTimer = 0;
public ResinBasinBlockEntity() {
super(TRBlockEntities.RESIN_BASIN);
public ResinBasinBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.RESIN_BASIN, pos, state);
/* TODO is this the right place? */
this.isFull = state.get(ResinBasinBlock.FULL);
if (state.get(ResinBasinBlock.POURING)) {
this.isPouring = true;
pouringTimer = TechRebornConfig.sapTimeTicks;
}
}
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient) return;
boolean shouldUpdateState = false;
@ -148,15 +156,8 @@ public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
}
@Override
public void readNbt(BlockState blockState, NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
this.isFull = blockState.get(ResinBasinBlock.FULL);
if (blockState.get(ResinBasinBlock.POURING)) {
this.isPouring = true;
pouringTimer = TechRebornConfig.sapTimeTicks;
}
public void readNbt(NbtCompound tagCompound) {
super.readNbt(tagCompound);
}
@Override

View file

@ -31,13 +31,16 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.recipe.Ingredient;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
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.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.ItemUtils;
@ -49,7 +52,6 @@ import techreborn.init.ModRecipes;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -73,8 +75,8 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
public boolean locked = false;
public int balanceSlot = 0;
public RollingMachineBlockEntity() {
super(TRBlockEntities.ROLLING_MACHINE);
public RollingMachineBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.ROLLING_MACHINE, pos, state);
outputSlot = 9;
}
@ -99,8 +101,8 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
}
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world.isClient) {
return;
}
@ -343,8 +345,8 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
}
@Override
public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
public void readNbt(final NbtCompound tagCompound) {
super.readNbt(tagCompound);
this.isRunning = tagCompound.getBoolean("isRunning");
this.tickTime = tagCompound.getInt("tickTime");
this.locked = tagCompound.getBoolean("locked");
@ -381,7 +383,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("rollingmachine").player(player.inventory)
return new ScreenHandlerBuilder("rollingmachine").player(player.getInventory())
.inventory().hotbar()
.addInventory().blockEntity(this)
.slot(0, 30, 22).slot(1, 48, 22).slot(2, 66, 22)

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -37,8 +39,8 @@ import techreborn.init.TRContent;
public class ScrapboxinatorBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public ScrapboxinatorBlockEntity() {
super(TRBlockEntities.SCRAPBOXINATOR, "Scrapboxinator", TechRebornConfig.scrapboxinatorMaxInput, TechRebornConfig.scrapboxinatorMaxEnergy, TRContent.Machine.SCRAPBOXINATOR.block, 2);
public ScrapboxinatorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.SCRAPBOXINATOR, pos, state, "Scrapboxinator", TechRebornConfig.scrapboxinatorMaxInput, TechRebornConfig.scrapboxinatorMaxEnergy, TRContent.Machine.SCRAPBOXINATOR.block, 2);
final int[] inputs = new int[]{0};
final int[] outputs = new int[]{1};
this.inventory = new RebornInventory<>(3, "ScrapboxinatorBlockEntity", 64, this);
@ -54,7 +56,7 @@ public class ScrapboxinatorBlockEntity extends GenericMachineBlockEntity impleme
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("scrapboxinator").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("scrapboxinator").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).filterSlot(0, 55, 45, stack -> stack.getItem() == TRContent.SCRAP_BOX).outputSlot(1, 101, 45)
.energySlot(2, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
}

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -38,8 +40,8 @@ import techreborn.init.TRContent;
public class SoildCanningMachineBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public SoildCanningMachineBlockEntity() {
super(TRBlockEntities.SOLID_CANNING_MACHINE, "SolidCanningMachine", TechRebornConfig.solidCanningMachineMaxInput, TechRebornConfig.solidCanningMachineMaxEnergy, TRContent.Machine.SOLID_CANNING_MACHINE.block, 3);
public SoildCanningMachineBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.SOLID_CANNING_MACHINE, pos, state, "SolidCanningMachine", TechRebornConfig.solidCanningMachineMaxInput, TechRebornConfig.solidCanningMachineMaxEnergy, TRContent.Machine.SOLID_CANNING_MACHINE.block, 3);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2};
this.inventory = new RebornInventory<>(4, "SolidCanningMachineBlockEntity", 64, this);
@ -49,7 +51,7 @@ public class SoildCanningMachineBlockEntity extends GenericMachineBlockEntity im
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("solidcanningmachine").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("solidcanningmachine").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this)
.slot(0, 34, 47)
.slot(1, 126, 47)

View file

@ -24,10 +24,14 @@
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;
@ -37,8 +41,8 @@ import techreborn.init.TRContent;
public class WireMillBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public WireMillBlockEntity() {
super(TRBlockEntities.WIRE_MILL, "WireMill", 32, 1000, TRContent.Machine.WIRE_MILL.block, 2);
public WireMillBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.WIRE_MILL, pos, state, "WireMill", 32, 1000, TRContent.Machine.WIRE_MILL.block, 2);
final int[] inputs = new int[]{0};
final int[] outputs = new int[]{1};
this.inventory = new RebornInventory<>(3, "WireMillBlockEntity", 64, this);
@ -48,7 +52,7 @@ public class WireMillBlockEntity extends GenericMachineBlockEntity implements Bu
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("wiremill").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("wiremill").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this)
.slot(0, 55, 45)
.outputSlot(1, 101, 45)

View file

@ -54,8 +54,8 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
private int radius;
private String ownerUdid;
public ChunkLoaderBlockEntity() {
super(TRBlockEntities.CHUNK_LOADER);
public ChunkLoaderBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.CHUNK_LOADER, pos, state);
this.radius = 1;
}
@ -77,6 +77,11 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
}
}
@Override
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
return TRContent.Machine.CHUNK_LOADER.getStack();
}
private void reload() {
unloadAll();
load();
@ -97,16 +102,7 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
}
}
private void unloadAll() {
ChunkLoaderManager manager = ChunkLoaderManager.get(world);
manager.unloadChunkLoader(world, getPos());
}
public ChunkPos getChunkPos() {
return new ChunkPos(getPos());
}
// MachineBaseBlockEntity
@Override
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
if (world.isClient) {
@ -123,20 +119,27 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
reload();
}
private void unloadAll() {
ChunkLoaderManager manager = ChunkLoaderManager.get(world);
manager.unloadChunkLoader(world, getPos());
}
public ChunkPos getChunkPos() {
return new ChunkPos(getPos());
}
@Override
public NbtCompound writeNbt(NbtCompound tagCompound) {
super.writeNbt(tagCompound);
tagCompound.putInt("radius", radius);
if (ownerUdid != null && !ownerUdid.isEmpty()){
tagCompound.putString("ownerUdid", ownerUdid);
}
tagCompound.putString("ownerUdid", ownerUdid);
inventory.write(tagCompound);
return tagCompound;
}
@Override
public void readNbt(BlockState blockState, NbtCompound nbttagcompound) {
super.readNbt(blockState, nbttagcompound);
public void readNbt(NbtCompound nbttagcompound) {
super.readNbt(nbttagcompound);
this.radius = nbttagcompound.getInt("radius");
this.ownerUdid = nbttagcompound.getString("ownerUdid");
if (!StringUtils.isBlank(ownerUdid)) {
@ -145,25 +148,11 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
inventory.read(nbttagcompound);
}
// IToolDrop
@Override
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
return TRContent.Machine.CHUNK_LOADER.getStack();
}
// InventoryProvider
@Override
public RebornInventory<ChunkLoaderBlockEntity> getInventory() {
return this.inventory;
}
// BuiltScreenHandlerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return new ScreenHandlerBuilder("chunkloader").player(player.inventory).inventory().hotbar().addInventory()
.blockEntity(this).sync(this::getRadius, this::setRadius).addInventory().create(this, syncID);
}
public int getRadius() {
return radius;
}
@ -172,5 +161,10 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
this.radius = radius;
}
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return new ScreenHandlerBuilder("chunkloader").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).sync(this::getRadius, this::setRadius).addInventory().create(this, syncID);
}
}

View file

@ -24,10 +24,12 @@
package techreborn.blockentity.machine.tier3;
import net.minecraft.block.BlockState;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import reborncore.api.IListInfoProvider;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
@ -46,8 +48,8 @@ import java.util.List;
public class IndustrialCentrifugeBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider, IListInfoProvider {
public IndustrialCentrifugeBlockEntity() {
super(TRBlockEntities.INDUSTRIAL_CENTRIFUGE, "IndustrialCentrifuge", TechRebornConfig.industrialCentrifugeMaxInput, TechRebornConfig.industrialCentrifugeMaxEnergy, TRContent.Machine.INDUSTRIAL_CENTRIFUGE.block, 6);
public IndustrialCentrifugeBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.INDUSTRIAL_CENTRIFUGE, pos, state, "IndustrialCentrifuge", TechRebornConfig.industrialCentrifugeMaxInput, TechRebornConfig.industrialCentrifugeMaxEnergy, TRContent.Machine.INDUSTRIAL_CENTRIFUGE.block, 6);
final int[] inputs = new int[]{0, 1};
final int[] outputs = new int[]{2, 3, 4, 5};
this.inventory = new RebornInventory<>(7, "IndustrialCentrifugeBlockEntity", 64, this);
@ -57,7 +59,7 @@ public class IndustrialCentrifugeBlockEntity extends GenericMachineBlockEntity i
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("centrifuge").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("centrifuge").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this)
.filterSlot(1, 40, 54, stack -> ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
.filterSlot(0, 40, 34, stack -> !ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))

View file

@ -24,13 +24,17 @@
package techreborn.blockentity.machine.tier3;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
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.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.ItemUtils;
import reborncore.common.util.RebornInventory;
@ -45,8 +49,8 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
public RebornInventory<MatterFabricatorBlockEntity> inventory = new RebornInventory<>(12, "MatterFabricatorBlockEntity", 64, this);
private int amplifier = 0;
public MatterFabricatorBlockEntity() {
super(TRBlockEntities.MATTER_FABRICATOR);
public MatterFabricatorBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.MATTER_FABRICATOR, pos, state);
}
private boolean spaceForOutput() {
@ -121,8 +125,8 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
// TilePowerAcceptor
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world.isClient) {
return;
@ -191,7 +195,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return new ScreenHandlerBuilder("matterfabricator").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("matterfabricator").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 30, 20).slot(1, 50, 20).slot(2, 70, 20).slot(3, 90, 20).slot(4, 110, 20)
.slot(5, 130, 20).outputSlot(6, 40, 66).outputSlot(7, 60, 66).outputSlot(8, 80, 66)
.outputSlot(9, 100, 66).outputSlot(10, 120, 66).energySlot(11, 8, 72).syncEnergyValue()

View file

@ -28,10 +28,13 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.blockentity.IUpgrade;
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.util.RebornInventory;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyTier;
@ -45,8 +48,8 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
private int OUTPUT = 64; // The current output
public int superconductors = 0;
public AdjustableSUBlockEntity() {
super(TRBlockEntities.ADJUSTABLE_SU, "ADJUSTABLE_SU", 4, TRContent.Machine.ADJUSTABLE_SU.block, EnergyTier.INSANE, TechRebornConfig.aesuMaxEnergy);
public AdjustableSUBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.ADJUSTABLE_SU, pos, state, "ADJUSTABLE_SU", 4, TRContent.Machine.ADJUSTABLE_SU.block, EnergyTier.INSANE, TechRebornConfig.aesuMaxEnergy);
}
public int getMaxConfigOutput() {
@ -86,8 +89,8 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
// EnergyStorageBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
return;
}
@ -144,8 +147,8 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
}
@Override
public void readNbt(BlockState blockState, NbtCompound nbttagcompound) {
super.readNbt(blockState, nbttagcompound);
public void readNbt(NbtCompound nbttagcompound) {
super.readNbt(nbttagcompound);
this.OUTPUT = nbttagcompound.getInt("output");
}
@ -158,7 +161,7 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return new ScreenHandlerBuilder("aesu").player(player.inventory).inventory().hotbar().armor()
return new ScreenHandlerBuilder("aesu").player(player.getInventory()).inventory().hotbar().armor()
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
.syncEnergyValue().sync(this::getCurrentOutput, this::setCurentOutput).addInventory().create(this, syncID);
}

View file

@ -25,12 +25,16 @@
package techreborn.blockentity.storage.energy;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.RebornInventory;
import team.reborn.energy.EnergySide;
@ -50,8 +54,8 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity implement
public int maxOutput;
public int maxStorage;
public EnergyStorageBlockEntity(BlockEntityType<?> blockEntityType, String name, int invSize, Block wrenchDrop, EnergyTier tier, int maxStorage) {
super(blockEntityType);
public EnergyStorageBlockEntity(BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state, String name, int invSize, Block wrenchDrop, EnergyTier tier, int maxStorage) {
super(blockEntityType, pos, state);
inventory = new RebornInventory<>(invSize, name + "BlockEntity", 64, this);
this.wrenchDrop = wrenchDrop;
this.tier = tier;
@ -65,8 +69,8 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity implement
// PowerAcceptorBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
return;
}

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.storage.energy;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -40,13 +42,13 @@ public class HighVoltageSUBlockEntity extends EnergyStorageBlockEntity implement
/**
* MFSU should store 4M Energy with 512 E/t I/O
*/
public HighVoltageSUBlockEntity() {
super(TRBlockEntities.HIGH_VOLTAGE_SU, "HIGH_VOLTAGE_SU", 2, TRContent.Machine.HIGH_VOLTAGE_SU.block, EnergyTier.HIGH, 4_000_000);
public HighVoltageSUBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.HIGH_VOLTAGE_SU, pos, state, "HIGH_VOLTAGE_SU", 2, TRContent.Machine.HIGH_VOLTAGE_SU.block, EnergyTier.HIGH, 4_000_000);
}
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("mfsu").player(player.inventory).inventory().hotbar().armor()
return new ScreenHandlerBuilder("mfsu").player(player.getInventory()).inventory().hotbar().armor()
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
.syncEnergyValue().addInventory().create(this, syncID);
}

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.storage.energy;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -37,13 +39,13 @@ import techreborn.init.TRContent;
*/
public class LowVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
public LowVoltageSUBlockEntity() {
super(TRBlockEntities.LOW_VOLTAGE_SU, "BatBox", 2, TRContent.Machine.LOW_VOLTAGE_SU.block, EnergyTier.LOW, 40_000);
public LowVoltageSUBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.LOW_VOLTAGE_SU, pos, state, "BatBox", 2, TRContent.Machine.LOW_VOLTAGE_SU.block, EnergyTier.LOW, 40_000);
}
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("batbox").player(player.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("batbox").player(player.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create(this, syncID);
}
}

View file

@ -24,7 +24,9 @@
package techreborn.blockentity.storage.energy;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
@ -40,13 +42,13 @@ public class MediumVoltageSUBlockEntity extends EnergyStorageBlockEntity impleme
/**
* MFE should store 300k energy with 128 E/t I/O
*/
public MediumVoltageSUBlockEntity() {
super(TRBlockEntities.MEDIUM_VOLTAGE_SU, "MEDIUM_VOLTAGE_SU", 2, TRContent.Machine.MEDIUM_VOLTAGE_SU.block, EnergyTier.MEDIUM, 300_000);
public MediumVoltageSUBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.MEDIUM_VOLTAGE_SU, pos, state, "MEDIUM_VOLTAGE_SU", 2, TRContent.Machine.MEDIUM_VOLTAGE_SU.block, EnergyTier.MEDIUM, 300_000);
}
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("mfe").player(player.inventory).inventory().hotbar().armor()
return new ScreenHandlerBuilder("mfe").player(player.getInventory()).inventory().hotbar().armor()
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
.syncEnergyValue().addInventory().create(this, syncID);
}

View file

@ -38,7 +38,6 @@ public class IDSUManager extends PersistentState {
private static final String KEY = "techreborn_idsu";
public IDSUManager() {
super(KEY);
}
@NotNull
@ -48,7 +47,7 @@ public class IDSUManager extends PersistentState {
public static IDSUManager get(World world) {
ServerWorld serverWorld = (ServerWorld) world;
return serverWorld.getPersistentStateManager().getOrCreate(IDSUManager::new, KEY);
return serverWorld.getPersistentStateManager().getOrCreate(IDSUManager::createFromTag, IDSUManager::new, KEY);
}
private final HashMap<String, IDSUPlayer> playerHashMap = new HashMap<>();
@ -58,8 +57,13 @@ public class IDSUManager extends PersistentState {
return playerHashMap.computeIfAbsent(uuid, s -> new IDSUPlayer());
}
@Override
public void fromNbt(NbtCompound tag) {
public static IDSUManager createFromTag(NbtCompound tag) {
IDSUManager idsuManager = new IDSUManager();
idsuManager.fromTag(tag);
return idsuManager;
}
public void fromTag(NbtCompound tag) {
for (String uuid : tag.getKeys()) {
playerHashMap.put(uuid, new IDSUPlayer(tag.getCompound(uuid)));
}

View file

@ -27,6 +27,7 @@ package techreborn.blockentity.storage.energy.idsu;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import org.apache.commons.lang3.StringUtils;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
@ -45,8 +46,8 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
//This is the energy value that is synced to the client
private double clientEnergy;
public InterdimensionalSUBlockEntity() {
super(TRBlockEntities.INTERDIMENSIONAL_SU, "IDSU", 2, TRContent.Machine.INTERDIMENSIONAL_SU.block, EnergyTier.INSANE, TechRebornConfig.idsuMaxEnergy);
public InterdimensionalSUBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.INTERDIMENSIONAL_SU, pos, state, "IDSU", 2, TRContent.Machine.INTERDIMENSIONAL_SU.block, EnergyTier.INSANE, TechRebornConfig.idsuMaxEnergy);
}
@Override
@ -96,8 +97,8 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
}
@Override
public void readNbt(BlockState blockState, NbtCompound nbttagcompound) {
super.readNbt(blockState, nbttagcompound);
public void readNbt(NbtCompound nbttagcompound) {
super.readNbt(nbttagcompound);
this.ownerUdid = nbttagcompound.getString("ownerUdid");
}
@ -113,7 +114,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("idsu").player(player.inventory).inventory().hotbar().armor()
return new ScreenHandlerBuilder("idsu").player(player.getInventory()).inventory().hotbar().armor()
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
.syncEnergyValue().addInventory().create(this, syncID);
}

View file

@ -24,6 +24,7 @@
package techreborn.blockentity.storage.energy.lesu;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
@ -40,8 +41,8 @@ public class LSUStorageBlockEntity extends MachineBaseBlockEntity
public LesuNetwork network;
public LSUStorageBlockEntity() {
super(TRBlockEntities.LSU_STORAGE);
public LSUStorageBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.LSU_STORAGE, pos, state);
}
public final void findAndJoinNetwork(World world, BlockPos pos) {
@ -86,8 +87,8 @@ public class LSUStorageBlockEntity extends MachineBaseBlockEntity
// TileMachineBase
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (network == null) {
findAndJoinNetwork(world, pos);
} else {

View file

@ -25,12 +25,16 @@
package techreborn.blockentity.storage.energy.lesu;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
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 team.reborn.energy.EnergyTier;
import techreborn.blockentity.storage.energy.EnergyStorageBlockEntity;
import techreborn.blocks.storage.energy.LapotronicSUBlock;
@ -45,8 +49,8 @@ public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements
private int connectedBlocks = 0;
private final ArrayList<LesuNetwork> countedNetworks = new ArrayList<>();
public LapotronicSUBlockEntity() {
super(TRBlockEntities.LAPOTRONIC_SU, "LESU", 2, TRContent.Machine.LAPOTRONIC_SU.block, EnergyTier.LOW, TechRebornConfig.lesuStoragePerBlock);
public LapotronicSUBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.LAPOTRONIC_SU, pos, state, "LESU", 2, TRContent.Machine.LAPOTRONIC_SU.block, EnergyTier.LOW, TechRebornConfig.lesuStoragePerBlock);
checkOverfill = false;
this.maxOutput = TechRebornConfig.lesuBaseOutput;
}
@ -95,8 +99,8 @@ public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements
// EnergyStorageBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world.isClient) {
return;
}
@ -125,7 +129,7 @@ public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements
// IContainerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("lesu").player(player.inventory).inventory().hotbar().armor().complete(8, 18)
return new ScreenHandlerBuilder("lesu").player(player.getInventory()).inventory().hotbar().armor().complete(8, 18)
.addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue()
.sync(this::getConnectedBlocksNum, this::setConnectedBlocksNum).addInventory().create(this, syncID);
}

View file

@ -32,6 +32,8 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.apache.commons.lang3.text.WordUtils;
import org.jetbrains.annotations.Nullable;
import reborncore.api.IListInfoProvider;
@ -43,7 +45,6 @@ import reborncore.client.screen.builder.ScreenHandlerBuilder;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.fluid.FluidUtil;
import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.Tank;
import techreborn.init.TRBlockEntities;
@ -54,24 +55,22 @@ import java.util.List;
public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements InventoryProvider, IToolDrop, IListInfoProvider, BuiltScreenHandlerProvider {
protected Tank tank;
private int serverMaxCapacity = -1;
protected RebornInventory<TankUnitBaseBlockEntity> inventory = new RebornInventory<>(2, "TankInventory", 64, this);
private TRContent.TankUnit type;
public TankUnitBaseBlockEntity() {
super(TRBlockEntities.TANK_UNIT);
public TankUnitBaseBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.TANK_UNIT, pos, state);
}
public TankUnitBaseBlockEntity(TRContent.TankUnit type) {
super(TRBlockEntities.TANK_UNIT);
public TankUnitBaseBlockEntity(BlockPos pos, BlockState state, TRContent.TankUnit type) {
super(TRBlockEntities.TANK_UNIT, pos, state);
configureEntity(type);
}
private void configureEntity(TRContent.TankUnit type) {
this.type = type;
this.tank = new Tank("TankStorage", serverMaxCapacity == -1 ? type.capacity : FluidValue.fromRaw(serverMaxCapacity), this);
this.tank = new Tank("TankStorage", type.capacity, this);
}
public ItemStack getDropWithNBT() {
@ -85,8 +84,8 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
// MachineBaseBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient()){
return;
@ -115,8 +114,8 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
}
@Override
public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
public void readNbt(final NbtCompound tagCompound) {
super.readNbt(tagCompound);
if (tagCompound.contains("unitType")) {
this.type = TRContent.TankUnit.valueOf(tagCompound.getString("unitType"));
configureEntity(type);
@ -175,24 +174,9 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
// BuiltScreenHandlerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("tank").player(player.inventory).inventory().hotbar()
return new ScreenHandlerBuilder("tank").player(player.getInventory()).inventory().hotbar()
.addInventory().blockEntity(this).fluidSlot(0, 100, 53).outputSlot(1, 140, 53)
.sync(tank)
.sync(this::getMaxCapacity, this::setMaxCapacity)
.addInventory().create(this, syncID);
}
// Sync between server/client if configs are mis-matched.
public int getMaxCapacity() {
return this.tank.getCapacity().getRawValue();
}
public void setMaxCapacity(int maxCapacity) {
FluidInstance instance = tank.getFluidInstance();
this.tank = new Tank("TankStorage", FluidValue.fromRaw(maxCapacity), this);
this.tank.setFluidInstance(instance);
this.serverMaxCapacity = maxCapacity;
.sync(tank).addInventory().create(this, syncID);
}
@Nullable

View file

@ -63,7 +63,6 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
protected RebornInventory<StorageUnitBaseBlockEntity> inventory;
private int maxCapacity;
private int serverCapacity = -1;
private ItemStack storeItemStack;
@ -73,22 +72,17 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
// the locked-in item, even if the stored amount drops to zero.
private ItemStack lockedItemStack = ItemStack.EMPTY;
public StorageUnitBaseBlockEntity() {
super(TRBlockEntities.STORAGE_UNIT);
public StorageUnitBaseBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.STORAGE_UNIT, pos, state);
}
public StorageUnitBaseBlockEntity(TRContent.StorageUnit type) {
super(TRBlockEntities.STORAGE_UNIT);
public StorageUnitBaseBlockEntity(BlockPos pos, BlockState state, TRContent.StorageUnit type) {
super(TRBlockEntities.STORAGE_UNIT, pos, state);
configureEntity(type);
}
private void configureEntity(TRContent.StorageUnit type) {
// Set capacity to local config unless overridden by server
if(serverCapacity == -1){
this.maxCapacity = type.capacity;
}
this.maxCapacity = type.capacity;
storeItemStack = ItemStack.EMPTY;
inventory = new RebornInventory<>(2, "ItemInventory", 64, this);
@ -242,10 +236,14 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
return storeItemStack.getCount() + inventory.getStack(OUTPUT_SLOT).getCount();
}
public int getMaxCapacity() {
return maxCapacity;
}
// MachineBaseBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient) {
return;
}
@ -285,8 +283,8 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
}
@Override
public void readNbt(BlockState blockState, NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
public void readNbt(NbtCompound tagCompound) {
super.readNbt(tagCompound);
if (tagCompound.contains("unitType")) {
this.type = TRContent.StorageUnit.valueOf(tagCompound.getString("unitType"));
@ -452,14 +450,13 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
// BuiltScreenHandlerProvider
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity playerEntity) {
return new ScreenHandlerBuilder("chest").player(playerEntity.inventory).inventory().hotbar().addInventory()
return new ScreenHandlerBuilder("chest").player(playerEntity.getInventory()).inventory().hotbar().addInventory()
.blockEntity(this)
.slot(INPUT_SLOT, 100, 53)
.outputSlot(OUTPUT_SLOT, 140, 53)
.sync(this::isLockedInt, this::setLockedInt)
.sync(this::getStoredStackNBT, this::setStoredStackFromNBT)
.sync(this::getStoredAmount, this::setStoredAmount)
.sync(this::getMaxCapacity, this::setMaxCapacity)
.addInventory().create(this, syncID);
// Note that inventory is synced, and it gets the stack from that
@ -482,16 +479,6 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
this.storedAmount = storedAmount;
}
// Sync between server/client if configs are mis-matched.
public int getMaxCapacity() {
return this.maxCapacity;
}
public void setMaxCapacity(int maxCapacity) {
this.maxCapacity = maxCapacity;
this.serverCapacity = maxCapacity;
}
public NbtCompound getStoredStackNBT() {
NbtCompound tag = new NbtCompound();
getStoredStack().writeNbt(tag);

View file

@ -24,6 +24,8 @@
package techreborn.blockentity.transformers;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import team.reborn.energy.EnergyTier;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
@ -33,8 +35,8 @@ import techreborn.init.TRContent;
*/
public class EVTransformerBlockEntity extends TransformerBlockEntity {
public EVTransformerBlockEntity() {
super(TRBlockEntities.EV_TRANSFORMER, "EVTransformer", TRContent.Machine.EV_TRANSFORMER.block, EnergyTier.INSANE);
public EVTransformerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.EV_TRANSFORMER, pos, state, "EVTransformer", TRContent.Machine.EV_TRANSFORMER.block, EnergyTier.INSANE);
}
}

View file

@ -24,6 +24,8 @@
package techreborn.blockentity.transformers;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import team.reborn.energy.EnergyTier;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
@ -33,8 +35,8 @@ import techreborn.init.TRContent;
*/
public class HVTransformerBlockEntity extends TransformerBlockEntity {
public HVTransformerBlockEntity() {
super(TRBlockEntities.HV_TRANSFORMER, "HVTransformer", TRContent.Machine.HV_TRANSFORMER.block, EnergyTier.EXTREME);
public HVTransformerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.HV_TRANSFORMER, pos, state, "HVTransformer", TRContent.Machine.HV_TRANSFORMER.block, EnergyTier.EXTREME);
}
}

View file

@ -24,6 +24,8 @@
package techreborn.blockentity.transformers;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import team.reborn.energy.EnergyTier;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
@ -33,8 +35,8 @@ import techreborn.init.TRContent;
*/
public class LVTransformerBlockEntity extends TransformerBlockEntity {
public LVTransformerBlockEntity() {
super(TRBlockEntities.LV_TRANSFORMER, "LVTransformer", TRContent.Machine.LV_TRANSFORMER.block, EnergyTier.MEDIUM);
public LVTransformerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.LV_TRANSFORMER, pos, state, "LVTransformer", TRContent.Machine.LV_TRANSFORMER.block, EnergyTier.MEDIUM);
}
}

View file

@ -24,6 +24,8 @@
package techreborn.blockentity.transformers;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import team.reborn.energy.EnergyTier;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
@ -33,7 +35,7 @@ import techreborn.init.TRContent;
*/
public class MVTransformerBlockEntity extends TransformerBlockEntity {
public MVTransformerBlockEntity() {
super(TRBlockEntities.MV_TRANSFORMER, "MVTransformer", TRContent.Machine.MV_TRANSFORMER.block, EnergyTier.HIGH);
public MVTransformerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.MV_TRANSFORMER, pos, state, "MVTransformer", TRContent.Machine.MV_TRANSFORMER.block, EnergyTier.HIGH);
}
}

View file

@ -25,12 +25,14 @@
package techreborn.blockentity.transformers;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import reborncore.api.IListInfoProvider;
import reborncore.api.IToolDrop;
@ -57,8 +59,8 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity implements
public int maxOutput;
public int maxStorage;
public TransformerBlockEntity(BlockEntityType<?> blockEntityType, String name, Block wrenchDrop, EnergyTier tier) {
super(blockEntityType);
public TransformerBlockEntity(BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state, String name, Block wrenchDrop, EnergyTier tier) {
super(blockEntityType, pos, state);
this.wrenchDrop = wrenchDrop;
this.inputTier = tier;
if (tier != EnergyTier.MICRO) {

View file

@ -25,12 +25,13 @@
package techreborn.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
import java.util.function.Supplier;
import java.util.function.BiFunction;
/**
* @author drcrazy
@ -38,32 +39,30 @@ import java.util.function.Supplier;
public class GenericMachineBlock extends BlockMachineBase {
private final IMachineGuiHandler gui;
Supplier<BlockEntity> blockEntityClass;
BiFunction<BlockPos, BlockState, BlockEntity> blockEntityClass;
public GenericMachineBlock(IMachineGuiHandler gui, Supplier<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, Supplier<BlockEntity> blockEntityClass) {
public GenericMachineBlock(Block.Settings settings, IMachineGuiHandler gui, BiFunction<BlockPos, BlockState, BlockEntity> blockEntityClass) {
super(settings);
this.blockEntityClass = blockEntityClass;
this.gui = gui;
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
if (blockEntityClass == null) {
return null;
}
return blockEntityClass.get();
return blockEntityClass.apply(pos, state);
}
@Override
public IMachineGuiHandler getGui() {
return gui;
}
}

View file

@ -26,6 +26,8 @@ package techreborn.blocks.cable;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -148,8 +150,13 @@ public class CableBlock extends BlockWithEntity implements Waterloggable {
@Nullable
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new CableBlockEntity(type);
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new CableBlockEntity(pos, state, type);
}
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return (world1, pos, state1, blockEntity) -> ((CableBlockEntity) blockEntity).tick(world1, pos, state1, (CableBlockEntity) blockEntity);
}
// Block

View file

@ -62,7 +62,7 @@ public final class CableShapeUtil {
double z = dir == Direction.NORTH ? 0 : dir == Direction.SOUTH ? 16D : size;
double y = dir == Direction.DOWN ? 0 : dir == Direction.UP ? 16D : size;
VoxelShape shape = Block.createCuboidShape(x, y, z, 16.0D - size, 16.0D - size, 16.0D - size);
VoxelShape shape = VoxelShapes.cuboidUnchecked(x, y, z, 16.0D - size, 16.0D - size, 16.0D - size);
connections.add(shape);
}
}

View file

@ -34,7 +34,6 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
@ -83,8 +82,8 @@ public class BlockFusionControlComputer extends BlockMachineBase {
}
@Override
public void onSteppedOn(final World worldIn, final BlockPos pos, final Entity entityIn) {
super.onSteppedOn(worldIn, pos, entityIn);
public void onSteppedOn(final World worldIn, final BlockPos pos, final BlockState state, final Entity entityIn) {
super.onSteppedOn(worldIn, pos, state, entityIn);
if (worldIn.getBlockEntity(pos) instanceof FusionControlComputerBlockEntity) {
if (((FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos)).craftingTickTime != 0
&& ((FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos)).isMultiblockValid()) {
@ -94,8 +93,8 @@ public class BlockFusionControlComputer extends BlockMachineBase {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new FusionControlComputerBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new FusionControlComputerBlockEntity(pos, state);
}
@Override

View file

@ -27,7 +27,6 @@ package techreborn.blocks.generator;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
@ -49,8 +48,8 @@ public class BlockSolarPanel extends BlockMachineBase {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new SolarPanelBlockEntity(panelType);
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new SolarPanelBlockEntity(pos, state, panelType);
}
@Override

View file

@ -32,14 +32,14 @@ import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import techreborn.blocks.GenericMachineBlock;
import java.util.function.Supplier;
import java.util.function.BiFunction;
/**
* An extension of {@link GenericMachineBlock} that provides utilities
* for generators, like comparator output based on energy.
*/
public class GenericGeneratorBlock extends GenericMachineBlock {
public GenericGeneratorBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
public GenericGeneratorBlock(IMachineGuiHandler gui, BiFunction<BlockPos, BlockState, BlockEntity> blockEntityClass) {
super(gui, blockEntityClass);
}

View file

@ -109,8 +109,8 @@ public class LampBlock extends BaseBlockEntityProvider {
// BaseTileBlock
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new LampBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new LampBlockEntity(pos, state);
}
// Block

View file

@ -65,8 +65,8 @@ public class PlayerDetectorBlock extends BlockMachineBase {
// BlockMachineBase
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new PlayerDectectorBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new PlayerDectectorBlockEntity(pos, state);
}
@Override

View file

@ -46,16 +46,16 @@ import reborncore.common.util.WorldUtils;
import techreborn.init.TRContent;
import java.util.UUID;
import java.util.function.Supplier;
import java.util.function.BiFunction;
public class ResinBasinBlock extends BaseBlockEntityProvider {
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
public static final BooleanProperty POURING = BooleanProperty.of("pouring");
public static final BooleanProperty FULL = BooleanProperty.of("full");
Supplier<BlockEntity> blockEntityClass;
BiFunction<BlockPos, BlockState, BlockEntity> blockEntityClass;
public ResinBasinBlock(Supplier<BlockEntity> blockEntityClass) {
public ResinBasinBlock(BiFunction<BlockPos, BlockState, BlockEntity> blockEntityClass) {
super(Block.Settings.of(Material.WOOD).strength(2F, 2F));
this.blockEntityClass = blockEntityClass;
@ -99,11 +99,11 @@ public class ResinBasinBlock extends BaseBlockEntityProvider {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
if (blockEntityClass == null) {
return null;
}
return blockEntityClass.get();
return blockEntityClass.apply(pos, state);
}
@Override

View file

@ -100,8 +100,8 @@ public class BlockAlarm extends BaseBlockEntityProvider {
// BaseTileBlock
@Nullable
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new AlarmBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new AlarmBlockEntity(pos, state);
}
// Block

View file

@ -26,6 +26,7 @@ package techreborn.blocks.misc;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundCategory;
@ -35,6 +36,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.api.ToolManager;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
@ -71,4 +73,10 @@ public class BlockComputerCube extends BlockMachineBase {
}
return ActionResult.PASS;
}
@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return null;
}
}

View file

@ -30,7 +30,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import reborncore.common.multiblock.BlockMultiblockBase;
import techreborn.blockentity.machine.multiblock.casing.MachineCasingBlockEntity;
@ -53,8 +53,8 @@ public class BlockMachineCasing extends BlockMultiblockBase {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new MachineCasingBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new MachineCasingBlockEntity(pos, state);
}
}

View file

@ -38,7 +38,6 @@ import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.tag.BlockTags;
import net.minecraft.tag.Tag;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
@ -88,10 +87,10 @@ public class BlockRubberLog extends PillarBlock {
}
}
@Override
/* FIXME @Override
public boolean isIn(Tag<Block> tagIn) {
return tagIn == BlockTags.LOGS;
}
}*/
@SuppressWarnings("deprecation")
@Override
@ -148,7 +147,7 @@ public class BlockRubberLog extends PillarBlock {
} else {
stack.damage(1, playerIn, player -> player.sendToolBreakStatus(hand));
}
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
if (!playerIn.getInventory().insertStack(TRContent.Parts.SAP.getStack())) {
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));
}
if (playerIn instanceof ServerPlayerEntity) {

View file

@ -24,8 +24,9 @@
package techreborn.blocks.storage.energy;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.client.GuiType;
@ -36,8 +37,8 @@ public class AdjustableSUBlock extends EnergyStorageBlock {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new AdjustableSUBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new AdjustableSUBlockEntity(pos, state);
}
}

View file

@ -80,9 +80,9 @@ public abstract class EnergyStorageBlock extends BaseBlockEntityProvider {
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
super.onPlaced(worldIn, pos, state, placer, stack);
Direction facing = placer.getHorizontalFacing().getOpposite();
if (placer.pitch < -50) {
if (placer.getPitch() < -50) {
facing = Direction.DOWN;
} else if (placer.pitch > 50) {
} else if (placer.getPitch() > 50) {
facing = Direction.UP;
}
setFacing(facing, worldIn, pos);

View file

@ -24,8 +24,9 @@
package techreborn.blocks.storage.energy;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import techreborn.blockentity.storage.energy.HighVoltageSUBlockEntity;
import techreborn.client.GuiType;
@ -39,8 +40,8 @@ public class HighVoltageSUBlock extends EnergyStorageBlock {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new HighVoltageSUBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new HighVoltageSUBlockEntity(pos, state);
}
}

View file

@ -30,7 +30,6 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import techreborn.blockentity.storage.energy.idsu.InterdimensionalSUBlockEntity;
import techreborn.client.GuiType;
@ -42,8 +41,8 @@ public class InterdimensionalSUBlock extends EnergyStorageBlock {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new InterdimensionalSUBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new InterdimensionalSUBlockEntity(pos, state);
}
@Override

View file

@ -35,7 +35,6 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import reborncore.api.ToolManager;
import reborncore.common.BaseBlockEntityProvider;
@ -69,8 +68,8 @@ public class LSUStorageBlock extends BaseBlockEntityProvider {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new LSUStorageBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new LSUStorageBlockEntity(pos, state);
}
@Override

View file

@ -24,8 +24,9 @@
package techreborn.blocks.storage.energy;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import techreborn.blockentity.storage.energy.lesu.LapotronicSUBlockEntity;
import techreborn.client.GuiType;
@ -36,8 +37,8 @@ public class LapotronicSUBlock extends EnergyStorageBlock {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new LapotronicSUBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new LapotronicSUBlockEntity(pos, state);
}
}

View file

@ -24,8 +24,9 @@
package techreborn.blocks.storage.energy;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import techreborn.blockentity.storage.energy.LowVoltageSUBlockEntity;
import techreborn.client.GuiType;
@ -39,7 +40,7 @@ public class LowVoltageSUBlock extends EnergyStorageBlock {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new LowVoltageSUBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new LowVoltageSUBlockEntity(pos, state);
}
}

View file

@ -24,8 +24,9 @@
package techreborn.blocks.storage.energy;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import techreborn.blockentity.storage.energy.MediumVoltageSUBlockEntity;
import techreborn.client.GuiType;
@ -39,8 +40,8 @@ public class MediumVoltageSUBlock extends EnergyStorageBlock {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new MediumVoltageSUBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new MediumVoltageSUBlockEntity(pos, state);
}
}

View file

@ -35,7 +35,6 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
@ -59,8 +58,8 @@ public class TankUnitBlock extends BlockMachineBase {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new TankUnitBaseBlockEntity(unitType);
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new TankUnitBaseBlockEntity(pos, state, unitType);
}
@Override
@ -114,7 +113,7 @@ public class TankUnitBlock extends BlockMachineBase {
selectedStack.increment(1);
didInsert = true;
}else {
didInsert = playerIn.inventory.insertStack(item);
didInsert = playerIn.getInventory().insertStack(item);
}

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;
@ -36,7 +35,6 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
@ -51,13 +49,13 @@ public class StorageUnitBlock extends BlockMachineBase {
public final TRContent.StorageUnit unitType;
public StorageUnitBlock(TRContent.StorageUnit unitType) {
super((Settings.of(unitType.name.equals("crude") ? Material.WOOD : Material.METAL).strength(2.0F, 2.0F)));
super();
this.unitType = unitType;
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new StorageUnitBaseBlockEntity(unitType);
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new StorageUnitBaseBlockEntity(pos, state, unitType);
}
@Override
@ -74,10 +72,10 @@ public class StorageUnitBlock extends BlockMachineBase {
(!storageEntity.isLocked() && storageEntity.isEmpty() && (!(itemInHand instanceof ToolItem))))) {
// Add item which is the same type (in users inventory) into storage
for (int i = 0; i < playerIn.inventory.size() && !storageEntity.isFull(); i++) {
ItemStack curStack = playerIn.inventory.getStack(i);
for (int i = 0; i < playerIn.getInventory().size() && !storageEntity.isFull(); i++) {
ItemStack curStack = playerIn.getInventory().getStack(i);
if (curStack.getItem() == itemInHand) {
playerIn.inventory.setStack(i, storageEntity.processInput(curStack));
playerIn.getInventory().setStack(i, storageEntity.processInput(curStack));
}
}

View file

@ -24,8 +24,9 @@
package techreborn.blocks.transformers;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import techreborn.blockentity.transformers.EVTransformerBlockEntity;
/**
@ -38,8 +39,8 @@ public class BlockEVTransformer extends BlockTransformer {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new EVTransformerBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new EVTransformerBlockEntity(pos, state);
}
}

View file

@ -24,8 +24,9 @@
package techreborn.blocks.transformers;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import techreborn.blockentity.transformers.HVTransformerBlockEntity;
/**
@ -38,8 +39,8 @@ public class BlockHVTransformer extends BlockTransformer {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new HVTransformerBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new HVTransformerBlockEntity(pos, state);
}
}

View file

@ -24,8 +24,9 @@
package techreborn.blocks.transformers;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import techreborn.blockentity.transformers.LVTransformerBlockEntity;
/**
@ -38,7 +39,7 @@ public class BlockLVTransformer extends BlockTransformer {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new LVTransformerBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new LVTransformerBlockEntity(pos, state);
}
}

View file

@ -24,8 +24,9 @@
package techreborn.blocks.transformers;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import net.minecraft.util.math.BlockPos;
import techreborn.blockentity.transformers.MVTransformerBlockEntity;
/**
@ -38,8 +39,8 @@ public class BlockMVTransformer extends BlockTransformer {
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new MVTransformerBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new MVTransformerBlockEntity(pos, state);
}
}

View file

@ -75,9 +75,9 @@ public abstract class BlockTransformer extends BaseBlockEntityProvider {
ItemStack stack) {
super.onPlaced(worldIn, pos, state, placer, stack);
Direction facing = placer.getHorizontalFacing().getOpposite();
if (placer.pitch < -50) {
if (placer.getPitch() < -50) {
facing = Direction.DOWN;
} else if (placer.pitch > 50) {
} else if (placer.getPitch() > 50) {
facing = Direction.UP;
}
setFacing(facing, worldIn, pos);

View file

@ -50,10 +50,10 @@ public class GuiAESU extends GuiBase<BuiltScreenHandler> {
@Override
public void init() {
super.init();
addButton(new GuiButtonUpDown(x + 121, y + 79, this, b -> onClick(256), UpDownButtonType.FASTFORWARD));
addButton(new GuiButtonUpDown(x + 121 + 12, y + 79, this, b -> onClick(64), UpDownButtonType.FORWARD));
addButton(new GuiButtonUpDown(x + 121 + 24, y + 79, this, b -> onClick(-64), UpDownButtonType.REWIND));
addButton(new GuiButtonUpDown(x + 121 + 36, y + 79, this, b -> onClick(-256), UpDownButtonType.FASTREWIND));
addDrawableChild(new GuiButtonUpDown(x + 121, y + 79, this, b -> onClick(256), UpDownButtonType.FASTFORWARD));
addDrawableChild(new GuiButtonUpDown(x + 121 + 12, y + 79, this, b -> onClick(64), UpDownButtonType.FORWARD));
addDrawableChild(new GuiButtonUpDown(x + 121 + 24, y + 79, this, b -> onClick(-64), UpDownButtonType.REWIND));
addDrawableChild(new GuiButtonUpDown(x + 121 + 36, y + 79, this, b -> onClick(-256), UpDownButtonType.FASTREWIND));
}
@Override

View file

@ -49,12 +49,12 @@ public class GuiChunkLoader extends GuiBase<BuiltScreenHandler> {
public void init() {
super.init();
addButton(new GuiButtonUpDown(x + 64, y + 40, this, b -> onClick(5), UpDownButtonType.FASTFORWARD));
addButton(new GuiButtonUpDown(x + 64 + 12, y + 40, this, b -> onClick(1), UpDownButtonType.FORWARD));
addButton(new GuiButtonUpDown(x + 64 + 24, y + 40, this, b -> onClick(-1), UpDownButtonType.REWIND));
addButton(new GuiButtonUpDown(x + 64 + 36, y + 40, this, b -> onClick(-5), UpDownButtonType.FASTREWIND));
addDrawableChild(new GuiButtonUpDown(x + 64, y + 40, this, b -> onClick(5), UpDownButtonType.FASTFORWARD));
addDrawableChild(new GuiButtonUpDown(x + 64 + 12, y + 40, this, b -> onClick(1), UpDownButtonType.FORWARD));
addDrawableChild(new GuiButtonUpDown(x + 64 + 24, y + 40, this, b -> onClick(-1), UpDownButtonType.REWIND));
addDrawableChild(new GuiButtonUpDown(x + 64 + 36, y + 40, this, b -> onClick(-5), UpDownButtonType.FASTREWIND));
addButton(new GuiButtonSimple(x + 10, y + 70, 155, 20, new LiteralText("Toggle Loaded Chunks"), b -> ClientChunkManager.toggleLoadedChunks(blockEntity.getPos())));
addDrawableChild(new GuiButtonSimple(x + 10, y + 70, 155, 20, new LiteralText("Toggle Loaded Chunks"), b -> ClientChunkManager.toggleLoadedChunks(blockEntity.getPos())));
}
@Override

View file

@ -56,10 +56,10 @@ public class GuiFusionReactor extends GuiBase<BuiltScreenHandler> {
@Override
public void init() {
super.init();
addButton(new GuiButtonUpDown(x + 121, y + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(5), UpDownButtonType.FASTFORWARD));
addButton(new GuiButtonUpDown(x + 121 + 12, y + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(1), UpDownButtonType.FORWARD));
addButton(new GuiButtonUpDown(x + 121 + 24, y + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(-5), UpDownButtonType.REWIND));
addButton(new GuiButtonUpDown(x + 121 + 36, y + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(-1), UpDownButtonType.FASTREWIND));
addDrawableChild(new GuiButtonUpDown(x + 121, y + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(5), UpDownButtonType.FASTFORWARD));
addDrawableChild(new GuiButtonUpDown(x + 121 + 12, y + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(1), UpDownButtonType.FORWARD));
addDrawableChild(new GuiButtonUpDown(x + 121 + 24, y + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(-5), UpDownButtonType.REWIND));
addDrawableChild(new GuiButtonUpDown(x + 121 + 36, y + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(-1), UpDownButtonType.FASTREWIND));
}
@Override

Some files were not shown because too many files have changed in this diff Show more