mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-24 14:06:42 +01:00
Compare, but do not fall
- Yet another attempt at preventing elevator fall damage - Flexcrate now has comparator output - Basin now has comparator output - Kinetic Gauges now have comparator output - Stress Gauge -> Stressometer
This commit is contained in:
parent
0e0148cbb6
commit
1edda9b564
13 changed files with 166 additions and 24 deletions
|
@ -11,6 +11,7 @@ import com.simibubi.create.foundation.item.AbstractToolItem;
|
||||||
import com.simibubi.create.foundation.packet.NbtPacket;
|
import com.simibubi.create.foundation.packet.NbtPacket;
|
||||||
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
||||||
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
||||||
|
import com.simibubi.create.modules.contraptions.components.contraptions.CancelPlayerFallPacket;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionStallPacket;
|
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionStallPacket;
|
||||||
import com.simibubi.create.modules.contraptions.relays.advanced.sequencer.ConfigureSequencedGearshiftPacket;
|
import com.simibubi.create.modules.contraptions.relays.advanced.sequencer.ConfigureSequencedGearshiftPacket;
|
||||||
import com.simibubi.create.modules.curiosities.symmetry.SymmetryEffectPacket;
|
import com.simibubi.create.modules.curiosities.symmetry.SymmetryEffectPacket;
|
||||||
|
@ -41,6 +42,7 @@ public enum AllPackets {
|
||||||
CONFIGURE_FILTER(FilterScreenPacket.class, FilterScreenPacket::new),
|
CONFIGURE_FILTER(FilterScreenPacket.class, FilterScreenPacket::new),
|
||||||
CONFIGURE_FILTERING_AMOUNT(FilteringCountUpdatePacket.class, FilteringCountUpdatePacket::new),
|
CONFIGURE_FILTERING_AMOUNT(FilteringCountUpdatePacket.class, FilteringCountUpdatePacket::new),
|
||||||
CONFIGURE_SCROLLABLE(ScrollValueUpdatePacket.class, ScrollValueUpdatePacket::new),
|
CONFIGURE_SCROLLABLE(ScrollValueUpdatePacket.class, ScrollValueUpdatePacket::new),
|
||||||
|
CANCEL_FALL(CancelPlayerFallPacket.class, CancelPlayerFallPacket::new),
|
||||||
|
|
||||||
// Server to Client
|
// Server to Client
|
||||||
SYMMETRY_EFFECT(SymmetryEffectPacket.class, SymmetryEffectPacket::new),
|
SYMMETRY_EFFECT(SymmetryEffectPacket.class, SymmetryEffectPacket::new),
|
||||||
|
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
@ -13,6 +15,7 @@ import com.simibubi.create.config.AllConfigs;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
|
@ -55,6 +58,33 @@ public class ItemHelper {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int calcRedstoneFromInventory(@Nullable IItemHandler inv) {
|
||||||
|
if (inv == null)
|
||||||
|
return 0;
|
||||||
|
int i = 0;
|
||||||
|
float f = 0.0F;
|
||||||
|
int totalSlots = inv.getSlots();
|
||||||
|
|
||||||
|
for (int j = 0; j < inv.getSlots(); ++j) {
|
||||||
|
int slotLimit = inv.getSlotLimit(j);
|
||||||
|
if (slotLimit == 0) {
|
||||||
|
totalSlots--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ItemStack itemstack = inv.getStackInSlot(j);
|
||||||
|
if (!itemstack.isEmpty()) {
|
||||||
|
f += (float) itemstack.getCount() / (float) Math.min(slotLimit, itemstack.getMaxStackSize());
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalSlots == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
f = f / totalSlots;
|
||||||
|
return MathHelper.floor(f * 14.0F) + (i > 0 ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Pair<Ingredient, MutableInt>> condenseIngredients(NonNullList<Ingredient> recipeIngredients) {
|
public static List<Pair<Ingredient, MutableInt>> condenseIngredients(NonNullList<Ingredient> recipeIngredients) {
|
||||||
List<Pair<Ingredient, MutableInt>> actualIngredients = new ArrayList<>();
|
List<Pair<Ingredient, MutableInt>> actualIngredients = new ArrayList<>();
|
||||||
Ingredients: for (Ingredient igd : recipeIngredients) {
|
Ingredients: for (Ingredient igd : recipeIngredients) {
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.simibubi.create.modules.contraptions.components.contraptions;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||||
|
|
||||||
|
public class CancelPlayerFallPacket extends SimplePacketBase {
|
||||||
|
|
||||||
|
public CancelPlayerFallPacket() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CancelPlayerFallPacket(PacketBuffer buffer) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(PacketBuffer buffer) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Supplier<Context> context) {
|
||||||
|
context.get().enqueueWork(() -> {
|
||||||
|
ServerPlayerEntity sender = context.get().getSender();
|
||||||
|
sender.fall(sender.fallDistance, 1.0F);
|
||||||
|
sender.fallDistance = 0;
|
||||||
|
sender.onGround = true;
|
||||||
|
});
|
||||||
|
context.get().setPacketHandled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import com.simibubi.create.modules.contraptions.components.actors.BlockBreakingM
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.material.PushReaction;
|
import net.minecraft.block.material.PushReaction;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.MoverType;
|
import net.minecraft.entity.MoverType;
|
||||||
|
@ -23,10 +24,14 @@ 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.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.gen.feature.template.Template.BlockInfo;
|
import net.minecraft.world.gen.feature.template.Template.BlockInfo;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
|
|
||||||
public class ContraptionCollider {
|
public class ContraptionCollider {
|
||||||
|
|
||||||
static Map<Object, AxisAlignedBB> renderedBBs = new HashMap<>();
|
static Map<Object, AxisAlignedBB> renderedBBs = new HashMap<>();
|
||||||
|
public static boolean wasClientPlayerGrounded;
|
||||||
|
|
||||||
public static void collideEntities(ContraptionEntity contraptionEntity) {
|
public static void collideEntities(ContraptionEntity contraptionEntity) {
|
||||||
if (Contraption.isFrozen())
|
if (Contraption.isFrozen())
|
||||||
|
@ -71,6 +76,7 @@ public class ContraptionCollider {
|
||||||
entity.fall(entity.fallDistance, 1);
|
entity.fall(entity.fallDistance, 1);
|
||||||
entity.fallDistance = 0;
|
entity.fallDistance = 0;
|
||||||
entity.onGround = true;
|
entity.onGround = true;
|
||||||
|
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> checkForClientPlayerCollision(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof PlayerEntity && !world.isRemote)
|
if (entity instanceof PlayerEntity && !world.isRemote)
|
||||||
|
@ -82,6 +88,13 @@ public class ContraptionCollider {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
private static void checkForClientPlayerCollision(Entity entity) {
|
||||||
|
if (entity != Minecraft.getInstance().player)
|
||||||
|
return;
|
||||||
|
wasClientPlayerGrounded = true;
|
||||||
|
}
|
||||||
|
|
||||||
public static void pushEntityOutOfShape(Entity entity, VoxelShape voxelShape, Vec3d positionOffset,
|
public static void pushEntityOutOfShape(Entity entity, VoxelShape voxelShape, Vec3d positionOffset,
|
||||||
Vec3d shapeMotion) {
|
Vec3d shapeMotion) {
|
||||||
AxisAlignedBB entityBB = entity.getBoundingBox().offset(positionOffset);
|
AxisAlignedBB entityBB = entity.getBoundingBox().offset(positionOffset);
|
||||||
|
|
|
@ -2,12 +2,15 @@ package com.simibubi.create.modules.contraptions.components.contraptions.piston;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllPackets;
|
||||||
import com.simibubi.create.foundation.behaviour.ValueBoxTransform;
|
import com.simibubi.create.foundation.behaviour.ValueBoxTransform;
|
||||||
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
|
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
|
||||||
import com.simibubi.create.foundation.behaviour.scrollvalue.ScrollOptionBehaviour;
|
import com.simibubi.create.foundation.behaviour.scrollvalue.ScrollOptionBehaviour;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
||||||
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
||||||
|
import com.simibubi.create.modules.contraptions.components.contraptions.CancelPlayerFallPacket;
|
||||||
|
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionCollider;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionEntity;
|
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionEntity;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.IControlContraption;
|
import com.simibubi.create.modules.contraptions.components.contraptions.IControlContraption;
|
||||||
|
|
||||||
|
@ -202,12 +205,20 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity impleme
|
||||||
|
|
||||||
protected abstract ValueBoxTransform getMovementModeSlot();
|
protected abstract ValueBoxTransform getMovementModeSlot();
|
||||||
|
|
||||||
protected abstract void visitNewPosition();
|
|
||||||
|
|
||||||
protected abstract Vec3d toMotionVector(float speed);
|
protected abstract Vec3d toMotionVector(float speed);
|
||||||
|
|
||||||
protected abstract Vec3d toPosition(float offset);
|
protected abstract Vec3d toPosition(float offset);
|
||||||
|
|
||||||
|
protected void visitNewPosition() {
|
||||||
|
if (!world.isRemote)
|
||||||
|
return;
|
||||||
|
if (!ContraptionCollider.wasClientPlayerGrounded)
|
||||||
|
return;
|
||||||
|
// Send falldamage-cancel for the colliding player
|
||||||
|
ContraptionCollider.wasClientPlayerGrounded = false;
|
||||||
|
AllPackets.channel.sendToServer(new CancelPlayerFallPacket());
|
||||||
|
}
|
||||||
|
|
||||||
protected void tryDisassemble() {
|
protected void tryDisassemble() {
|
||||||
if (removed) {
|
if (removed) {
|
||||||
disassemble();
|
disassemble();
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.modules.contraptions.components.contraptions.piston;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllTileEntities;
|
import com.simibubi.create.AllTileEntities;
|
||||||
import com.simibubi.create.foundation.behaviour.ValueBoxTransform;
|
import com.simibubi.create.foundation.behaviour.ValueBoxTransform;
|
||||||
import com.simibubi.create.foundation.utility.Debug;
|
|
||||||
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
||||||
import com.simibubi.create.modules.contraptions.base.IRotate;
|
import com.simibubi.create.modules.contraptions.base.IRotate;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionCollider;
|
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionCollider;
|
||||||
|
|
|
@ -121,6 +121,7 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void visitNewPosition() {
|
protected void visitNewPosition() {
|
||||||
|
super.visitNewPosition();
|
||||||
if (world.isRemote)
|
if (world.isRemote)
|
||||||
return;
|
return;
|
||||||
if (movedContraption != null)
|
if (movedContraption != null)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.processing;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.block.IWithTileEntity;
|
import com.simibubi.create.foundation.block.IWithTileEntity;
|
||||||
|
import com.simibubi.create.foundation.item.ItemHelper;
|
||||||
import com.simibubi.create.foundation.utility.AllShapes;
|
import com.simibubi.create.foundation.utility.AllShapes;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -40,12 +41,12 @@ public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
return new BasinTileEntity();
|
return new BasinTileEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PushReaction getPushReaction(BlockState state) {
|
public PushReaction getPushReaction(BlockState state) {
|
||||||
return PushReaction.BLOCK;
|
return PushReaction.BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
|
@ -57,11 +58,11 @@ public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity
|
||||||
BasinTileEntity te = (BasinTileEntity) worldIn.getTileEntity(pos);
|
BasinTileEntity te = (BasinTileEntity) worldIn.getTileEntity(pos);
|
||||||
IItemHandlerModifiable inv = te.inventory.orElse(new ItemStackHandler(1));
|
IItemHandlerModifiable inv = te.inventory.orElse(new ItemStackHandler(1));
|
||||||
for (int slot = 0; slot < inv.getSlots(); slot++) {
|
for (int slot = 0; slot < inv.getSlots(); slot++) {
|
||||||
player.inventory.placeItemBackInInventory(worldIn, inv.getStackInSlot(slot));
|
player.inventory.placeItemBackInInventory(worldIn, inv.getStackInSlot(slot));
|
||||||
inv.setStackInSlot(slot, ItemStack.EMPTY);
|
inv.setStackInSlot(slot, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
te.onEmptied();
|
te.onEmptied();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,12 +79,12 @@ public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity
|
||||||
BasinTileEntity te = (BasinTileEntity) worldIn.getTileEntity(entityIn.getPosition());
|
BasinTileEntity te = (BasinTileEntity) worldIn.getTileEntity(entityIn.getPosition());
|
||||||
ItemEntity itemEntity = (ItemEntity) entityIn;
|
ItemEntity itemEntity = (ItemEntity) entityIn;
|
||||||
ItemStack insertItem = ItemHandlerHelper.insertItem(te.inputInventory, itemEntity.getItem().copy(), false);
|
ItemStack insertItem = ItemHandlerHelper.insertItem(te.inputInventory, itemEntity.getItem().copy(), false);
|
||||||
|
|
||||||
if (insertItem.isEmpty()) {
|
if (insertItem.isEmpty()) {
|
||||||
itemEntity.remove();
|
itemEntity.remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
itemEntity.setItem(insertItem);
|
itemEntity.setItem(insertItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -92,7 +93,7 @@ public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return AllShapes.BASIN_BLOCK_SHAPE;
|
return AllShapes.BASIN_BLOCK_SHAPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
if (worldIn.getTileEntity(pos) == null)
|
if (worldIn.getTileEntity(pos) == null)
|
||||||
|
@ -101,8 +102,7 @@ public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity
|
||||||
BasinTileEntity te = (BasinTileEntity) worldIn.getTileEntity(pos);
|
BasinTileEntity te = (BasinTileEntity) worldIn.getTileEntity(pos);
|
||||||
IItemHandlerModifiable inv = te.inventory.orElse(new ItemStackHandler(1));
|
IItemHandlerModifiable inv = te.inventory.orElse(new ItemStackHandler(1));
|
||||||
for (int slot = 0; slot < inv.getSlots(); slot++) {
|
for (int slot = 0; slot < inv.getSlots(); slot++) {
|
||||||
InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(),
|
InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), inv.getStackInSlot(slot));
|
||||||
inv.getStackInSlot(slot));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
|
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
|
||||||
|
@ -116,4 +116,19 @@ public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasComparatorInputOverride(BlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) {
|
||||||
|
TileEntity te = worldIn.getTileEntity(pos);
|
||||||
|
if (te instanceof BasinTileEntity) {
|
||||||
|
BasinTileEntity basinTileEntity = (BasinTileEntity) te;
|
||||||
|
return ItemHelper.calcRedstoneFromInventory(basinTileEntity.inputInventory);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.Direction.AxisDirection;
|
import net.minecraft.util.Direction.AxisDirection;
|
||||||
import net.minecraft.util.IStringSerializable;
|
import net.minecraft.util.IStringSerializable;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
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;
|
||||||
|
@ -157,4 +158,19 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
|
||||||
return GAUGE.get(state.get(FACING), state.get(AXIS_ALONG_FIRST_COORDINATE));
|
return GAUGE.get(state.get(FACING), state.get(AXIS_ALONG_FIRST_COORDINATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasComparatorInputOverride(BlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) {
|
||||||
|
TileEntity te = worldIn.getTileEntity(pos);
|
||||||
|
if (te instanceof GaugeTileEntity) {
|
||||||
|
GaugeTileEntity gaugeTileEntity = (GaugeTileEntity) te;
|
||||||
|
return MathHelper.ceil(MathHelper.clamp(gaugeTileEntity.dialTarget * 14, 0, 15));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity {
|
||||||
} else {
|
} else {
|
||||||
dialTarget = MathHelper.lerp((speed - fast) / (max - fast), .75f, 1.125f);
|
dialTarget = MathHelper.lerp((speed - fast) / (max - fast), .75f, 1.125f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,21 +33,24 @@ public class StressGaugeTileEntity extends GaugeTileEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
sendData();
|
sendData();
|
||||||
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSpeedChanged(float prevSpeed) {
|
public void onSpeedChanged(float prevSpeed) {
|
||||||
super.onSpeedChanged(prevSpeed);
|
super.onSpeedChanged(prevSpeed);
|
||||||
if (getSpeed() == 0)
|
if (getSpeed() == 0) {
|
||||||
dialTarget = 0;
|
dialTarget = 0;
|
||||||
else
|
markDirty();
|
||||||
updateStressFromNetwork(capacity, stress);
|
return;
|
||||||
|
}
|
||||||
|
updateStressFromNetwork(capacity, stress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getNetworkStress() {
|
public float getNetworkStress() {
|
||||||
return stress;
|
return stress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getNetworkCapacity() {
|
public float getNetworkCapacity() {
|
||||||
return capacity;
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.modules.logistics.block.inventories;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||||
|
import com.simibubi.create.foundation.item.ItemHelper;
|
||||||
import com.simibubi.create.foundation.utility.AllShapes;
|
import com.simibubi.create.foundation.utility.AllShapes;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -160,4 +161,19 @@ public class FlexcrateBlock extends ProperDirectionalBlock {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasComparatorInputOverride(BlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) {
|
||||||
|
TileEntity te = worldIn.getTileEntity(pos);
|
||||||
|
if (te instanceof FlexcrateTileEntity) {
|
||||||
|
FlexcrateTileEntity flexcrateTileEntity = (FlexcrateTileEntity) te;
|
||||||
|
return ItemHelper.calcRedstoneFromInventory(flexcrateTileEntity.inventory);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
"block.create.flywheel": "Flywheel",
|
"block.create.flywheel": "Flywheel",
|
||||||
"block.create.furnace_engine": "Furnace Engine",
|
"block.create.furnace_engine": "Furnace Engine",
|
||||||
"block.create.speed_gauge": "Speedometer",
|
"block.create.speed_gauge": "Speedometer",
|
||||||
"block.create.stress_gauge": "Stress Gauge",
|
"block.create.stress_gauge": "Stressometer",
|
||||||
"block.create.cart_assembler": "Cart Assembler",
|
"block.create.cart_assembler": "Cart Assembler",
|
||||||
"block.create.analog_lever": "Analog Lever",
|
"block.create.analog_lever": "Analog Lever",
|
||||||
"block.create.rotation_speed_controller": "Rotation Speed Controller",
|
"block.create.rotation_speed_controller": "Rotation Speed Controller",
|
||||||
|
@ -887,7 +887,7 @@
|
||||||
"block.create.mechanical_mixer.tooltip.behaviour3": "Starts to _compact_ _items_ in the basin whenever all necessary ingredients are present.",
|
"block.create.mechanical_mixer.tooltip.behaviour3": "Starts to _compact_ _items_ in the basin whenever all necessary ingredients are present.",
|
||||||
|
|
||||||
"block.create.basin.tooltip": "BASIN",
|
"block.create.basin.tooltip": "BASIN",
|
||||||
"block.create.basin.tooltip.summary": "A handy _item_ _container_ used in processing with the _Mechanical_ _Mixer_ and the _Mechanical_ _Press_.",
|
"block.create.basin.tooltip.summary": "A handy _item_ _container_ used in processing with the _Mechanical_ _Mixer_ and the _Mechanical_ _Press_. Supports _Redstone_ _Comparators_.",
|
||||||
|
|
||||||
"block.create.mechanical_mixer.tooltip": "MECHANICAL MIXER",
|
"block.create.mechanical_mixer.tooltip": "MECHANICAL MIXER",
|
||||||
"block.create.mechanical_mixer.tooltip.summary": "A kinetic whisk for applying any shapeless crafting recipes to items beneath it. Requires constant _Rotational_ _Force_ and a _Basin_ placed below (with a gap in between).",
|
"block.create.mechanical_mixer.tooltip.summary": "A kinetic whisk for applying any shapeless crafting recipes to items beneath it. Requires constant _Rotational_ _Force_ and a _Basin_ placed below (with a gap in between).",
|
||||||
|
@ -1034,7 +1034,7 @@
|
||||||
"block.create.contact.tooltip.behaviour2": "Triggers all stationary Contacts it passes.",
|
"block.create.contact.tooltip.behaviour2": "Triggers all stationary Contacts it passes.",
|
||||||
|
|
||||||
"block.create.flexcrate.tooltip": "ADJUSTABLE CRATE",
|
"block.create.flexcrate.tooltip": "ADJUSTABLE CRATE",
|
||||||
"block.create.flexcrate.tooltip.summary": "This _Storage_ _Container_ allows Manual control over its capacity. It can hold up to _16_ _Stacks_ of any Item.",
|
"block.create.flexcrate.tooltip.summary": "This _Storage_ _Container_ allows Manual control over its capacity. It can hold up to _16_ _Stacks_ of any Item. Supports _Redstone_ _Comparators_.",
|
||||||
"block.create.flexcrate.tooltip.control1": "When R-Clicked",
|
"block.create.flexcrate.tooltip.control1": "When R-Clicked",
|
||||||
"block.create.flexcrate.tooltip.action1": "Opens the _Interface_.",
|
"block.create.flexcrate.tooltip.action1": "Opens the _Interface_.",
|
||||||
|
|
||||||
|
@ -1128,12 +1128,12 @@
|
||||||
"block.create.redstone_latch.tooltip.summary": "A lever that can be controlled by _Redstone_ _Signals_. A signal on the _back_ _enables_ it, a signal from the _side_ _will_ _reset_ it.",
|
"block.create.redstone_latch.tooltip.summary": "A lever that can be controlled by _Redstone_ _Signals_. A signal on the _back_ _enables_ it, a signal from the _side_ _will_ _reset_ it.",
|
||||||
|
|
||||||
"block.create.speed_gauge.tooltip": "SPEEDOMETER",
|
"block.create.speed_gauge.tooltip": "SPEEDOMETER",
|
||||||
"block.create.speed_gauge.tooltip.summary": "Measures and displays the _rotational_ _speed_ of attached kinetic components.",
|
"block.create.speed_gauge.tooltip.summary": "Measures and displays the _rotational_ _speed_ of attached kinetic components. Supports _Redstone_ _Comparators_.",
|
||||||
"block.create.speed_gauge.tooltip.condition1": "When Rotated",
|
"block.create.speed_gauge.tooltip.condition1": "When Rotated",
|
||||||
"block.create.speed_gauge.tooltip.behaviour1": "Indicates a color corresponding to the level of speed. _Green_ indicates Slow, _Blue_ Moderate and _Purple_ Fast rotation. Some mechanical components require a sufficient level of speed to work properly.",
|
"block.create.speed_gauge.tooltip.behaviour1": "Indicates a color corresponding to the level of speed. _Green_ indicates Slow, _Blue_ Moderate and _Purple_ Fast rotation. Some mechanical components require a sufficient level of speed to work properly.",
|
||||||
|
|
||||||
"block.create.stress_gauge.tooltip": "STRESS GAUGE",
|
"block.create.stress_gauge.tooltip": "STRESSOMETER",
|
||||||
"block.create.stress_gauge.tooltip.summary": "Measures and displays the _overall_ _stress_ of the attached kinetic network.",
|
"block.create.stress_gauge.tooltip.summary": "Measures and displays the _overall_ _stress_ of the attached kinetic network. Supports _Redstone_ _Comparators_.",
|
||||||
"block.create.stress_gauge.tooltip.condition1": "When Rotated",
|
"block.create.stress_gauge.tooltip.condition1": "When Rotated",
|
||||||
"block.create.stress_gauge.tooltip.behaviour1": "Indicates a color corresponding to the level of stress. _Over-stressed_ _networks_ will cease to move. Stress can be relieved by adding more _rotational_ _sources_ to the network.",
|
"block.create.stress_gauge.tooltip.behaviour1": "Indicates a color corresponding to the level of stress. _Over-stressed_ _networks_ will cease to move. Stress can be relieved by adding more _rotational_ _sources_ to the network.",
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue