mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-24 14:06:42 +01:00
The Belt is Lava
- Belts are now being avoided by pathfinding - Fixed Belt observers not detecting items - Lowered spacing between moved entities - Tweaked initial collision shape for diagonal belts, fixes entities not being picked up at certain spots - Fixed Glass Panes being usable on Belts and Crushing wheels (wall tag) - Fixed Pulley sections not moving entities properly - Fixed belt UVs not updating when textureAtlas changes, addresses #24
This commit is contained in:
parent
85042d460a
commit
0bded65338
7 changed files with 71 additions and 10 deletions
|
@ -4,6 +4,7 @@ import com.simibubi.create.foundation.utility.ColoredIndicatorRenderer;
|
||||||
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
|
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
|
||||||
import com.simibubi.create.modules.contraptions.receivers.constructs.ContraptionRenderer;
|
import com.simibubi.create.modules.contraptions.receivers.constructs.ContraptionRenderer;
|
||||||
import com.simibubi.create.modules.contraptions.receivers.constructs.MechanicalBearingTileEntityRenderer;
|
import com.simibubi.create.modules.contraptions.receivers.constructs.MechanicalBearingTileEntityRenderer;
|
||||||
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltModelAnimator;
|
||||||
|
|
||||||
import net.minecraft.client.resources.ReloadListener;
|
import net.minecraft.client.resources.ReloadListener;
|
||||||
import net.minecraft.profiler.IProfiler;
|
import net.minecraft.profiler.IProfiler;
|
||||||
|
@ -22,6 +23,7 @@ public class CachedBufferReloader extends ReloadListener<String> {
|
||||||
ContraptionRenderer.invalidateCache();
|
ContraptionRenderer.invalidateCache();
|
||||||
MechanicalBearingTileEntityRenderer.invalidateCache();
|
MechanicalBearingTileEntityRenderer.invalidateCache();
|
||||||
ColoredIndicatorRenderer.invalidateCache();
|
ColoredIndicatorRenderer.invalidateCache();
|
||||||
|
BeltModelAnimator.invalidateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,13 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.MobEntity;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.DyeColor;
|
import net.minecraft.item.DyeColor;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemUseContext;
|
import net.minecraft.item.ItemUseContext;
|
||||||
|
import net.minecraft.pathfinding.PathNodeType;
|
||||||
import net.minecraft.state.BooleanProperty;
|
import net.minecraft.state.BooleanProperty;
|
||||||
import net.minecraft.state.EnumProperty;
|
import net.minecraft.state.EnumProperty;
|
||||||
import net.minecraft.state.IProperty;
|
import net.minecraft.state.IProperty;
|
||||||
|
@ -38,6 +40,7 @@ import net.minecraft.util.IStringSerializable;
|
||||||
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.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
import net.minecraft.util.math.shapes.IBooleanFunction;
|
||||||
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.util.math.shapes.VoxelShapes;
|
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||||
|
@ -52,6 +55,7 @@ public class BeltBlock extends HorizontalKineticBlock implements IWithoutBlockIt
|
||||||
public static final IProperty<Slope> SLOPE = EnumProperty.create("slope", Slope.class);
|
public static final IProperty<Slope> SLOPE = EnumProperty.create("slope", Slope.class);
|
||||||
public static final IProperty<Part> PART = EnumProperty.create("part", Part.class);
|
public static final IProperty<Part> PART = EnumProperty.create("part", Part.class);
|
||||||
public static final BooleanProperty CASING = BooleanProperty.create("casing");
|
public static final BooleanProperty CASING = BooleanProperty.create("casing");
|
||||||
|
private final VoxelShape collisionMask = makeCuboidShape(0, 0, 0, 16, 19, 16);
|
||||||
|
|
||||||
public BeltBlock() {
|
public BeltBlock() {
|
||||||
super(Properties.from(Blocks.BROWN_WOOL));
|
super(Properties.from(Blocks.BROWN_WOOL));
|
||||||
|
@ -247,11 +251,33 @@ public class BeltBlock extends HorizontalKineticBlock implements IWithoutBlockIt
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos, MobEntity entity) {
|
||||||
|
return PathNodeType.DANGER_OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return VoxelShapes.or(BeltShapes.getShape(state), BeltShapes.getCasingShape(state));
|
return VoxelShapes.or(BeltShapes.getShape(state), BeltShapes.getCasingShape(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
|
||||||
|
ISelectionContext context) {
|
||||||
|
VoxelShape shape = getShape(state, worldIn, pos, context);
|
||||||
|
BeltTileEntity belt = (BeltTileEntity) worldIn.getTileEntity(pos);
|
||||||
|
if (belt == null || context.getEntity() == null)
|
||||||
|
return shape;
|
||||||
|
BeltTileEntity controller = (BeltTileEntity) worldIn.getTileEntity(belt.getController());
|
||||||
|
if (controller == null)
|
||||||
|
return shape;
|
||||||
|
if (controller.passengers == null || !controller.passengers.containsKey(context.getEntity())) {
|
||||||
|
return VoxelShapes.combine(collisionMask, shape, IBooleanFunction.AND);
|
||||||
|
}
|
||||||
|
|
||||||
|
return shape;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
return new BeltTileEntity();
|
return new BeltTileEntity();
|
||||||
|
|
|
@ -14,14 +14,12 @@ import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
class BeltModelAnimator extends BufferManipulator {
|
public class BeltModelAnimator extends BufferManipulator {
|
||||||
protected static TextureAtlasSprite beltTextures;
|
protected static TextureAtlasSprite beltTextures;
|
||||||
protected static TextureAtlasSprite originalTexture;
|
protected static TextureAtlasSprite originalTexture;
|
||||||
|
|
||||||
public BeltModelAnimator(ByteBuffer template) {
|
public BeltModelAnimator(ByteBuffer template) {
|
||||||
super(template);
|
super(template);
|
||||||
if (beltTextures == null)
|
|
||||||
initSprites();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSprites() {
|
private void initSprites() {
|
||||||
|
@ -46,6 +44,8 @@ class BeltModelAnimator extends BufferManipulator {
|
||||||
if (textureIndex < 0)
|
if (textureIndex < 0)
|
||||||
textureIndex += 16;
|
textureIndex += 16;
|
||||||
|
|
||||||
|
if (beltTextures == null)
|
||||||
|
initSprites();
|
||||||
textureOffsetX = beltTextures.getInterpolatedU((textureIndex % 4) * 4) - originalTexture.getMinU();
|
textureOffsetX = beltTextures.getInterpolatedU((textureIndex % 4) * 4) - originalTexture.getMinU();
|
||||||
textureOffsetY = beltTextures.getInterpolatedV((textureIndex / 4) * 4) - originalTexture.getMinV();
|
textureOffsetY = beltTextures.getInterpolatedV((textureIndex / 4) * 4) - originalTexture.getMinV();
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,7 @@ class BeltModelAnimator extends BufferManipulator {
|
||||||
int r = defaultColor ? 128 : (color >> 16) & 0xFF;
|
int r = defaultColor ? 128 : (color >> 16) & 0xFF;
|
||||||
|
|
||||||
for (int vertex = 0; vertex < vertexCount(original); vertex++) {
|
for (int vertex = 0; vertex < vertexCount(original); vertex++) {
|
||||||
putPos(mutable, vertex, getX(original, vertex) + x, getY(original, vertex) + y,
|
putPos(mutable, vertex, getX(original, vertex) + x, getY(original, vertex) + y, getZ(original, vertex) + z);
|
||||||
getZ(original, vertex) + z);
|
|
||||||
putLight(mutable, vertex, packedLightCoords);
|
putLight(mutable, vertex, packedLightCoords);
|
||||||
|
|
||||||
int bufferPosition = getBufferPosition(vertex);
|
int bufferPosition = getBufferPosition(vertex);
|
||||||
|
@ -80,4 +79,8 @@ class BeltModelAnimator extends BufferManipulator {
|
||||||
|
|
||||||
return mutable;
|
return mutable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void invalidateCache() {
|
||||||
|
beltTextures = null;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -86,7 +86,7 @@ public class BeltMovementHandler {
|
||||||
// Lock entities in place
|
// Lock entities in place
|
||||||
boolean isPlayer = entityIn instanceof PlayerEntity;
|
boolean isPlayer = entityIn instanceof PlayerEntity;
|
||||||
if (entityIn instanceof LivingEntity && !isPlayer) {
|
if (entityIn instanceof LivingEntity && !isPlayer) {
|
||||||
((LivingEntity) entityIn).addPotionEffect(new EffectInstance(Effects.SLOWNESS, 1, 9, false, false));
|
((LivingEntity) entityIn).addPotionEffect(new EffectInstance(Effects.SLOWNESS, 10, 1, false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
BeltTileEntity belt = (BeltTileEntity) te;
|
BeltTileEntity belt = (BeltTileEntity) te;
|
||||||
|
@ -115,7 +115,7 @@ public class BeltMovementHandler {
|
||||||
|
|
||||||
Part part = blockState.get(BeltBlock.PART);
|
Part part = blockState.get(BeltBlock.PART);
|
||||||
float top = 13 / 16f;
|
float top = 13 / 16f;
|
||||||
boolean onSlope = notHorizontal && (part == Part.MIDDLE
|
boolean onSlope = notHorizontal && (part == Part.MIDDLE || part == Part.PULLEY
|
||||||
|| part == (slope == Slope.UPWARD ? Part.END : Part.START) && entityIn.posY - pos.getY() < top
|
|| part == (slope == Slope.UPWARD ? Part.END : Part.START) && entityIn.posY - pos.getY() < top
|
||||||
|| part == (slope == Slope.UPWARD ? Part.START : Part.END) && entityIn.posY - pos.getY() > top);
|
|| part == (slope == Slope.UPWARD ? Part.START : Part.END) && entityIn.posY - pos.getY() > top);
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ public class BeltMovementHandler {
|
||||||
|
|
||||||
// Entity Collisions
|
// Entity Collisions
|
||||||
if (Math.abs(movementSpeed) < .5f) {
|
if (Math.abs(movementSpeed) < .5f) {
|
||||||
Vec3d checkDistance = movement.scale(2f).add(movement.normalize());
|
Vec3d checkDistance = movement.normalize().scale(0.5);
|
||||||
AxisAlignedBB bb = entityIn.getBoundingBox();
|
AxisAlignedBB bb = entityIn.getBoundingBox();
|
||||||
AxisAlignedBB checkBB = new AxisAlignedBB(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
|
AxisAlignedBB checkBB = new AxisAlignedBB(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
|
||||||
if (!world
|
if (!world
|
||||||
|
|
|
@ -150,4 +150,5 @@ public class BeltTileEntityRenderer extends TileEntityRenderer<BeltTileEntity> {
|
||||||
buffer.putBulkData(((BeltModelAnimator) KineticTileEntityRenderer.cachedBuffers
|
buffer.putBulkData(((BeltModelAnimator) KineticTileEntityRenderer.cachedBuffers
|
||||||
.get(te.getBlockState().with(BeltBlock.CASING, false))).getTransformed(te, x, y, z, te.color));
|
.get(te.getBlockState().with(BeltBlock.CASING, false))).getTransformed(te, x, y, z, te.color));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.I
|
||||||
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock;
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock;
|
||||||
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Part;
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Part;
|
||||||
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope;
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope;
|
||||||
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltInventory.TransportedItemStack;
|
||||||
import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity;
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity;
|
||||||
import com.simibubi.create.modules.logistics.block.IBlockWithFilter;
|
import com.simibubi.create.modules.logistics.block.IBlockWithFilter;
|
||||||
|
|
||||||
|
@ -180,6 +181,34 @@ public class EntityDetectorBlock extends HorizontalBlock
|
||||||
onAttachmentPlaced(worldIn, pos, state);
|
onAttachmentPlaced(worldIn, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean startProcessingItem(BeltTileEntity te, TransportedItemStack transported, BeltAttachmentState state) {
|
||||||
|
|
||||||
|
state.processingDuration = 0;
|
||||||
|
withTileEntityDo(te.getWorld(), state.attachmentPos, detectorTE -> {
|
||||||
|
ItemStack filter = detectorTE.getFilter();
|
||||||
|
if (filter.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Todo: Package filters
|
||||||
|
if (!ItemStack.areItemsEqual(transported.stack, filter)) {
|
||||||
|
state.processingDuration = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
World world = te.getWorld();
|
||||||
|
BlockState blockState = world.getBlockState(state.attachmentPos);
|
||||||
|
if (state.processingDuration == 0) {
|
||||||
|
world.setBlockState(state.attachmentPos, blockState.with(POWERED, true));
|
||||||
|
world.getPendingBlockTicks().scheduleTick(state.attachmentPos, this, 6);
|
||||||
|
world.notifyNeighborsOfStateChange(state.attachmentPos, this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processEntity(BeltTileEntity te, Entity entity, BeltAttachmentState state) {
|
public boolean processEntity(BeltTileEntity te, Entity entity, BeltAttachmentState state) {
|
||||||
|
|
||||||
|
@ -193,6 +222,8 @@ public class EntityDetectorBlock extends HorizontalBlock
|
||||||
ItemStack filter = detectorTE.getFilter();
|
ItemStack filter = detectorTE.getFilter();
|
||||||
if (filter.isEmpty())
|
if (filter.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Todo: Package filters
|
||||||
if (!(entity instanceof ItemEntity)
|
if (!(entity instanceof ItemEntity)
|
||||||
|| !ItemStack.areItemsEqual(((ItemEntity) entity).getItem(), filter)) {
|
|| !ItemStack.areItemsEqual(((ItemEntity) entity).getItem(), filter)) {
|
||||||
state.processingDuration = -1;
|
state.processingDuration = -1;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
{
|
{
|
||||||
"replace": false,
|
"replace": false,
|
||||||
"values": [
|
"values": [
|
||||||
"create:belt",
|
|
||||||
"create:crushing_wheel",
|
|
||||||
"create:limestone_wall",
|
"create:limestone_wall",
|
||||||
"create:limestone_bricks_wall",
|
"create:limestone_bricks_wall",
|
||||||
"create:weathered_limestone_wall",
|
"create:weathered_limestone_wall",
|
||||||
|
|
Loading…
Reference in a new issue