mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 22:43:41 +01:00
blaze heater lighting (moved heat level to block state)
This commit is contained in:
parent
0580318b38
commit
376b6cc851
5 changed files with 37 additions and 44 deletions
|
@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.fan;
|
||||||
|
|
||||||
import com.simibubi.create.AllTags.AllBlockTags;
|
import com.simibubi.create.AllTags.AllBlockTags;
|
||||||
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
|
||||||
|
import com.simibubi.create.content.contraptions.processing.HeaterBlock;
|
||||||
import com.simibubi.create.content.contraptions.processing.HeaterTileEntity;
|
import com.simibubi.create.content.contraptions.processing.HeaterTileEntity;
|
||||||
import com.simibubi.create.content.logistics.block.chute.ChuteTileEntity;
|
import com.simibubi.create.content.logistics.block.chute.ChuteTileEntity;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
|
@ -74,11 +75,12 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean blockBelowIsHot() {
|
public boolean blockBelowIsHot() {
|
||||||
|
if (world == null)
|
||||||
|
return false;
|
||||||
BlockState checkState = world.getBlockState(pos.down());
|
BlockState checkState = world.getBlockState(pos.down());
|
||||||
TileEntity te = world.getTileEntity(pos.down());
|
|
||||||
return checkState.getBlock()
|
return checkState.getBlock()
|
||||||
.isIn(AllBlockTags.FAN_HEATERS.tag)
|
.isIn(AllBlockTags.FAN_HEATERS.tag)
|
||||||
|| (te instanceof HeaterTileEntity && ((HeaterTileEntity) te).getHeatLevel() >= 2);
|
|| (checkState.has(HeaterBlock.BLAZE_LEVEL) && checkState.get(HeaterBlock.BLAZE_LEVEL) >= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMaxDistance() {
|
public float getMaxDistance() {
|
||||||
|
|
|
@ -11,13 +11,14 @@ import com.simibubi.create.content.contraptions.fluids.CombinedFluidHandler;
|
||||||
import com.simibubi.create.content.contraptions.processing.BasinOperatingTileEntity;
|
import com.simibubi.create.content.contraptions.processing.BasinOperatingTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.processing.BasinTileEntity.BasinInventory;
|
import com.simibubi.create.content.contraptions.processing.BasinTileEntity.BasinInventory;
|
||||||
import com.simibubi.create.content.contraptions.processing.CombinedItemFluidList;
|
import com.simibubi.create.content.contraptions.processing.CombinedItemFluidList;
|
||||||
import com.simibubi.create.content.contraptions.processing.HeaterTileEntity;
|
import com.simibubi.create.content.contraptions.processing.HeaterBlock;
|
||||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform;
|
import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour;
|
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
|
@ -26,7 +27,6 @@ import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.particles.ItemParticleData;
|
import net.minecraft.particles.ItemParticleData;
|
||||||
import net.minecraft.particles.ParticleTypes;
|
import net.minecraft.particles.ParticleTypes;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
|
@ -35,6 +35,8 @@ import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
import static com.simibubi.create.content.contraptions.processing.HeaterBlock.getHeaterLevel;
|
||||||
|
|
||||||
public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
|
public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
|
||||||
|
|
||||||
private static final Object shapelessOrMixingRecipesKey = new Object();
|
private static final Object shapelessOrMixingRecipesKey = new Object();
|
||||||
|
@ -270,10 +272,9 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
|
||||||
private int getHeatLevelApplied() {
|
private int getHeatLevelApplied() {
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return 0;
|
return 0;
|
||||||
TileEntity te = world.getTileEntity(pos.down(3));
|
BlockState state = world.getBlockState(pos.down(3));
|
||||||
if (!(te instanceof HeaterTileEntity))
|
if (state.has(HeaterBlock.BLAZE_LEVEL))
|
||||||
return AllTags.AllBlockTags.FAN_HEATERS.matches(world.getBlockState(pos.down(3))) ? 1 : 0;
|
return state.get(HeaterBlock.BLAZE_LEVEL);
|
||||||
return ((HeaterTileEntity) te).getHeatLevel();
|
return AllTags.AllBlockTags.FAN_HEATERS.matches(state) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,15 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.state.BooleanProperty;
|
|
||||||
import net.minecraft.state.IProperty;
|
import net.minecraft.state.IProperty;
|
||||||
|
import net.minecraft.state.IntegerProperty;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
|
@ -30,22 +31,22 @@ import net.minecraft.world.World;
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public class HeaterBlock extends Block implements ITE<HeaterTileEntity> {
|
public class HeaterBlock extends Block implements ITE<HeaterTileEntity> {
|
||||||
|
|
||||||
public static IProperty<Boolean> HAS_BLAZE = BooleanProperty.create("has_blaze");
|
public static IProperty<Integer> BLAZE_LEVEL = IntegerProperty.create("blaze_level", 0, 4);
|
||||||
|
|
||||||
public HeaterBlock(Properties properties) {
|
public HeaterBlock(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
setDefaultState(super.getDefaultState().with(HAS_BLAZE, false));
|
setDefaultState(super.getDefaultState().with(BLAZE_LEVEL, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||||
super.fillStateContainer(builder);
|
super.fillStateContainer(builder);
|
||||||
builder.add(HAS_BLAZE);
|
builder.add(BLAZE_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasTileEntity(BlockState state) {
|
public boolean hasTileEntity(BlockState state) {
|
||||||
return state.get(HAS_BLAZE);
|
return state.get(BLAZE_LEVEL) >= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -78,10 +79,10 @@ public class HeaterBlock extends Block implements ITE<HeaterTileEntity> {
|
||||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
ItemStack item = context.getItem();
|
ItemStack item = context.getItem();
|
||||||
BlockState state = super.getStateForPlacement(context);
|
BlockState state = super.getStateForPlacement(context);
|
||||||
return (state != null ? state : getDefaultState()).with(HAS_BLAZE,
|
return (state != null ? state : getDefaultState()).with(BLAZE_LEVEL,
|
||||||
item.hasTag() && item.getTag() != null && item.getTag()
|
(item.hasTag() && item.getTag() != null && item.getTag()
|
||||||
.contains("has_blaze") && item.getTag()
|
.contains("has_blaze") && item.getTag()
|
||||||
.getBoolean("has_blaze"));
|
.getBoolean("has_blaze")) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,12 +92,15 @@ public class HeaterBlock extends Block implements ITE<HeaterTileEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightValue(BlockState state, IBlockReader world, BlockPos pos) {
|
public int getLightValue(BlockState state, IBlockReader world, BlockPos pos) {
|
||||||
// System.out.println("light " + pos);
|
return MathHelper.clamp(state.get(BLAZE_LEVEL) * 4 - 1, 0, 15);
|
||||||
// return 15;
|
}
|
||||||
try {
|
|
||||||
return getTileEntity(world, pos).getHeatLevel() * 4 - 1;
|
static void setBlazeLevel(@Nullable World world, BlockPos pos, int blazeLevel) {
|
||||||
} catch (TileEntityException e) {
|
if (world != null)
|
||||||
return 0;
|
world.setBlockState(pos, world.getBlockState(pos).with(BLAZE_LEVEL, blazeLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getHeaterLevel(BlockState blockState) {
|
||||||
|
return blockState.has(HeaterBlock.BLAZE_LEVEL) ? blockState.get(HeaterBlock.BLAZE_LEVEL) : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,12 @@ import net.minecraftforge.common.ForgeHooks;
|
||||||
public class HeaterTileEntity extends SmartTileEntity {
|
public class HeaterTileEntity extends SmartTileEntity {
|
||||||
private int fuelLevel;
|
private int fuelLevel;
|
||||||
private int burnTimeRemaining;
|
private int burnTimeRemaining;
|
||||||
private int bufferedHeatLevel;
|
|
||||||
private static final int maxHeatCapacity = 5000;
|
private static final int maxHeatCapacity = 5000;
|
||||||
|
|
||||||
public HeaterTileEntity(TileEntityType<? extends HeaterTileEntity> tileEntityTypeIn) {
|
public HeaterTileEntity(TileEntityType<? extends HeaterTileEntity> tileEntityTypeIn) {
|
||||||
super(tileEntityTypeIn);
|
super(tileEntityTypeIn);
|
||||||
fuelLevel = 0;
|
fuelLevel = 0;
|
||||||
burnTimeRemaining = 0;
|
burnTimeRemaining = 0;
|
||||||
bufferedHeatLevel = 1;
|
|
||||||
setLazyTickRate(40);
|
setLazyTickRate(40);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,17 +87,10 @@ public class HeaterTileEntity extends SmartTileEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeatLevel() {
|
public int getHeatLevel() {
|
||||||
return bufferedHeatLevel;
|
return HeaterBlock.getHeaterLevel(getBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateHeatLevel() {
|
private void updateHeatLevel() {
|
||||||
int newHeatLevel = 1 + fuelLevel;
|
HeaterBlock.setBlazeLevel(world, pos, 1 + fuelLevel);
|
||||||
if (newHeatLevel != bufferedHeatLevel) {
|
|
||||||
bufferedHeatLevel = newHeatLevel;
|
|
||||||
markDirty();
|
|
||||||
if (world != null) {
|
|
||||||
sendData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Optional;
|
||||||
|
|
||||||
import com.simibubi.create.AllRecipeTypes;
|
import com.simibubi.create.AllRecipeTypes;
|
||||||
import com.simibubi.create.content.contraptions.components.fan.SplashingRecipe;
|
import com.simibubi.create.content.contraptions.components.fan.SplashingRecipe;
|
||||||
import com.simibubi.create.content.contraptions.processing.HeaterTileEntity;
|
|
||||||
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
|
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
|
@ -32,7 +31,6 @@ import net.minecraft.particles.RedstoneParticleData;
|
||||||
import net.minecraft.tileentity.BlastFurnaceTileEntity;
|
import net.minecraft.tileentity.BlastFurnaceTileEntity;
|
||||||
import net.minecraft.tileentity.FurnaceTileEntity;
|
import net.minecraft.tileentity.FurnaceTileEntity;
|
||||||
import net.minecraft.tileentity.SmokerTileEntity;
|
import net.minecraft.tileentity.SmokerTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
|
@ -41,6 +39,8 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||||
|
|
||||||
|
import static com.simibubi.create.content.contraptions.processing.HeaterBlock.getHeaterLevel;
|
||||||
|
|
||||||
public class InWorldProcessing {
|
public class InWorldProcessing {
|
||||||
|
|
||||||
public static class SplashingInv extends RecipeWrapper {
|
public static class SplashingInv extends RecipeWrapper {
|
||||||
|
@ -62,17 +62,12 @@ public class InWorldProcessing {
|
||||||
if (fluidState.getFluid() == Fluids.WATER || fluidState.getFluid() == Fluids.FLOWING_WATER)
|
if (fluidState.getFluid() == Fluids.WATER || fluidState.getFluid() == Fluids.FLOWING_WATER)
|
||||||
return Type.SPLASHING;
|
return Type.SPLASHING;
|
||||||
if (blockState.getBlock() == Blocks.FIRE
|
if (blockState.getBlock() == Blocks.FIRE
|
||||||
|| (blockState.getBlock() == Blocks.CAMPFIRE && blockState.get(CampfireBlock.LIT)) || getHeaterLevel(reader, pos) == 1)
|
|| (blockState.getBlock() == Blocks.CAMPFIRE && blockState.get(CampfireBlock.LIT)) || getHeaterLevel(blockState) == 1)
|
||||||
return Type.SMOKING;
|
return Type.SMOKING;
|
||||||
if (blockState.getBlock() == Blocks.LAVA || getHeaterLevel(reader, pos) >= 2)
|
if (blockState.getBlock() == Blocks.LAVA || getHeaterLevel(blockState) >= 2)
|
||||||
return Type.BLASTING;
|
return Type.BLASTING;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getHeaterLevel(IBlockReader reader, BlockPos pos) {
|
|
||||||
TileEntity te = reader.getTileEntity(pos);
|
|
||||||
return te instanceof HeaterTileEntity ? ((HeaterTileEntity) te).getHeatLevel() : 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canProcess(ItemEntity entity, Type type) {
|
public static boolean canProcess(ItemEntity entity, Type type) {
|
||||||
|
|
Loading…
Reference in a new issue