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.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.logistics.block.chute.ChuteTileEntity;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
|
@ -74,11 +75,12 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity {
|
|||
}
|
||||
|
||||
public boolean blockBelowIsHot() {
|
||||
if (world == null)
|
||||
return false;
|
||||
BlockState checkState = world.getBlockState(pos.down());
|
||||
TileEntity te = world.getTileEntity(pos.down());
|
||||
return checkState.getBlock()
|
||||
.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() {
|
||||
|
|
|
@ -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.BasinTileEntity.BasinInventory;
|
||||
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.behaviour.CenteredSideValueBoxTransform;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
@ -26,7 +27,6 @@ import net.minecraft.item.crafting.Ingredient;
|
|||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.particles.ItemParticleData;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
@ -35,6 +35,8 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import static com.simibubi.create.content.contraptions.processing.HeaterBlock.getHeaterLevel;
|
||||
|
||||
public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
|
||||
|
||||
private static final Object shapelessOrMixingRecipesKey = new Object();
|
||||
|
@ -270,10 +272,9 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
|
|||
private int getHeatLevelApplied() {
|
||||
if (world == null)
|
||||
return 0;
|
||||
TileEntity te = world.getTileEntity(pos.down(3));
|
||||
if (!(te instanceof HeaterTileEntity))
|
||||
return AllTags.AllBlockTags.FAN_HEATERS.matches(world.getBlockState(pos.down(3))) ? 1 : 0;
|
||||
return ((HeaterTileEntity) te).getHeatLevel();
|
||||
BlockState state = world.getBlockState(pos.down(3));
|
||||
if (state.has(HeaterBlock.BLAZE_LEVEL))
|
||||
return state.get(HeaterBlock.BLAZE_LEVEL);
|
||||
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.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.state.IntegerProperty;
|
||||
import net.minecraft.state.StateContainer.Builder;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
@ -30,22 +31,22 @@ import net.minecraft.world.World;
|
|||
@ParametersAreNonnullByDefault
|
||||
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) {
|
||||
super(properties);
|
||||
setDefaultState(super.getDefaultState().with(HAS_BLAZE, false));
|
||||
setDefaultState(super.getDefaultState().with(BLAZE_LEVEL, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(HAS_BLAZE);
|
||||
builder.add(BLAZE_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return state.get(HAS_BLAZE);
|
||||
return state.get(BLAZE_LEVEL) >= 1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -78,10 +79,10 @@ public class HeaterBlock extends Block implements ITE<HeaterTileEntity> {
|
|||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
ItemStack item = context.getItem();
|
||||
BlockState state = super.getStateForPlacement(context);
|
||||
return (state != null ? state : getDefaultState()).with(HAS_BLAZE,
|
||||
item.hasTag() && item.getTag() != null && item.getTag()
|
||||
return (state != null ? state : getDefaultState()).with(BLAZE_LEVEL,
|
||||
(item.hasTag() && item.getTag() != null && item.getTag()
|
||||
.contains("has_blaze") && item.getTag()
|
||||
.getBoolean("has_blaze"));
|
||||
.getBoolean("has_blaze")) ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,12 +92,15 @@ public class HeaterBlock extends Block implements ITE<HeaterTileEntity> {
|
|||
|
||||
@Override
|
||||
public int getLightValue(BlockState state, IBlockReader world, BlockPos pos) {
|
||||
// System.out.println("light " + pos);
|
||||
// return 15;
|
||||
try {
|
||||
return getTileEntity(world, pos).getHeatLevel() * 4 - 1;
|
||||
} catch (TileEntityException e) {
|
||||
return 0;
|
||||
}
|
||||
return MathHelper.clamp(state.get(BLAZE_LEVEL) * 4 - 1, 0, 15);
|
||||
}
|
||||
|
||||
static void setBlazeLevel(@Nullable World world, BlockPos pos, int blazeLevel) {
|
||||
if (world != null)
|
||||
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 {
|
||||
private int fuelLevel;
|
||||
private int burnTimeRemaining;
|
||||
private int bufferedHeatLevel;
|
||||
private static final int maxHeatCapacity = 5000;
|
||||
|
||||
public HeaterTileEntity(TileEntityType<? extends HeaterTileEntity> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
fuelLevel = 0;
|
||||
burnTimeRemaining = 0;
|
||||
bufferedHeatLevel = 1;
|
||||
setLazyTickRate(40);
|
||||
}
|
||||
|
||||
|
@ -89,17 +87,10 @@ public class HeaterTileEntity extends SmartTileEntity {
|
|||
}
|
||||
|
||||
public int getHeatLevel() {
|
||||
return bufferedHeatLevel;
|
||||
return HeaterBlock.getHeaterLevel(getBlockState());
|
||||
}
|
||||
|
||||
private void updateHeatLevel() {
|
||||
int newHeatLevel = 1 + fuelLevel;
|
||||
if (newHeatLevel != bufferedHeatLevel) {
|
||||
bufferedHeatLevel = newHeatLevel;
|
||||
markDirty();
|
||||
if (world != null) {
|
||||
sendData();
|
||||
}
|
||||
}
|
||||
HeaterBlock.setBlazeLevel(world, pos, 1 + fuelLevel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Optional;
|
|||
|
||||
import com.simibubi.create.AllRecipeTypes;
|
||||
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.relays.belt.transport.TransportedItemStack;
|
||||
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.FurnaceTileEntity;
|
||||
import net.minecraft.tileentity.SmokerTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
@ -41,6 +39,8 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
|||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
|
||||
import static com.simibubi.create.content.contraptions.processing.HeaterBlock.getHeaterLevel;
|
||||
|
||||
public class InWorldProcessing {
|
||||
|
||||
public static class SplashingInv extends RecipeWrapper {
|
||||
|
@ -62,17 +62,12 @@ public class InWorldProcessing {
|
|||
if (fluidState.getFluid() == Fluids.WATER || fluidState.getFluid() == Fluids.FLOWING_WATER)
|
||||
return Type.SPLASHING;
|
||||
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;
|
||||
if (blockState.getBlock() == Blocks.LAVA || getHeaterLevel(reader, pos) >= 2)
|
||||
if (blockState.getBlock() == Blocks.LAVA || getHeaterLevel(blockState) >= 2)
|
||||
return Type.BLASTING;
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue