Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
Expand Down Expand Up @@ -58,7 +57,7 @@ public class MachineDefinition implements Supplier<MetaMachineBlock> {
@Setter
private Supplier<? extends MetaMachineItem> itemSupplier;
@Setter
private Supplier<BlockEntityType<? extends BlockEntity>> blockEntityTypeSupplier;
private Supplier<BlockEntityType<? extends MetaMachine>> blockEntityTypeSupplier;
@Getter
@Setter
private @NotNull GTRecipeType @NotNull [] recipeTypes;
Expand Down Expand Up @@ -150,7 +149,7 @@ public MetaMachineItem getItem() {
return itemSupplier.get();
}

public BlockEntityType<? extends BlockEntity> getBlockEntityType() {
public BlockEntityType<? extends MetaMachine> getBlockEntityType() {
return blockEntityTypeSupplier.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -114,7 +113,7 @@ public class MachineBuilder<DEFINITION extends MachineDefinition, TYPE extends M
private Consumer<BlockBuilder<? extends Block, ?>> blockBuilder;
@Nullable
private Consumer<ItemBuilder<? extends MetaMachineItem, ?>> itemBuilder;
private NonNullConsumer<BlockEntityType<BlockEntity>> onBlockEntityRegister = NonNullConsumer.noop();
private NonNullConsumer<BlockEntityType<MetaMachine>> onBlockEntityRegister = NonNullConsumer.noop();
@Getter // getter for KJS
private @NotNull GTRecipeType @NotNull [] recipeTypes = new GTRecipeType[0];
@Getter // getter for KJS
Expand Down Expand Up @@ -226,7 +225,7 @@ public TYPE itemBuilder(Consumer<ItemBuilder<? extends MetaMachineItem, ?>> item
return getThis();
}

public TYPE onBlockEntityRegister(NonNullConsumer<BlockEntityType<BlockEntity>> onBlockEntityRegister) {
public TYPE onBlockEntityRegister(NonNullConsumer<BlockEntityType<MetaMachine>> onBlockEntityRegister) {
this.onBlockEntityRegister = onBlockEntityRegister;
return getThis();
}
Expand Down Expand Up @@ -666,7 +665,7 @@ public DEFINITION register() {
var item = itemBuilder.register();

var blockEntityBuilder = registrate
.blockEntity(
.<MetaMachine>blockEntity(
(type, pos, state) -> blockEntityFactory.apply(new BlockEntityCreationInfo(type, pos, state)))
.onRegister(onBlockEntityRegister)
.validBlock(block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
Expand All @@ -61,7 +60,7 @@
import java.util.stream.Collectors;

public final class MachineModel extends BaseBakedModel implements ICoverableRenderer,
IBlockEntityRendererBakedModel<BlockEntity> {
IBlockEntityRendererBakedModel<MetaMachine> {

public static final ResourceLocation PIPE_OVERLAY = GTCEu.id("block/overlay/machine/overlay_pipe");
public static final ResourceLocation FLUID_OUTPUT_OVERLAY = GTCEu.id("block/overlay/machine/overlay_fluid_output");
Expand Down Expand Up @@ -429,10 +428,9 @@ public boolean isCustomRenderer() {

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void render(BlockEntity blockEntity, float partialTick,
public void render(MetaMachine machine, float partialTick,
PoseStack poseStack, MultiBufferSource buffer,
int packedLight, int packedOverlay) {
if (!(blockEntity instanceof MetaMachine machine)) return;
if (machine.getDefinition() != getDefinition()) return;
ICoverableRenderer.super.renderDynamicCovers(machine, partialTick, poseStack, buffer,
packedLight,
Expand Down Expand Up @@ -460,10 +458,9 @@ public void renderByItem(ItemStack stack, ItemDisplayContext displayContext,

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public AABB getRenderBoundingBox(BlockEntity blockEntity) {
AABB bounds = IBlockEntityRendererBakedModel.super.getRenderBoundingBox(blockEntity);
public AABB getRenderBoundingBox(MetaMachine machine) {
AABB bounds = IBlockEntityRendererBakedModel.super.getRenderBoundingBox(machine);

if (!(blockEntity instanceof MetaMachine machine)) return bounds;
if (machine.getDefinition() != getDefinition()) return bounds;
if (dynamicRenders.isEmpty()) return bounds;

Expand All @@ -475,8 +472,7 @@ public AABB getRenderBoundingBox(BlockEntity blockEntity) {

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public boolean shouldRenderOffScreen(BlockEntity blockEntity) {
if (!(blockEntity instanceof MetaMachine machine)) return false;
public boolean shouldRenderOffScreen(MetaMachine machine) {
if (machine.getDefinition() != getDefinition()) return false;
if (dynamicRenders.isEmpty()) return false;

Expand All @@ -488,8 +484,7 @@ public boolean shouldRenderOffScreen(BlockEntity blockEntity) {

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public boolean shouldRender(BlockEntity blockEntity, Vec3 cameraPos) {
if (!(blockEntity instanceof MetaMachine machine)) return false;
public boolean shouldRender(MetaMachine machine, Vec3 cameraPos) {
if (machine.getDefinition() != getDefinition()) return false;
if (machine.getCoverContainer().hasDynamicCovers()) return true;
if (dynamicRenders.isEmpty()) return false;
Expand All @@ -512,7 +507,7 @@ public int getViewDistance() {
}

@Override
public BlockEntityType<? extends BlockEntity> getBlockEntityType() {
public BlockEntityType<? extends MetaMachine> getBlockEntityType() {
return getDefinition().getBlockEntityType();
}
}
Loading