Skip to content

Commit

Permalink
rename tile entity to block entity
Browse files Browse the repository at this point in the history
  • Loading branch information
cech12 committed Dec 5, 2021
1 parent 6c75f4f commit c941238
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cech12.brickfurnace.api.tileentity;
package cech12.brickfurnace.api.blockentity;

import net.minecraft.world.level.block.entity.BlockEntityType;

public class BrickFurnaceTileEntities {
public class BrickFurnaceBlockEntities {

public static BlockEntityType<?> BRICK_FURNACE;
public static BlockEntityType<?> BRICK_BLAST_FURNACE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cech12.brickfurnace.block;

import cech12.brickfurnace.api.tileentity.BrickFurnaceTileEntities;
import cech12.brickfurnace.tileentity.AbstractBrickFurnaceTileEntity;
import cech12.brickfurnace.tileentity.BrickBlastFurnaceTileEntity;
import cech12.brickfurnace.api.blockentity.BrickFurnaceBlockEntities;
import cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity;
import cech12.brickfurnace.blockentity.BrickBlastFurnaceBlockEntity;
import net.minecraft.world.level.block.BlastFurnaceBlock;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.MenuProvider;
Expand All @@ -27,13 +27,13 @@ public BrickBlastFurnaceBlock(BlockBehaviour.Properties builder) {

@Override
public BlockEntity newBlockEntity(@Nonnull BlockPos blockPos, @Nonnull BlockState blockState) {
return new BrickBlastFurnaceTileEntity(blockPos, blockState);
return new BrickBlastFurnaceBlockEntity(blockPos, blockState);
}

@Override
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@Nonnull Level level, @Nonnull BlockState state, @Nonnull BlockEntityType<T> entityType) {
return createTickerHelper(entityType, (BlockEntityType<AbstractBrickFurnaceTileEntity>) BrickFurnaceTileEntities.BRICK_BLAST_FURNACE, AbstractBrickFurnaceTileEntity::tick);
return createTickerHelper(entityType, (BlockEntityType<AbstractBrickFurnaceBlockEntity>) BrickFurnaceBlockEntities.BRICK_BLAST_FURNACE, AbstractBrickFurnaceBlockEntity::tick);
}

/**
Expand All @@ -42,9 +42,9 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@Nonnull Level lev
*/
@Override
protected void openContainer(Level worldIn, @Nonnull BlockPos pos, @Nonnull Player player) {
BlockEntity tileentity = worldIn.getBlockEntity(pos);
if (tileentity instanceof BrickBlastFurnaceTileEntity) {
player.openMenu((MenuProvider)tileentity);
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity instanceof BrickBlastFurnaceBlockEntity) {
player.openMenu((MenuProvider)blockEntity);
player.awardStat(Stats.INTERACT_WITH_BLAST_FURNACE);
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/cech12/brickfurnace/block/BrickFurnaceBlock.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cech12.brickfurnace.block;

import cech12.brickfurnace.api.tileentity.BrickFurnaceTileEntities;
import cech12.brickfurnace.tileentity.AbstractBrickFurnaceTileEntity;
import cech12.brickfurnace.tileentity.BrickFurnaceTileEntity;
import cech12.brickfurnace.api.blockentity.BrickFurnaceBlockEntities;
import cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity;
import cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity;
import net.minecraft.world.level.block.FurnaceBlock;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.MenuProvider;
Expand All @@ -27,13 +27,13 @@ public BrickFurnaceBlock(BlockBehaviour.Properties builder) {

@Override
public BlockEntity newBlockEntity(@Nonnull BlockPos blockPos, @Nonnull BlockState blockState) {
return new BrickFurnaceTileEntity(blockPos, blockState);
return new BrickFurnaceBlockEntity(blockPos, blockState);
}

@Override
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@Nonnull Level level, @Nonnull BlockState state, @Nonnull BlockEntityType<T> entityType) {
return createTickerHelper(entityType, (BlockEntityType<AbstractBrickFurnaceTileEntity>) BrickFurnaceTileEntities.BRICK_FURNACE, AbstractBrickFurnaceTileEntity::tick);
return createTickerHelper(entityType, (BlockEntityType<AbstractBrickFurnaceBlockEntity>) BrickFurnaceBlockEntities.BRICK_FURNACE, AbstractBrickFurnaceBlockEntity::tick);
}

/**
Expand All @@ -42,9 +42,9 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@Nonnull Level lev
*/
@Override
protected void openContainer(Level worldIn, @Nonnull BlockPos pos, @Nonnull Player player) {
BlockEntity tileentity = worldIn.getBlockEntity(pos);
if (tileentity instanceof BrickFurnaceTileEntity) {
player.openMenu((MenuProvider)tileentity);
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity instanceof BrickFurnaceBlockEntity) {
player.openMenu((MenuProvider)blockEntity);
player.awardStat(Stats.INTERACT_WITH_FURNACE);
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/cech12/brickfurnace/block/BrickSmokerBlock.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cech12.brickfurnace.block;

import cech12.brickfurnace.api.tileentity.BrickFurnaceTileEntities;
import cech12.brickfurnace.tileentity.AbstractBrickFurnaceTileEntity;
import cech12.brickfurnace.tileentity.BrickSmokerTileEntity;
import cech12.brickfurnace.api.blockentity.BrickFurnaceBlockEntities;
import cech12.brickfurnace.blockentity.AbstractBrickFurnaceBlockEntity;
import cech12.brickfurnace.blockentity.BrickSmokerBlockEntity;
import net.minecraft.world.level.block.SmokerBlock;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.MenuProvider;
Expand All @@ -27,13 +27,13 @@ public BrickSmokerBlock(BlockBehaviour.Properties builder) {

@Override
public BlockEntity newBlockEntity(@Nonnull BlockPos blockPos, @Nonnull BlockState blockState) {
return new BrickSmokerTileEntity(blockPos, blockState);
return new BrickSmokerBlockEntity(blockPos, blockState);
}

@Override
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@Nonnull Level level, @Nonnull BlockState state, @Nonnull BlockEntityType<T> entityType) {
return createTickerHelper(entityType, (BlockEntityType<AbstractBrickFurnaceTileEntity>) BrickFurnaceTileEntities.BRICK_SMOKER, AbstractBrickFurnaceTileEntity::tick);
return createTickerHelper(entityType, (BlockEntityType<AbstractBrickFurnaceBlockEntity>) BrickFurnaceBlockEntities.BRICK_SMOKER, AbstractBrickFurnaceBlockEntity::tick);
}

/**
Expand All @@ -42,9 +42,9 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@Nonnull Level lev
*/
@Override
protected void openContainer(Level worldIn, @Nonnull BlockPos pos, @Nonnull Player player) {
BlockEntity tileentity = worldIn.getBlockEntity(pos);
if (tileentity instanceof BrickSmokerTileEntity) {
player.openMenu((MenuProvider)tileentity);
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity instanceof BrickSmokerBlockEntity) {
player.openMenu((MenuProvider)blockEntity);
player.awardStat(Stats.INTERACT_WITH_SMOKER);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cech12.brickfurnace.tileentity;
package cech12.brickfurnace.blockentity;

import cech12.brickfurnace.config.ServerConfig;
import net.minecraft.core.BlockPos;
Expand All @@ -17,17 +17,17 @@

import javax.annotation.Nullable;

public abstract class AbstractBrickFurnaceTileEntity extends AbstractFurnaceBlockEntity {
public abstract class AbstractBrickFurnaceBlockEntity extends AbstractFurnaceBlockEntity {

protected final RecipeType<? extends AbstractCookingRecipe> specificRecipeType;
protected final RecipeType<? extends AbstractCookingRecipe> vanillaRecipeType;

public AbstractBrickFurnaceTileEntity(BlockEntityType<?> tileTypeIn,
BlockPos blockPos,
BlockState blockState,
RecipeType<? extends AbstractCookingRecipe> specificRecipeTypeIn,
RecipeType<? extends AbstractCookingRecipe> vanillaRecipeTypeIn) {
super(tileTypeIn, blockPos, blockState, vanillaRecipeTypeIn);
public AbstractBrickFurnaceBlockEntity(BlockEntityType<?> blockEntityTypeIn,
BlockPos blockPos,
BlockState blockState,
RecipeType<? extends AbstractCookingRecipe> specificRecipeTypeIn,
RecipeType<? extends AbstractCookingRecipe> vanillaRecipeTypeIn) {
super(blockEntityTypeIn, blockPos, blockState, vanillaRecipeTypeIn);
this.specificRecipeType = specificRecipeTypeIn;
this.vanillaRecipeType = vanillaRecipeTypeIn;
}
Expand All @@ -52,7 +52,7 @@ private boolean isBurning() {
return this.dataAccess.get(BURN_TIME) > 0; //changed because of private variable
}

public static void tick(Level level, BlockPos pos, BlockState state, AbstractBrickFurnaceTileEntity entity) {
public static void tick(Level level, BlockPos pos, BlockState state, AbstractBrickFurnaceBlockEntity entity) {
boolean wasBurning = entity.isBurning();
boolean dirty = false;
if (entity.isBurning()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cech12.brickfurnace.tileentity;
package cech12.brickfurnace.blockentity;

import cech12.brickfurnace.api.crafting.RecipeTypes;
import cech12.brickfurnace.api.tileentity.BrickFurnaceTileEntities;
import cech12.brickfurnace.api.blockentity.BrickFurnaceBlockEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.BlastFurnaceMenu;
Expand All @@ -13,10 +13,10 @@

import javax.annotation.Nonnull;

public class BrickBlastFurnaceTileEntity extends AbstractBrickFurnaceTileEntity {
public class BrickBlastFurnaceBlockEntity extends AbstractBrickFurnaceBlockEntity {

public BrickBlastFurnaceTileEntity(BlockPos blockPos, BlockState blockState) {
super(BrickFurnaceTileEntities.BRICK_BLAST_FURNACE, blockPos, blockState, RecipeTypes.BLASTING, RecipeType.BLASTING);
public BrickBlastFurnaceBlockEntity(BlockPos blockPos, BlockState blockState) {
super(BrickFurnaceBlockEntities.BRICK_BLAST_FURNACE, blockPos, blockState, RecipeTypes.BLASTING, RecipeType.BLASTING);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cech12.brickfurnace.tileentity;
package cech12.brickfurnace.blockentity;

import cech12.brickfurnace.api.crafting.RecipeTypes;
import cech12.brickfurnace.api.tileentity.BrickFurnaceTileEntities;
import cech12.brickfurnace.api.blockentity.BrickFurnaceBlockEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.AbstractContainerMenu;
Expand All @@ -13,10 +13,10 @@

import javax.annotation.Nonnull;

public class BrickFurnaceTileEntity extends AbstractBrickFurnaceTileEntity {
public class BrickFurnaceBlockEntity extends AbstractBrickFurnaceBlockEntity {

public BrickFurnaceTileEntity(BlockPos blockPos, BlockState blockState) {
super(BrickFurnaceTileEntities.BRICK_FURNACE, blockPos, blockState, RecipeTypes.SMELTING, RecipeType.SMELTING);
public BrickFurnaceBlockEntity(BlockPos blockPos, BlockState blockState) {
super(BrickFurnaceBlockEntities.BRICK_FURNACE, blockPos, blockState, RecipeTypes.SMELTING, RecipeType.SMELTING);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cech12.brickfurnace.tileentity;
package cech12.brickfurnace.blockentity;

import cech12.brickfurnace.api.crafting.RecipeTypes;
import cech12.brickfurnace.api.tileentity.BrickFurnaceTileEntities;
import cech12.brickfurnace.api.blockentity.BrickFurnaceBlockEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.AbstractContainerMenu;
Expand All @@ -13,10 +13,10 @@

import javax.annotation.Nonnull;

public class BrickSmokerTileEntity extends AbstractBrickFurnaceTileEntity {
public class BrickSmokerBlockEntity extends AbstractBrickFurnaceBlockEntity {

public BrickSmokerTileEntity(BlockPos blockPos, BlockState blockState) {
super(BrickFurnaceTileEntities.BRICK_SMOKER, blockPos, blockState, RecipeTypes.SMOKING, RecipeType.SMOKING);
public BrickSmokerBlockEntity(BlockPos blockPos, BlockState blockState) {
super(BrickFurnaceBlockEntities.BRICK_SMOKER, blockPos, blockState, RecipeTypes.SMOKING, RecipeType.SMOKING);
}

@Override
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/cech12/brickfurnace/init/ModBlockEntities.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cech12.brickfurnace.init;

import cech12.brickfurnace.BrickFurnaceMod;
import cech12.brickfurnace.api.block.BrickFurnaceBlocks;
import cech12.brickfurnace.api.blockentity.BrickFurnaceBlockEntities;
import cech12.brickfurnace.blockentity.BrickBlastFurnaceBlockEntity;
import cech12.brickfurnace.blockentity.BrickFurnaceBlockEntity;
import cech12.brickfurnace.blockentity.BrickSmokerBlockEntity;
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.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid= BrickFurnaceMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public final class ModBlockEntities {

@SubscribeEvent
public static void registerBlockEntities(RegistryEvent.Register<BlockEntityType<?>> event) {
BrickFurnaceBlockEntities.BRICK_FURNACE = register(BrickFurnaceBlockEntity::new, "brick_furnace", BrickFurnaceBlocks.BRICK_FURNACE, event);
BrickFurnaceBlockEntities.BRICK_BLAST_FURNACE = register(BrickBlastFurnaceBlockEntity::new, "brick_blast_furnace", BrickFurnaceBlocks.BRICK_BLAST_FURNACE, event);
BrickFurnaceBlockEntities.BRICK_SMOKER = register(BrickSmokerBlockEntity::new, "brick_smoker", BrickFurnaceBlocks.BRICK_SMOKER, event);
}

private static <T extends BlockEntity> BlockEntityType<T> register(BlockEntityType.BlockEntitySupplier<T> supplier, String registryName, Block block, RegistryEvent.Register<BlockEntityType<?>> registryEvent) {
BlockEntityType<T> blockEntityType = BlockEntityType.Builder.of(supplier, block).build(null);
blockEntityType.setRegistryName(registryName);
registryEvent.getRegistry().register(blockEntityType);
return blockEntityType;
}

}
33 changes: 0 additions & 33 deletions src/main/java/cech12/brickfurnace/init/ModTileEntities.java

This file was deleted.

0 comments on commit c941238

Please sign in to comment.