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( registration.addRecipes(findRecipes(
r -> (r instanceof MechanicalCraftingRecipe) && MechanicalCraftingCategory.isSmall((ShapedRecipe) r)), r -> (r instanceof MechanicalCraftingRecipe) && MechanicalCraftingCategory.isSmall((ShapedRecipe) r)),
smallMechanicalCraftingCategory.getUid()); smallMechanicalCraftingCategory.getUid());
registration.addRecipes( registration.addRecipes(findRecipes(r -> r.getType() == IRecipeType.CRAFTING && (r instanceof ShapedRecipe)
findRecipes(r -> (r instanceof ShapedRecipe) && !(r instanceof MechanicalCraftingRecipe) && !(r instanceof MechanicalCraftingRecipe) && MechanicalCraftingCategory.isSmall((ShapedRecipe) r)),
&& MechanicalCraftingCategory.isSmall((ShapedRecipe) r)),
smallMechanicalCraftingCategory.getUid()); smallMechanicalCraftingCategory.getUid());
registration.addRecipes( 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()); 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 com.simibubi.create.modules.contraptions.relays.gearbox.GearboxTileEntity;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -95,12 +96,6 @@ public class RotationPropagator {
if (isLargeToSmallGear(stateTo, stateFrom, diff)) if (isLargeToSmallGear(stateTo, stateFrom, diff))
return -.5f; 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 // Gear <-> Gear
if (connectedByGears) { if (connectedByGears) {
if (diff.manhattanDistance(BlockPos.ZERO) != 1) if (diff.manhattanDistance(BlockPos.ZERO) != 1)
@ -114,6 +109,20 @@ public class RotationPropagator {
return 0; 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) { private static boolean isLargeToLargeGear(BlockState from, BlockState to, BlockPos diff) {
if (!LARGE_COGWHEEL.typeOf(from) || !LARGE_COGWHEEL.typeOf(to)) if (!LARGE_COGWHEEL.typeOf(from) || !LARGE_COGWHEEL.typeOf(to))
return false; return false;
@ -184,31 +193,7 @@ public class RotationPropagator {
return; return;
if (!worldIn.isBlockPresent(pos)) if (!worldIn.isBlockPresent(pos))
return; return;
if (addedTE.getTheoreticalSpeed() != 0) { propagateNewSource(addedTE);
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;
}
} }
/** /**
@ -221,12 +206,10 @@ public class RotationPropagator {
World world = currentTE.getWorld(); World world = currentTE.getWorld();
for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) { for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) {
float modFromTo = getRotationSpeedModifier(currentTE, neighbourTE);
float modToFrom = getRotationSpeedModifier(neighbourTE, currentTE);
float speedOfCurrent = currentTE.getTheoreticalSpeed(); float speedOfCurrent = currentTE.getTheoreticalSpeed();
float speedOfNeighbour = neighbourTE.getTheoreticalSpeed(); float speedOfNeighbour = neighbourTE.getTheoreticalSpeed();
float newSpeed = speedOfCurrent * modFromTo; float newSpeed = getConveyedSpeed(currentTE, neighbourTE);
float oppositeSpeed = speedOfNeighbour * modToFrom; float oppositeSpeed = getConveyedSpeed(neighbourTE, currentTE);
boolean incompatible = boolean incompatible =
Math.signum(newSpeed) != Math.signum(speedOfNeighbour) && (newSpeed != 0 && speedOfNeighbour != 0); Math.signum(newSpeed) != Math.signum(speedOfNeighbour) && (newSpeed != 0 && speedOfNeighbour != 0);
@ -249,7 +232,7 @@ public class RotationPropagator {
// Neighbour faster, overpower the incoming tree // Neighbour faster, overpower the incoming tree
if (Math.abs(oppositeSpeed) > Math.abs(speedOfCurrent)) { if (Math.abs(oppositeSpeed) > Math.abs(speedOfCurrent)) {
float prevSpeed = currentTE.getSpeed(); float prevSpeed = currentTE.getSpeed();
currentTE.setSpeed(speedOfNeighbour * getRotationSpeedModifier(neighbourTE, currentTE)); currentTE.setSpeed(oppositeSpeed);
currentTE.setSource(neighbourTE.getPos()); currentTE.setSource(neighbourTE.getPos());
currentTE.onSpeedChanged(prevSpeed); currentTE.onSpeedChanged(prevSpeed);
currentTE.sendData(); currentTE.sendData();
@ -272,7 +255,7 @@ public class RotationPropagator {
currentTE.removeSource(); currentTE.removeSource();
float prevSpeed = neighbourTE.getSpeed(); float prevSpeed = neighbourTE.getSpeed();
neighbourTE.setSpeed(speedOfCurrent * getRotationSpeedModifier(currentTE, neighbourTE)); neighbourTE.setSpeed(newSpeed);
neighbourTE.setSource(currentTE.getPos()); neighbourTE.setSource(currentTE.getPos());
neighbourTE.onSpeedChanged(prevSpeed); neighbourTE.onSpeedChanged(prevSpeed);
neighbourTE.sendData(); neighbourTE.sendData();
@ -370,17 +353,33 @@ public class RotationPropagator {
} }
} }
private static KineticTileEntity findConnectedNeighbour(KineticTileEntity te, BlockPos neighbourPos) { private static KineticTileEntity findConnectedNeighbour(KineticTileEntity currentTE, BlockPos neighbourPos) {
BlockState neighbourState = te.getWorld().getBlockState(neighbourPos); BlockState neighbourState = currentTE.getWorld().getBlockState(neighbourPos);
if (!(neighbourState.getBlock() instanceof IRotate)) if (!(neighbourState.getBlock() instanceof IRotate))
return null; return null;
if (!neighbourState.hasTileEntity()) if (!neighbourState.hasTileEntity())
return null; return null;
TileEntity neighbourTE = currentTE.getWorld().getTileEntity(neighbourPos);
KineticTileEntity neighbour = (KineticTileEntity) te.getWorld().getTileEntity(neighbourPos); if (!(neighbourTE instanceof KineticTileEntity))
if (getRotationSpeedModifier(te, neighbour) == 0)
return null; 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) { 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()); String level = color + ItemDescription.makeProgressBar(3, speedLevel.ordinal());
if (speedLevel == SpeedLevel.MEDIUM) if (speedLevel == SpeedLevel.MEDIUM)
level += Lang.translate("tooltip.speedRequirements.medium"); level += Lang.translate("tooltip.speedRequirement.medium");
if (speedLevel == SpeedLevel.FAST) 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")); 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.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.IProjectile;
import net.minecraft.entity.MoverType; import net.minecraft.entity.MoverType;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
@ -52,7 +53,7 @@ public class ContraptionCollider {
return; return;
for (Entity entity : world.getEntitiesWithinAABB((EntityType<?>) null, bounds.grow(1), for (Entity entity : world.getEntitiesWithinAABB((EntityType<?>) null, bounds.grow(1),
e -> e.getPushReaction() == PushReaction.NORMAL)) { e -> canBeCollidedWith(e))) {
ReuseableStream<VoxelShape> potentialHits = ReuseableStream<VoxelShape> potentialHits =
getPotentiallyCollidedShapes(world, contraption, contraptionPosition, entity); 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) @OnlyIn(Dist.CLIENT)
private static void checkForClientPlayerCollision(Entity entity) { private static void checkForClientPlayerCollision(Entity entity) {
if (entity != Minecraft.getInstance().player) if (entity != Minecraft.getInstance().player)

View File

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

View File

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

View File

@ -203,21 +203,22 @@ public class ClockworkBearingTileEntity extends KineticTileEntity implements IBe
@Override @Override
public void attach(ContraptionEntity contraption) { public void attach(ContraptionEntity contraption) {
if (contraption.getContraption() instanceof ClockworkContraption) { if (!(contraption.getContraption() instanceof ClockworkContraption))
ClockworkContraption cc = (ClockworkContraption) contraption.getContraption(); return;
markDirty();
Direction facing = getBlockState().get(BlockStateProperties.FACING); ClockworkContraption cc = (ClockworkContraption) contraption.getContraption();
BlockPos anchor = pos.offset(facing, cc.offset + 1); markDirty();
if (cc.handType == HandType.HOUR) { Direction facing = getBlockState().get(BlockStateProperties.FACING);
this.hourHand = contraption; BlockPos anchor = pos.offset(facing, cc.offset + 1);
hourHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); if (cc.handType == HandType.HOUR) {
} else { this.hourHand = contraption;
this.minuteHand = contraption; hourHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
minuteHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); } else {
} this.minuteHand = contraption;
if (!world.isRemote) minuteHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
sendData();
} }
if (!world.isRemote)
sendData();
} }
@Override @Override
@ -287,4 +288,15 @@ public class ClockworkBearingTileEntity extends KineticTileEntity implements IBe
public void collided() { 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; package com.simibubi.create.modules.contraptions.components.contraptions.bearing;
import static net.minecraft.state.properties.BlockStateProperties.FACING;
import java.util.List; import java.util.List;
import com.simibubi.create.AllTileEntities; 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.ContraptionEntity;
import com.simibubi.create.modules.contraptions.components.contraptions.DirectionalExtenderScrollOptionSlot; import com.simibubi.create.modules.contraptions.components.contraptions.DirectionalExtenderScrollOptionSlot;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.Direction.AxisDirection;
@ -145,7 +147,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
} }
public void assemble() { public void assemble() {
Direction direction = getBlockState().get(BlockStateProperties.FACING); Direction direction = getBlockState().get(FACING);
// Collect Construct // Collect Construct
BearingContraption contraption = BearingContraption.assembleBearingAt(world, pos, direction); BearingContraption contraption = BearingContraption.assembleBearingAt(world, pos, direction);
@ -237,7 +239,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
protected void applyRotation() { protected void applyRotation() {
if (movedContraption != null) { if (movedContraption != null) {
Axis axis = getBlockState().get(BlockStateProperties.FACING).getAxis(); Axis axis = getBlockState().get(FACING).getAxis();
Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis);
Vec3d vec = new Vec3d(1, 1, 1).scale(angle).mul(new Vec3d(direction.getDirectionVec())); Vec3d vec = new Vec3d(1, 1, 1).scale(angle).mul(new Vec3d(direction.getDirectionVec()));
movedContraption.rotateTo(vec.x, vec.y, vec.z); movedContraption.rotateTo(vec.x, vec.y, vec.z);
@ -246,14 +248,18 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
@Override @Override
public void attach(ContraptionEntity contraption) { public void attach(ContraptionEntity contraption) {
if (contraption.getContraption() instanceof BearingContraption) { BlockState blockState = getBlockState();
this.movedContraption = contraption; if (!(contraption.getContraption() instanceof BearingContraption))
markDirty(); return;
BlockPos anchor = pos.offset(getBlockState().get(BlockStateProperties.FACING)); if (!blockState.has(FACING))
movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); return;
if (!world.isRemote)
sendData(); this.movedContraption = contraption;
} markDirty();
BlockPos anchor = pos.offset(blockState.get(FACING));
movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
if (!world.isRemote)
sendData();
} }
@Override @Override
@ -279,4 +285,9 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
public void collided() { 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(); sendData();
} }
@Override
public boolean isAttachedTo(ContraptionEntity contraption) {
return movedContraption == contraption;
}
} }

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff