Fix 1.16 too, i guess

This commit is contained in:
grimmauld 2021-03-29 23:25:28 +02:00
commit 358ff25031
5 changed files with 44 additions and 18 deletions

View file

@ -6,7 +6,6 @@ import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
import com.simibubi.create.content.logistics.block.chute.ChuteTileEntity;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.BlockHelper;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT;
@ -73,12 +72,17 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements
public void updateGenerator() {
BlockState blockState = getBlockState();
boolean shouldGenerate = true;
if (!AllBlocks.ENCASED_FAN.has(blockState))
return;
if (blockState.get(EncasedFanBlock.FACING) != Direction.DOWN)
return;
boolean shouldGenerate = world.isBlockPowered(pos) && world.isBlockPresent(pos.down()) && blockBelowIsHot();
shouldGenerate = false;
if (shouldGenerate && blockState.get(EncasedFanBlock.FACING) != Direction.DOWN)
shouldGenerate = false;
if (shouldGenerate)
shouldGenerate = world != null && world.isBlockPowered(pos) && world.isBlockPresent(pos.down()) && blockBelowIsHot();
if (shouldGenerate == isGenerator)
return;
isGenerator = shouldGenerate;

View file

@ -1,16 +1,13 @@
package com.simibubi.create.content.contraptions.components.flywheel;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemUseContext;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer.Builder;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.IStringSerializable;
@ -19,6 +16,13 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineTileEntity;
import com.simibubi.create.content.contraptions.components.flywheel.engine.FurnaceEngineBlock;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.utility.Lang;
public class FlywheelBlock extends HorizontalKineticBlock {
public static EnumProperty<ConnectionState> CONNECTION = EnumProperty.create("connection", ConnectionState.class);
@ -84,6 +88,24 @@ public class FlywheelBlock extends HorizontalKineticBlock {
return state.get(HORIZONTAL_FACING).getAxis();
}
@Override
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
Direction connection = getConnection(state);
if (connection == null)
return super.onWrenched(state ,context);
if (context.getFace().getAxis() == state.get(HORIZONTAL_FACING).getAxis())
return ActionResultType.PASS;
World world = context.getWorld();
BlockPos enginePos = context.getPos().offset(connection, 2);
BlockState engine = world.getBlockState(enginePos);
if (engine.getBlock() instanceof FurnaceEngineBlock)
((FurnaceEngineBlock) engine.getBlock()).withTileEntityDo(world, enginePos, EngineTileEntity::detachWheel);
return super.onWrenched(state.with(CONNECTION, ConnectionState.NONE), context);
}
public enum ConnectionState implements IStringSerializable {
NONE, LEFT, RIGHT;

View file

@ -76,16 +76,16 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender
}
public void detachWheel() {
if (poweredWheel.isRemoved())
if (poweredWheel == null || poweredWheel.isRemoved())
return;
poweredWheel.setRotation(0, 0);
FlywheelBlock.setConnection(world, poweredWheel.getPos(), poweredWheel.getBlockState(), null);
poweredWheel = null;
}
@Override
public void remove() {
if (poweredWheel != null)
detachWheel();
detachWheel();
super.remove();
}

View file

@ -7,7 +7,6 @@ import com.simibubi.create.content.contraptions.base.HorizontalAxisKineticBlock;
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.DirectionHelper;
import com.simibubi.create.foundation.utility.VoxelShaper;
@ -38,7 +37,7 @@ public interface IWrenchable {
if (te != null)
te.updateContainingBlockInfo();
if (te instanceof GeneratingKineticTileEntity) {
((GeneratingKineticTileEntity) te).updateGeneratedRotation();
((GeneratingKineticTileEntity) te).reActivateSource = true;
}
return ActionResultType.SUCCESS;

View file

@ -1,9 +1,10 @@
package com.simibubi.create.foundation.utility.animation;
import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.MathHelper;
import com.simibubi.create.foundation.utility.AngleHelper;
// Can replace all Interpolated value classes
// InterpolatedChasingValue, InterpolatedValue, InterpolatedChasingAngle, InterpolatedAngle
public class LerpedFloat {
@ -82,7 +83,7 @@ public class LerpedFloat {
}
public boolean settled() {
return MathHelper.epsilonEquals(previousValue, value);
return MathHelper.epsilonEquals((double) previousValue, value);
}
public float getChaseTarget() {