Bug Fixes, Updated zh_cn localization

- Mechanical Crafter JEI no longer adds other mods' custom crafting recipe types, addresses #114
- Potential fix for #125
- Blacklisted a few entities from contraption collision, addresses #120
- Contraption Entities no longer spawn water particles, addresses #107
- Fixed floating point errors in RSC, addresses #118
- Added rendering safety check for belts, addresses #108
- Update Chinese translation
This commit is contained in:
simibubi 2020-03-25 23:42:38 +01:00
parent f9b9659bc6
commit 30bb98468f
13 changed files with 1330 additions and 706 deletions

View file

@ -133,12 +133,12 @@ public class CreateJEI implements IModPlugin {
registration.addRecipes(findRecipes(
r -> (r instanceof MechanicalCraftingRecipe) && MechanicalCraftingCategory.isSmall((ShapedRecipe) r)),
smallMechanicalCraftingCategory.getUid());
registration.addRecipes(
findRecipes(r -> (r instanceof ShapedRecipe) && !(r instanceof MechanicalCraftingRecipe)
&& MechanicalCraftingCategory.isSmall((ShapedRecipe) r)),
registration.addRecipes(findRecipes(r -> r.getType() == IRecipeType.CRAFTING && (r instanceof ShapedRecipe)
&& !(r instanceof MechanicalCraftingRecipe) && MechanicalCraftingCategory.isSmall((ShapedRecipe) r)),
smallMechanicalCraftingCategory.getUid());
registration.addRecipes(
findRecipes(r -> (r instanceof ShapedRecipe) && !MechanicalCraftingCategory.isSmall((ShapedRecipe) r)),
findRecipes(r -> r.getType() == IRecipeType.CRAFTING && (r instanceof ShapedRecipe)
&& !MechanicalCraftingCategory.isSmall((ShapedRecipe) r)),
largeMechanicalCraftingCategory.getUid());
}

View file

@ -20,6 +20,7 @@ import com.simibubi.create.modules.contraptions.relays.encased.SplitShaftTileEnt
import com.simibubi.create.modules.contraptions.relays.gearbox.GearboxTileEntity;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos;
@ -95,12 +96,6 @@ public class RotationPropagator {
if (isLargeToSmallGear(stateTo, stateFrom, diff))
return -.5f;
// Rotation Speed Controller <-> Large Gear
if (isLargeGearToSpeedController(stateFrom, stateTo, diff))
return SpeedControllerTileEntity.getSpeedModifier(from, to, true);
if (isLargeGearToSpeedController(stateTo, stateFrom, diff))
return SpeedControllerTileEntity.getSpeedModifier(to, from, false);
// Gear <-> Gear
if (connectedByGears) {
if (diff.manhattanDistance(BlockPos.ZERO) != 1)
@ -114,6 +109,20 @@ public class RotationPropagator {
return 0;
}
private static float getConveyedSpeed(KineticTileEntity from, KineticTileEntity to) {
final BlockState stateFrom = from.getBlockState();
final BlockState stateTo = to.getBlockState();
final BlockPos diff = to.getPos().subtract(from.getPos());
// Rotation Speed Controller <-> Large Gear
if (isLargeGearToSpeedController(stateFrom, stateTo, diff))
return SpeedControllerTileEntity.getConveyedSpeed(from, to, true);
if (isLargeGearToSpeedController(stateTo, stateFrom, diff))
return SpeedControllerTileEntity.getConveyedSpeed(to, from, false);
return from.getTheoreticalSpeed() * getRotationSpeedModifier(from, to);
}
private static boolean isLargeToLargeGear(BlockState from, BlockState to, BlockPos diff) {
if (!LARGE_COGWHEEL.typeOf(from) || !LARGE_COGWHEEL.typeOf(to))
return false;
@ -184,31 +193,7 @@ public class RotationPropagator {
return;
if (!worldIn.isBlockPresent(pos))
return;
if (addedTE.getTheoreticalSpeed() != 0) {
propagateNewSource(addedTE);
return;
}
for (KineticTileEntity neighbourTE : getConnectedNeighbours(addedTE)) {
final float speedModifier = getRotationSpeedModifier(neighbourTE, addedTE);
float neighbourSpeed = neighbourTE.getTheoreticalSpeed();
if (neighbourSpeed == 0)
continue;
if (neighbourTE.hasSource() && neighbourTE.source.equals(addedTE.getPos())) {
addedTE.setSpeed(neighbourSpeed * speedModifier);
addedTE.onSpeedChanged(0);
addedTE.sendData();
continue;
}
addedTE.setSpeed(neighbourSpeed * speedModifier);
addedTE.setSource(neighbourTE.getPos());
addedTE.onSpeedChanged(0);
addedTE.sendData();
propagateNewSource(addedTE);
return;
}
propagateNewSource(addedTE);
}
/**
@ -221,12 +206,10 @@ public class RotationPropagator {
World world = currentTE.getWorld();
for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) {
float modFromTo = getRotationSpeedModifier(currentTE, neighbourTE);
float modToFrom = getRotationSpeedModifier(neighbourTE, currentTE);
float speedOfCurrent = currentTE.getTheoreticalSpeed();
float speedOfNeighbour = neighbourTE.getTheoreticalSpeed();
float newSpeed = speedOfCurrent * modFromTo;
float oppositeSpeed = speedOfNeighbour * modToFrom;
float newSpeed = getConveyedSpeed(currentTE, neighbourTE);
float oppositeSpeed = getConveyedSpeed(neighbourTE, currentTE);
boolean incompatible =
Math.signum(newSpeed) != Math.signum(speedOfNeighbour) && (newSpeed != 0 && speedOfNeighbour != 0);
@ -249,7 +232,7 @@ public class RotationPropagator {
// Neighbour faster, overpower the incoming tree
if (Math.abs(oppositeSpeed) > Math.abs(speedOfCurrent)) {
float prevSpeed = currentTE.getSpeed();
currentTE.setSpeed(speedOfNeighbour * getRotationSpeedModifier(neighbourTE, currentTE));
currentTE.setSpeed(oppositeSpeed);
currentTE.setSource(neighbourTE.getPos());
currentTE.onSpeedChanged(prevSpeed);
currentTE.sendData();
@ -272,7 +255,7 @@ public class RotationPropagator {
currentTE.removeSource();
float prevSpeed = neighbourTE.getSpeed();
neighbourTE.setSpeed(speedOfCurrent * getRotationSpeedModifier(currentTE, neighbourTE));
neighbourTE.setSpeed(newSpeed);
neighbourTE.setSource(currentTE.getPos());
neighbourTE.onSpeedChanged(prevSpeed);
neighbourTE.sendData();
@ -370,17 +353,33 @@ public class RotationPropagator {
}
}
private static KineticTileEntity findConnectedNeighbour(KineticTileEntity te, BlockPos neighbourPos) {
BlockState neighbourState = te.getWorld().getBlockState(neighbourPos);
private static KineticTileEntity findConnectedNeighbour(KineticTileEntity currentTE, BlockPos neighbourPos) {
BlockState neighbourState = currentTE.getWorld().getBlockState(neighbourPos);
if (!(neighbourState.getBlock() instanceof IRotate))
return null;
if (!neighbourState.hasTileEntity())
return null;
KineticTileEntity neighbour = (KineticTileEntity) te.getWorld().getTileEntity(neighbourPos);
if (getRotationSpeedModifier(te, neighbour) == 0)
TileEntity neighbourTE = currentTE.getWorld().getTileEntity(neighbourPos);
if (!(neighbourTE instanceof KineticTileEntity))
return null;
return neighbour;
KineticTileEntity neighbourKTE = (KineticTileEntity) neighbourTE;
if (!(neighbourKTE.getBlockState().getBlock() instanceof IRotate))
return null;
if (!isConnected(currentTE, neighbourKTE))
return null;
return neighbourKTE;
}
public static boolean isConnected(KineticTileEntity from, KineticTileEntity to) {
final BlockState stateFrom = from.getBlockState();
final BlockState stateTo = to.getBlockState();
final BlockPos diff = to.getPos().subtract(from.getPos());
if (isLargeGearToSpeedController(stateFrom, stateTo, diff))
return true;
if (isLargeGearToSpeedController(stateTo, stateFrom, diff))
return true;
return getRotationSpeedModifier(from, to) != 0;
}
private static List<KineticTileEntity> getConnectedNeighbours(KineticTileEntity te) {

View file

@ -68,9 +68,9 @@ public interface IRotate extends IWrenchable {
String level = color + ItemDescription.makeProgressBar(3, speedLevel.ordinal());
if (speedLevel == SpeedLevel.MEDIUM)
level += Lang.translate("tooltip.speedRequirements.medium");
level += Lang.translate("tooltip.speedRequirement.medium");
if (speedLevel == SpeedLevel.FAST)
level += Lang.translate("tooltip.speedRequirements.high");
level += Lang.translate("tooltip.speedRequirement.high");
level += String.format(" (%s%s) ", IHaveGoggleInformation.format(Math.abs(speed)), Lang.translate("generic.unit.rpm"));

View file

@ -11,6 +11,7 @@ import net.minecraft.block.material.PushReaction;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.MoverType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Direction;
@ -52,7 +53,7 @@ public class ContraptionCollider {
return;
for (Entity entity : world.getEntitiesWithinAABB((EntityType<?>) null, bounds.grow(1),
e -> e.getPushReaction() == PushReaction.NORMAL)) {
e -> canBeCollidedWith(e))) {
ReuseableStream<VoxelShape> potentialHits =
getPotentiallyCollidedShapes(world, contraption, contraptionPosition, entity);
@ -88,6 +89,16 @@ public class ContraptionCollider {
}
public static boolean canBeCollidedWith(Entity e) {
if (e instanceof PlayerEntity && e.isSpectator())
return false;
if (e.noClip)
return false;
if (e instanceof IProjectile)
return false;
return e.getPushReaction() == PushReaction.NORMAL;
}
@OnlyIn(Dist.CLIENT)
private static void checkForClientPlayerCollision(Entity entity) {
if (entity != Minecraft.getInstance().player)

View file

@ -54,7 +54,6 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
protected Contraption contraption;
protected float initialAngle;
protected BlockPos controllerPos;
protected IControlContraption controllerTE;
protected Vec3d motionBeforeStall;
protected boolean stationary;
@ -103,12 +102,22 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
public <T extends TileEntity & IControlContraption> ContraptionEntity controlledBy(T controller) {
this.controllerPos = controller.getPos();
this.controllerTE = controller;
return this;
}
private IControlContraption getController() {
if (controllerPos == null)
return null;
if (!world.isBlockPresent(controllerPos))
return null;
TileEntity te = world.getTileEntity(controllerPos);
if (!(te instanceof IControlContraption))
return null;
return (IControlContraption) te;
}
public boolean collisionEnabled() {
return stationary && controllerTE instanceof LinearActuatorTileEntity;
return getController() instanceof LinearActuatorTileEntity;
}
@Override
@ -118,7 +127,7 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
return;
}
attachToController();
checkController();
Entity mountedEntity = getRidingEntity();
if (mountedEntity != null) {
@ -131,7 +140,7 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
move(getMotion().x, getMotion().y, getMotion().z);
if (ContraptionCollider.collideBlocks(this))
controllerTE.collided();
getController().collided();
tickActors(new Vec3d(posX - prevPosX, posY - prevPosY, posZ - prevPosZ));
@ -256,8 +265,8 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
if (!world.isRemote) {
if (!stalledPreviously && contraption.stalled) {
setMotion(Vec3d.ZERO);
if (controllerTE != null)
controllerTE.onStall();
if (getController() != null)
getController().onStall();
AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> this),
new ContraptionStallPacket(getEntityId(), posX, posY, posZ, yaw, pitch, roll));
}
@ -368,22 +377,21 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
controllerPos = NBTUtil.readBlockPos(compound.getCompound("Controller"));
}
public void attachToController() {
if (controllerPos != null && (controllerTE == null || !controllerTE.isValid())) {
if (!world.isBlockPresent(controllerPos))
return;
TileEntity te = world.getTileEntity(controllerPos);
if (te == null || !(te instanceof IControlContraption)) {
remove();
return;
}
IControlContraption controllerTE = (IControlContraption) te;
this.controllerTE = controllerTE;
controllerTE.attach(this);
if (world.isRemote)
setPosition(posX, posY, posZ);
public void checkController() {
if (controllerPos == null)
return;
if (!world.isBlockPresent(controllerPos))
return;
IControlContraption controller = getController();
if (controller == null) {
remove();
return;
}
if (controller.isAttachedTo(this))
return;
controller.attach(this);
if (world.isRemote)
setPosition(posX, posY, posZ);
}
@Override
@ -424,6 +432,10 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
}
remove();
}
@Override
protected void doWaterSplashEffect() {
}
public void preventMovedEntitiesFromGettingStuck() {
Vec3d stuckTest = new Vec3d(0, -2, 0);

View file

@ -6,6 +6,8 @@ import com.simibubi.create.foundation.utility.Lang;
public interface IControlContraption {
public boolean isAttachedTo(ContraptionEntity contraption);
public void attach(ContraptionEntity contraption);
public void onStall();

View file

@ -203,21 +203,22 @@ public class ClockworkBearingTileEntity extends KineticTileEntity implements IBe
@Override
public void attach(ContraptionEntity contraption) {
if (contraption.getContraption() instanceof ClockworkContraption) {
ClockworkContraption cc = (ClockworkContraption) contraption.getContraption();
markDirty();
Direction facing = getBlockState().get(BlockStateProperties.FACING);
BlockPos anchor = pos.offset(facing, cc.offset + 1);
if (cc.handType == HandType.HOUR) {
this.hourHand = contraption;
hourHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
} else {
this.minuteHand = contraption;
minuteHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
}
if (!world.isRemote)
sendData();
if (!(contraption.getContraption() instanceof ClockworkContraption))
return;
ClockworkContraption cc = (ClockworkContraption) contraption.getContraption();
markDirty();
Direction facing = getBlockState().get(BlockStateProperties.FACING);
BlockPos anchor = pos.offset(facing, cc.offset + 1);
if (cc.handType == HandType.HOUR) {
this.hourHand = contraption;
hourHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
} else {
this.minuteHand = contraption;
minuteHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
}
if (!world.isRemote)
sendData();
}
@Override
@ -287,4 +288,15 @@ public class ClockworkBearingTileEntity extends KineticTileEntity implements IBe
public void collided() {
}
@Override
public boolean isAttachedTo(ContraptionEntity contraption) {
if (!(contraption.getContraption() instanceof ClockworkContraption))
return false;
ClockworkContraption cc = (ClockworkContraption) contraption.getContraption();
if (cc.handType == HandType.HOUR)
return this.hourHand == contraption;
else
return this.minuteHand == contraption;
}
}

View file

@ -1,5 +1,7 @@
package com.simibubi.create.modules.contraptions.components.contraptions.bearing;
import static net.minecraft.state.properties.BlockStateProperties.FACING;
import java.util.List;
import com.simibubi.create.AllTileEntities;
@ -14,8 +16,8 @@ import com.simibubi.create.modules.contraptions.components.contraptions.Contrapt
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionEntity;
import com.simibubi.create.modules.contraptions.components.contraptions.DirectionalExtenderScrollOptionSlot;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Direction.AxisDirection;
@ -145,7 +147,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
}
public void assemble() {
Direction direction = getBlockState().get(BlockStateProperties.FACING);
Direction direction = getBlockState().get(FACING);
// Collect Construct
BearingContraption contraption = BearingContraption.assembleBearingAt(world, pos, direction);
@ -237,7 +239,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
protected void applyRotation() {
if (movedContraption != null) {
Axis axis = getBlockState().get(BlockStateProperties.FACING).getAxis();
Axis axis = getBlockState().get(FACING).getAxis();
Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis);
Vec3d vec = new Vec3d(1, 1, 1).scale(angle).mul(new Vec3d(direction.getDirectionVec()));
movedContraption.rotateTo(vec.x, vec.y, vec.z);
@ -246,14 +248,18 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
@Override
public void attach(ContraptionEntity contraption) {
if (contraption.getContraption() instanceof BearingContraption) {
this.movedContraption = contraption;
markDirty();
BlockPos anchor = pos.offset(getBlockState().get(BlockStateProperties.FACING));
movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
if (!world.isRemote)
sendData();
}
BlockState blockState = getBlockState();
if (!(contraption.getContraption() instanceof BearingContraption))
return;
if (!blockState.has(FACING))
return;
this.movedContraption = contraption;
markDirty();
BlockPos anchor = pos.offset(blockState.get(FACING));
movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
if (!world.isRemote)
sendData();
}
@Override
@ -279,4 +285,9 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
public void collided() {
}
@Override
public boolean isAttachedTo(ContraptionEntity contraption) {
return movedContraption == contraption;
}
}

View file

@ -297,4 +297,9 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity impleme
sendData();
}
@Override
public boolean isAttachedTo(ContraptionEntity contraption) {
return movedContraption == contraption;
}
}

View file

@ -31,8 +31,8 @@ public class SpeedControllerTileEntity extends KineticTileEntity {
super.addBehaviours(behaviours);
Integer max = AllConfigs.SERVER.kinetics.maxRotationSpeed.get();
targetSpeed = new ScrollValueBehaviour(Lang.translate("generic.speed"), this,
new ControllerValueBoxTransform());
targetSpeed =
new ScrollValueBehaviour(Lang.translate("generic.speed"), this, new ControllerValueBoxTransform());
targetSpeed.between(-max, max);
targetSpeed.value = DEFAULT_SPEED;
targetSpeed.moveText(new Vec3d(9, 0, 10));
@ -43,7 +43,7 @@ public class SpeedControllerTileEntity extends KineticTileEntity {
}
private void updateTargetRotation() {
if (hasNetwork())
if (hasNetwork())
getOrCreateNetwork().remove(this);
RotationPropagator.handleRemoved(world, pos, this);
removeSource();
@ -54,38 +54,38 @@ public class SpeedControllerTileEntity extends KineticTileEntity {
public boolean hasFastRenderer() {
return false;
}
public static float getSpeedModifier(KineticTileEntity cogWheel, KineticTileEntity speedControllerIn,
public static float getConveyedSpeed(KineticTileEntity cogWheel, KineticTileEntity speedControllerIn,
boolean targetingController) {
if (!(speedControllerIn instanceof SpeedControllerTileEntity))
return 1;
return 0;
SpeedControllerTileEntity speedController = (SpeedControllerTileEntity) speedControllerIn;
float targetSpeed = speedController.targetSpeed.getValue();
float speed = speedControllerIn.getSpeed();
float wheelSpeed = cogWheel.getTheoreticalSpeed();
if (targetSpeed == 0)
return 0;
float wheelSpeed = cogWheel.getTheoreticalSpeed();
if (targetingController && wheelSpeed == 0)
return 1;
return 0;
if (!speedController.hasSource()) {
if (targetingController)
return targetSpeed / wheelSpeed;
return 1;
return targetSpeed;
return 0;
}
boolean wheelPowersController = speedController.source.equals(cogWheel.getPos());
if (wheelPowersController) {
if (targetingController)
return targetSpeed / wheelSpeed;
return wheelSpeed / targetSpeed;
return targetSpeed;
return wheelSpeed;
}
if (targetingController)
return speed / targetSpeed;
return targetSpeed / speed;
return speed;
return targetSpeed;
}
private class ControllerValueBoxTransform extends ValueBoxTransform.Sided {

View file

@ -1,6 +1,5 @@
package com.simibubi.create.modules.contraptions.relays.belt;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@ -55,7 +54,6 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraft.world.storage.loot.LootParameter;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

View file

@ -13,6 +13,8 @@ class BeltColor implements IBlockColor {
@Override
public int getColor(BlockState state, IEnviromentBlockReader reader, BlockPos pos, int layer) {
if (reader == null)
return 0;
TileEntity tileEntity = reader.getTileEntity(pos);
if (tileEntity instanceof BeltTileEntity) {
BeltTileEntity te = (BeltTileEntity) tileEntity;

File diff suppressed because it is too large Load diff