- Fixed extractors looking for belt inventories too eagerly, adresses #327
- Slightly refactored Extendo Grip handlers
- Fixed missing particle texture of Extendo Grips
- Fixed crash when assembled minecarts pick up the block below their assembler
- Ploughs no longer break blocks if farmland is below them, adresses #345
- Fixed Schematic tools placing lit furnaces, adresses #342
- Super glue can no longer be removed while inbetween two blocks, adresses #341
- Added a safety check in RotationPropagation, addresses #340
This commit is contained in:
simibubi 2020-06-07 22:40:27 +02:00
parent dbb2a74839
commit c5e783207f
13 changed files with 119 additions and 89 deletions

View file

@ -17,6 +17,7 @@ import com.simibubi.create.content.contraptions.relays.encased.SplitShaftTileEnt
import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity;
import com.simibubi.create.foundation.config.AllConfigs;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
@ -40,8 +41,14 @@ public class RotationPropagator {
private static float getRotationSpeedModifier(KineticTileEntity from, KineticTileEntity to) {
final BlockState stateFrom = from.getBlockState();
final BlockState stateTo = to.getBlockState();
final IRotate definitionFrom = (IRotate) stateFrom.getBlock();
final IRotate definitionTo = (IRotate) stateTo.getBlock();
Block fromBlock = stateFrom.getBlock();
Block toBlock = stateTo.getBlock();
if (!(fromBlock instanceof IRotate && toBlock instanceof IRotate))
return 0;
final IRotate definitionFrom = (IRotate) fromBlock;
final IRotate definitionTo = (IRotate) toBlock;
final BlockPos diff = to.getPos()
.subtract(from.getPos());
final Direction direction = Direction.getFacingFromVector(diff.getX(), diff.getY(), diff.getZ());
@ -75,7 +82,7 @@ public class RotationPropagator {
}
// Attached Encased Belts
if (stateFrom.getBlock() instanceof EncasedBeltBlock && stateTo.getBlock() instanceof EncasedBeltBlock) {
if (fromBlock instanceof EncasedBeltBlock && toBlock instanceof EncasedBeltBlock) {
boolean connected = EncasedBeltBlock.areBlocksConnected(stateFrom, stateTo, direction);
return connected ? EncasedBeltBlock.getRotationSpeedModifier(from, to) : 0;
}

View file

@ -155,9 +155,9 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour {
data.remove("Progress");
data.remove("TicksUntilNextProgress");
data.remove("BreakingPos");
context.stall = false;
world.sendBlockBreakProgress(id, breakingPos, -1);
}
context.stall = false;
return;
}

View file

@ -7,6 +7,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.block.FlowingFluidBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
@ -26,8 +27,8 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
@Override
public boolean isActive(MovementContext context) {
return !VecHelper
.isVecPointingTowards(context.relativeMotion, context.state.get(HORIZONTAL_FACING).getOpposite());
return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.get(HORIZONTAL_FACING)
.getOpposite());
}
@Override
@ -57,7 +58,8 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
@Override
public Vec3d getActiveAreaOffset(MovementContext context) {
return new Vec3d(context.state.get(HORIZONTAL_FACING).getDirectionVec()).scale(.45);
return new Vec3d(context.state.get(HORIZONTAL_FACING)
.getDirectionVec()).scale(.45);
}
@Override
@ -67,8 +69,10 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
@Override
public boolean canBreak(World world, BlockPos breakingPos, BlockState state) {
return state.getCollisionShape(world, breakingPos).isEmpty()
&& !(state.getBlock() instanceof FlowingFluidBlock);
return state.getCollisionShape(world, breakingPos)
.isEmpty() && !(state.getBlock() instanceof FlowingFluidBlock)
&& !(world.getBlockState(breakingPos.down())
.getBlock() instanceof FarmlandBlock);
}
@Override

View file

@ -64,8 +64,6 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
return super.insertItem(slot, stack, simulate);
};
protected void onContentsChanged(int slot) {
if (!getStackInSlot(slot).isEmpty() && phase == Phase.IDLE)
checkCompletedRecipe(false);
@ -82,7 +80,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
protected Phase phase;
protected int countDown;
protected boolean covered;
private boolean wasPoweredBefore = true;
protected boolean wasPoweredBefore;
protected GroupedItems groupedItemsBeforeCraft; // for rendering on client
private InsertingBehaviour inserting;
@ -93,6 +91,9 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
setLazyTickRate(20);
phase = Phase.IDLE;
groupedItemsBeforeCraft = new GroupedItems();
// Does not get serialized due to active checking in tick
wasPoweredBefore = true;
}
@Override
@ -422,11 +423,13 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
}
public boolean craftingItemPresent() {
return !inventory.getStackInSlot(0).isEmpty();
return !inventory.getStackInSlot(0)
.isEmpty();
}
public boolean craftingItemOrCoverPresent() {
return !inventory.getStackInSlot(0).isEmpty() || covered;
return !inventory.getStackInSlot(0)
.isEmpty() || covered;
}
protected void checkCompletedRecipe(boolean poweredStart) {
@ -434,8 +437,10 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
return;
if (world.isRemote)
return;
List<MechanicalCrafterTileEntity> chain =
RecipeGridHandler.getAllCraftersOfChainIf(this, poweredStart ? MechanicalCrafterTileEntity::craftingItemPresent : MechanicalCrafterTileEntity::craftingItemOrCoverPresent, poweredStart);
List<MechanicalCrafterTileEntity> chain = RecipeGridHandler.getAllCraftersOfChainIf(this,
poweredStart ? MechanicalCrafterTileEntity::craftingItemPresent
: MechanicalCrafterTileEntity::craftingItemOrCoverPresent,
poweredStart);
if (chain == null)
return;
chain.forEach(MechanicalCrafterTileEntity::begin);

View file

@ -39,7 +39,6 @@ public class RecipeGridHandler {
return getAllCraftersOfChainIf(root, test, false);
}
public static List<MechanicalCrafterTileEntity> getAllCraftersOfChainIf(MechanicalCrafterTileEntity root,
Predicate<MechanicalCrafterTileEntity> test, boolean poweredStart) {
List<MechanicalCrafterTileEntity> crafters = new ArrayList<>();
@ -62,7 +61,8 @@ public class RecipeGridHandler {
empty = true;
else
allEmpty = false;
if(poweredStart && current.getWorld().isBlockPowered(current.getPos()))
if (poweredStart && current.getWorld()
.isBlockPowered(current.getPos()))
powered = true;
crafters.add(current);

View file

@ -69,8 +69,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
}
@Override
protected void registerData() {
}
protected void registerData() {}
public int getWidthPixels() {
return 12;
@ -95,11 +94,13 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
protected void updateFacingWithBoundingBox() {
Validate.notNull(getFacingDirection());
if (getFacingDirection().getAxis().isHorizontal()) {
if (getFacingDirection().getAxis()
.isHorizontal()) {
this.rotationPitch = 0.0F;
this.rotationYaw = getFacingDirection().getHorizontalIndex() * 90;
} else {
this.rotationPitch = -90 * getFacingDirection().getAxisDirection().getOffset();
this.rotationPitch = -90 * getFacingDirection().getAxisDirection()
.getOffset();
this.rotationYaw = 0.0F;
}
@ -118,7 +119,8 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
double w = getWidthPixels();
double h = getHeightPixels();
double l = getWidthPixels();
Axis axis = this.getFacingDirection().getAxis();
Axis axis = this.getFacingDirection()
.getAxis();
double depth = 2 - 1 / 128f;
switch (axis) {
@ -151,14 +153,25 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
}
public boolean isVisible() {
if (!isAlive())
return false;
BlockPos pos = hangingPosition;
BlockPos pos2 = pos.offset(getFacingDirection().getOpposite());
return isValidFace(world, pos2, getFacingDirection()) != isValidFace(world, pos,
getFacingDirection().getOpposite());
}
public boolean onValidSurface() {
BlockPos pos = hangingPosition;
BlockPos pos2 = hangingPosition.offset(getFacingDirection().getOpposite());
if (!world.isAreaLoaded(pos, 0) || !world.isAreaLoaded(pos2, 0))
return true;
if (!isValidFace(world, pos2, getFacingDirection()) && !isValidFace(world, pos, getFacingDirection().getOpposite()))
if (!isValidFace(world, pos2, getFacingDirection())
&& !isValidFace(world, pos, getFacingDirection().getOpposite()))
return false;
return world.getEntitiesInAABBexcluding(this, getBoundingBox(), e -> e instanceof SuperGlueEntity).isEmpty();
return world.getEntitiesInAABBexcluding(this, getBoundingBox(), e -> e instanceof SuperGlueEntity)
.isEmpty();
}
public static boolean isValidFace(World world, BlockPos pos, Direction direction) {
@ -193,7 +206,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
public boolean attackEntityFrom(DamageSource source, float amount) {
if (this.isInvulnerableTo(source))
return false;
if (isAlive() && !world.isRemote) {
if (isAlive() && !world.isRemote && isVisible()) {
remove();
markVelocityChanged();
onBroken(source.getTrueSource());
@ -268,7 +281,8 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
@Override
public void writeAdditional(CompoundNBT compound) {
compound.putByte("Facing", (byte) this.getFacingDirection().getIndex());
compound.putByte("Facing", (byte) this.getFacingDirection()
.getIndex());
BlockPos blockpos = this.getHangingPosition();
compound.putInt("TileX", blockpos.getX());
compound.putInt("TileY", blockpos.getY());
@ -285,8 +299,10 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
@Override
public ItemEntity entityDropItem(ItemStack stack, float yOffset) {
float xOffset = (float) this.getFacingDirection().getXOffset() * 0.15F;
float zOffset = (float) this.getFacingDirection().getZOffset() * 0.15F;
float xOffset = (float) this.getFacingDirection()
.getXOffset() * 0.15F;
float zOffset = (float) this.getFacingDirection()
.getZOffset() * 0.15F;
ItemEntity itementity =
new ItemEntity(this.world, this.getX() + xOffset, this.getY() + yOffset, this.getZ() + zOffset, stack);
itementity.setDefaultPickupDelay();
@ -308,7 +324,8 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
@Override
public float getRotatedYaw(Rotation transformRotation) {
if (this.getFacingDirection().getAxis() != Direction.Axis.Y) {
if (this.getFacingDirection()
.getAxis() != Direction.Axis.Y) {
switch (transformRotation) {
case CLOCKWISE_180:
facingDirection = facingDirection.getOpposite();
@ -350,12 +367,10 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
}
@Override
public void onStruckByLightning(LightningBoltEntity lightningBolt) {
}
public void onStruckByLightning(LightningBoltEntity lightningBolt) {}
@Override
public void recalculateSize() {
}
public void recalculateSize() {}
public static EntityType.Builder<?> build(EntityType.Builder<?> builder) {
@SuppressWarnings("unchecked")

View file

@ -51,7 +51,7 @@ public class SuperGlueRenderer extends EntityRenderer<SuperGlueEntity> {
super.render(entity, p_225623_2_, p_225623_3_, ms, buffer, light);
PlayerEntity player = Minecraft.getInstance().player;
boolean visible = isVisible(entity);
boolean visible = entity.isVisible();
boolean holdingGlue = AllItems.SUPER_GLUE.isIn(player.getHeldItemMainhand())
|| AllItems.SUPER_GLUE.isIn(player.getHeldItemOffhand());
@ -83,17 +83,6 @@ public class SuperGlueRenderer extends EntityRenderer<SuperGlueEntity> {
ms.pop();
}
private boolean isVisible(SuperGlueEntity entity) {
if (!entity.isAlive())
return false;
BlockPos pos = entity.hangingPosition;
BlockPos pos2 = pos.offset(entity.getFacingDirection()
.getOpposite());
return SuperGlueEntity.isValidFace(entity.world, pos2, entity.getFacingDirection()) != SuperGlueEntity
.isValidFace(entity.world, pos, entity.getFacingDirection()
.getOpposite());
}
private void initQuads() {
Vec3d diff = new Vec3d(Direction.SOUTH.getDirectionVec());
Vec3d extension = diff.normalize()

View file

@ -29,6 +29,10 @@ public class MountedContraption extends Contraption {
public CartMovementMode rotationMode;
public MountedContraption() {
rotationMode = CartMovementMode.ROTATE;
}
@Override
protected AllContraptionTypes getType() {
return AllContraptionTypes.MOUNTED;
@ -47,9 +51,8 @@ public class MountedContraption extends Contraption {
return null;
Axis axis = state.get(RAIL_SHAPE) == RailShape.EAST_WEST ? Axis.X : Axis.Z;
contraption.add(pos, Pair.of(new BlockInfo(pos,
AllBlocks.MINECART_ANCHOR.getDefaultState().with(BlockStateProperties.HORIZONTAL_AXIS, axis),
null), null));
contraption.add(pos, Pair.of(new BlockInfo(pos, AllBlocks.MINECART_ANCHOR.getDefaultState()
.with(BlockStateProperties.HORIZONTAL_AXIS, axis), null), null));
contraption.removeBlocksFromWorld(world, BlockPos.ZERO);
contraption.initActors(world);
contraption.expandBoundsAroundAxis(Axis.Y);

View file

@ -16,6 +16,9 @@ import net.minecraft.util.math.Vec3d;
public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer<ExtendoGripModel> {
private static final Vec3d rotationOffset = new Vec3d(0, 1 / 2f, 1 / 2f);
private static final Vec3d cogRotationOffset = new Vec3d(0, 1 / 16f, 0);
@Override
protected void render(ItemStack stack, ExtendoGripModel model, PartialItemModelRenderer renderer, MatrixStack ms,
IRenderTypeBuffer buffer, int light, int overlay) {
@ -30,8 +33,6 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer<Ext
ExtendoGripRenderHandler.mainHandAnimation);
animation = animation * animation * animation;
Vec3d rotationOffset = new Vec3d(0, 1 / 2f, 1 / 2f);
float extensionAngle = MathHelper.lerp(animation, 24f, 156f);
float halfAngle = extensionAngle / 2;
float oppositeAngle = 180 - extensionAngle;
@ -101,11 +102,9 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer<Ext
if (leftHand || rightHand)
angle += 360 * animation;
angle %= 360;
float offset = 1 / 16f;
rotationOffset = new Vec3d(0, offset, 0);
stacker.translate(rotationOffset)
stacker.translate(cogRotationOffset)
.rotateZ(angle)
.translateBack(rotationOffset);
.translateBack(cogRotationOffset);
renderer.renderSolid(model.getPartial("cog"), light);
ms.pop();
}

View file

@ -69,9 +69,8 @@ public class ExtendoGripRenderHandler {
mc.getTextureManager()
.bindTexture(abstractclientplayerentity.getLocationSkin());
float f = rightHand ? 1.0F : -1.0F;
float flip = rightHand ? 1.0F : -1.0F;
float swingProgress = event.getSwingProgress();
float f3 = 0.4F * MathHelper.sin(((float) Math.PI * 2F));
boolean blockItem = heldItem.getItem() instanceof BlockItem;
float equipProgress = blockItem ? 0 : event.getEquipProgress() / 4;
@ -85,16 +84,16 @@ public class ExtendoGripRenderHandler {
ExtendoGripRenderHandler.mainHandAnimation);
animation = animation * animation * animation;
ms.translate(f * (0.64000005F - .1f), f3 + -0.4F + equipProgress * -0.6F, -0.71999997F + .3f);
ms.translate(flip * (0.64000005F - .1f), -0.4F + equipProgress * -0.6F, -0.71999997F + .3f);
ms.push();
msr.rotateY(f * 75.0F);
ms.translate(f * -1.0F, 3.6F, 3.5F);
msr.rotateZ(f * 120)
msr.rotateY(flip * 75.0F);
ms.translate(flip * -1.0F, 3.6F, 3.5F);
msr.rotateZ(flip * 120)
.rotateX(200)
.rotateY(f * -135.0F);
ms.translate(f * 5.6F, 0.0F, 0.0F);
msr.rotateY(f * 40.0F);
.rotateY(flip * -135.0F);
ms.translate(flip * 5.6F, 0.0F, 0.0F);
msr.rotateY(flip * 40.0F);
ms.translate(0.05f, -0.3f, -0.3f);
PlayerRenderer playerrenderer = (PlayerRenderer) mc.getRenderManager()
@ -107,7 +106,7 @@ public class ExtendoGripRenderHandler {
// Render gun
ms.push();
ms.translate(f * -0.1f, 0, -0.3f);
ms.translate(flip * -0.1f, 0, -0.3f);
FirstPersonRenderer firstPersonRenderer = mc.getFirstPersonRenderer();
TransformType transform =
rightHand ? TransformType.FIRST_PERSON_RIGHT_HAND : TransformType.FIRST_PERSON_LEFT_HAND;
@ -117,7 +116,7 @@ public class ExtendoGripRenderHandler {
if (!notInOffhand) {
ForgeHooksClient.handleCameraTransforms(ms, mc.getItemRenderer()
.getItemModelWithOverrides(offhandItem, null, null), transform, false);
ms.translate(f * -.05f, .15f, -1.2f);
ms.translate(flip * -.05f, .15f, -1.2f);
ms.translate(0, 0, -animation * 2.25f);
if (blockItem && mc.getItemRenderer()
.getItemModelWithOverrides(heldItem, null, null)

View file

@ -5,6 +5,7 @@ import java.util.List;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity;
import com.simibubi.create.content.contraptions.relays.belt.transport.BeltInventory;
import com.simibubi.create.content.logistics.block.AttachedLogisticalBlock;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
@ -102,7 +103,10 @@ public class ExtractorTileEntity extends SmartTileEntity {
return false;
BeltTileEntity controller = belt.getControllerTE();
if (controller != null) {
if (!controller.getInventory().canInsertFrom(belt.index, Direction.UP))
BeltInventory inventory = controller.getInventory();
if (inventory == null)
return false;
if (!inventory.canInsertFrom(belt.index, Direction.UP))
return false;
}
}

View file

@ -20,6 +20,7 @@ import net.minecraft.entity.item.ItemFrameEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.IFluidState;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
@ -100,8 +101,12 @@ public class SchematicWorld extends WrappedWorld {
if (pos.getY() - bounds.minY == -1 && !renderMode)
return Blocks.GRASS_BLOCK.getDefaultState();
if (getBounds().isVecInside(pos) && blocks.containsKey(pos))
return blocks.get(pos);
if (getBounds().isVecInside(pos) && blocks.containsKey(pos)) {
BlockState blockState = blocks.get(pos);
if (blockState.has(BlockStateProperties.LIT))
blockState = blockState.with(BlockStateProperties.LIT, false);
return blockState;
}
return Blocks.AIR.getDefaultState();
}

View file

@ -3,7 +3,7 @@
"textures": {
"3": "create:block/mechanical_press_pole",
"4": "create:item/extendo_grip",
"particle": "texture"
"particle": "#4"
},
"elements": [
{