diff --git a/src/main/java/com/simibubi/create/CreateConfig.java b/src/main/java/com/simibubi/create/CreateConfig.java index 29c8371c1..82e3bcd65 100644 --- a/src/main/java/com/simibubi/create/CreateConfig.java +++ b/src/main/java/com/simibubi/create/CreateConfig.java @@ -216,11 +216,11 @@ public class CreateConfig { name = "fanRotationArgmax"; fanRotationArgmax = builder.comment("", "Rotation speed at which the maximum stats of fans are reached.") - .translation(basePath + name).defineInRange(name, 1024, 64, Integer.MAX_VALUE); + .translation(basePath + name).defineInRange(name, 256, 64, Integer.MAX_VALUE); name = "generatingFanSpeed"; generatingFanSpeed = builder.comment("", "Rotation speed generated by a vertical fan above fire.") - .translation(basePath + name).defineInRange(name, 32, 0, Integer.MAX_VALUE); + .translation(basePath + name).defineInRange(name, 16, 0, Integer.MAX_VALUE); name = "inWorldProcessingTime"; inWorldProcessingTime = builder @@ -259,11 +259,11 @@ public class CreateConfig { name = "maxMotorSpeed"; maxMotorSpeed = builder.comment("", "Maximum allowed speed of a configurable motor.") - .translation(basePath + name).defineInRange(name, 4096, 64, Integer.MAX_VALUE); + .translation(basePath + name).defineInRange(name, 256, 64, Integer.MAX_VALUE); name = "maxRotationSpeed"; maxRotationSpeed = builder.comment("", "Maximum allowed rotation speed for any Kinetic Tile.") - .translation(basePath + name).defineInRange(name, 16384, 64, Integer.MAX_VALUE); + .translation(basePath + name).defineInRange(name, 256, 64, Integer.MAX_VALUE); builder.pop(); } @@ -369,11 +369,11 @@ public class CreateConfig { name = "mediumSpeed"; mediumSpeed = builder.comment("", "[in Degrees/Tick]", "Minimum speed of rotation to be considered 'medium'") - .translation(basePath + name).defineInRange(name, 32D, 0D, 4096D); + .translation(basePath + name).defineInRange(name, 30D, 0D, 4096D); name = "fastSpeed"; fastSpeed = builder.comment("", "[in Degrees/Tick]", "Minimum speed of rotation to be considered 'fast'") - .translation(basePath + name).defineInRange(name, 512D, 0D, 65535D); + .translation(basePath + name).defineInRange(name, 100D, 0D, 65535D); name = "mediumStressImpact"; mediumStressImpact = builder.comment("", "Minimum stress impact to be considered 'medium'") @@ -419,11 +419,11 @@ public class CreateConfig { String basePath = "create.config.stress."; String name = block.name(); stressEntries.put(block.get().getRegistryName(), builder.comment("").translation(basePath + name) - .defineInRange(name, getDefaultStressImpact(block), 0, 2048)); + .defineInRange(name, StressConfigDefaults.getDefaultStressImpact(block), 0, 2048)); } private void initStressCapacityEntry(AllBlocks block, final ForgeConfigSpec.Builder builder) { - double defaultStressCapacity = getDefaultStressCapacity(block); + double defaultStressCapacity = StressConfigDefaults.getDefaultStressCapacity(block); if (defaultStressCapacity == -1) return; String basePath = "create.config.stressCapacity."; @@ -432,66 +432,6 @@ public class CreateConfig { builder.comment("").translation(basePath + name).defineInRange(name, defaultStressCapacity, 0, 4096D)); } - public static double getDefaultStressCapacity(AllBlocks block) { - - switch (block) { - case MOTOR: - return 1024; - case ENCASED_FAN: - case HAND_CRANK: - return 64; - case WATER_WHEEL: - return 32; - case MECHANICAL_BEARING: - return 128; - default: - return -1; - } - } - - public static double getDefaultStressImpact(AllBlocks block) { - - switch (block) { - case CRUSHING_WHEEL: - case MECHANICAL_PRESS: - case MOTOR: - return 32; - - case DRILL: - case SAW: - case MECHANICAL_PISTON: - case STICKY_MECHANICAL_PISTON: - return 16; - - case ENCASED_FAN: - case MECHANICAL_MIXER: - case MECHANICAL_BEARING: - case MECHANICAL_CRAFTER: - return 8; - - case WATER_WHEEL: - case TURNTABLE: - case GEARBOX: - case GEARSHIFT: - case LARGE_COGWHEEL: - return 4; - - case CLUTCH: - return 2; - - case BELT: - case COGWHEEL: - case ENCASED_BELT: - case ENCASED_SHAFT: - case SHAFT: - case SPEED_GAUGE: - case STRESS_GAUGE: - case HAND_CRANK: - default: - return 1; - } - } - private boolean isValidPath(Object path) { if (!(path instanceof String)) return false; diff --git a/src/main/java/com/simibubi/create/StressConfigDefaults.java b/src/main/java/com/simibubi/create/StressConfigDefaults.java new file mode 100644 index 000000000..d4e79272c --- /dev/null +++ b/src/main/java/com/simibubi/create/StressConfigDefaults.java @@ -0,0 +1,53 @@ +package com.simibubi.create; + +public class StressConfigDefaults { + + public static double getDefaultStressCapacity(AllBlocks block) { + + switch (block) { + case MOTOR: + return 1024; + case MECHANICAL_BEARING: + return 128; + case ENCASED_FAN: + case HAND_CRANK: + return 64; + case WATER_WHEEL: + return 32; + default: + return -1; + } + } + + public static double getDefaultStressImpact(AllBlocks block) { + + switch (block) { + case CRUSHING_WHEEL: + case MECHANICAL_PRESS: + return 32; + + case DRILL: + case SAW: + case DEPLOYER: + return 16; + + case ENCASED_FAN: + case MECHANICAL_MIXER: + case MECHANICAL_BEARING: + case MECHANICAL_CRAFTER: + return 8; + + case TURNTABLE: + case MECHANICAL_PISTON: + case STICKY_MECHANICAL_PISTON: + return 4; + + case BELT: + return 2; + + default: + return 0; + } + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/command/CreateCommand.java b/src/main/java/com/simibubi/create/foundation/command/CreateCommand.java index e5d365969..4c415f29d 100644 --- a/src/main/java/com/simibubi/create/foundation/command/CreateCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/CreateCommand.java @@ -2,7 +2,6 @@ package com.simibubi.create.foundation.command; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; diff --git a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java index 8b8d524bb..ed4816d1c 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java @@ -21,13 +21,16 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import com.simibubi.create.AllItems; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel; import com.simibubi.create.modules.contraptions.base.IRotate.StressImpact; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; @@ -80,17 +83,26 @@ public class ItemDescription { SpeedLevel minimumRequiredSpeedLevel = block.getMinimumRequiredSpeedLevel(); boolean hasSpeedRequirement = minimumRequiredSpeedLevel != SpeedLevel.NONE; ResourceLocation id = ((Block) block).getRegistryName(); - boolean hasStressImpact = parameters.stressEntries.containsKey(id); + boolean hasStressImpact = parameters.stressEntries.containsKey(id) + && parameters.stressEntries.get(id).get() > 0; boolean hasStressCapacity = parameters.stressCapacityEntries.containsKey(id); + boolean hasGlasses = AllItems.GOGGLES + .typeOf(Minecraft.getInstance().player.getItemStackFromSlot(EquipmentSlotType.HEAD)); + String rpmUnit = Lang.translate("generic.unit.rpm"); if (hasSpeedRequirement) { List speedLevels = Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high"); int index = minimumRequiredSpeedLevel.ordinal(); String level = minimumRequiredSpeedLevel.getTextColor() + makeProgressBar(3, index) + speedLevels.get(index); + + if (hasGlasses) + level += " (" + minimumRequiredSpeedLevel.getSpeedValue() + rpmUnit + "+)"; + add(linesOnShift, GRAY + Lang.translate("tooltip.speedRequirement")); add(linesOnShift, level); } + String stressUnit = Lang.translate("generic.unit.stress"); if (hasStressImpact && !block.hideStressImpact()) { List stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high"); double impact = parameters.stressEntries.get(id).get(); @@ -98,6 +110,10 @@ public class ItemDescription { : (impact >= parameters.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW); int index = impactId.ordinal(); String level = impactId.getColor() + makeProgressBar(3, index) + stressLevels.get(index); + + if (hasGlasses) + level += " (" + parameters.stressEntries.get(id).get() + stressUnit + ")"; + add(linesOnShift, GRAY + Lang.translate("tooltip.stressImpact")); add(linesOnShift, level); @@ -110,6 +126,9 @@ public class ItemDescription { : (capacity >= parameters.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH); int index = StressImpact.values().length - 1 - impactId.ordinal(); String level = impactId.getColor() + makeProgressBar(3, index) + stressCapacityLevels.get(index); + + if (hasGlasses) + level += " (" + capacity + stressUnit + ")"; if (block.showCapacityWithAnnotation()) level += " " + DARK_GRAY + TextFormatting.ITALIC + Lang.translate("tooltip.capacityProvided.asGenerator"); @@ -123,7 +142,7 @@ public class ItemDescription { return this; } - protected String makeProgressBar(int length, int filledLength) { + public static String makeProgressBar(int length, int filledLength) { String bar = " "; int emptySpaces = length - 1 - filledLength; for (int i = 0; i <= filledLength; i++) diff --git a/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java b/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java index a2aa10a21..dbdcc065e 100644 --- a/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java +++ b/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import com.mojang.bridge.game.Language; +import com.simibubi.create.AllItems; import com.simibubi.create.foundation.item.ItemDescription.Palette; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.IModule; @@ -15,6 +16,7 @@ import com.simibubi.create.modules.contraptions.base.IRotate; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; +import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; import net.minecraft.util.text.TextFormatting; @@ -24,6 +26,7 @@ public class TooltipHelper { public static final int maxCharsPerLine = 35; public static final Map cachedTooltips = new HashMap<>(); public static Language cachedLanguage; + private static boolean gogglesMode; public static String holdShift(Palette color, boolean highlighted) { TextFormatting colorFormat = highlighted ? color.hColor : color.color; @@ -81,7 +84,13 @@ public class TooltipHelper { public static boolean hasTooltip(ItemStack stack) { checkLocale(); -// cachedTooltips.clear(); + + boolean hasGlasses = AllItems.GOGGLES.typeOf(Minecraft.getInstance().player.getItemStackFromSlot(EquipmentSlotType.HEAD)); + if (hasGlasses != gogglesMode) { + gogglesMode = hasGlasses; + cachedTooltips.clear(); + } + String key = getTooltipTranslationKey(stack); if (cachedTooltips.containsKey(key)) return cachedTooltips.get(key) != ItemDescription.MISSING; diff --git a/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java b/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java index d4388cd2f..01f01de38 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java @@ -11,7 +11,7 @@ public class AnimationTickHolder { } public static float getRenderTick() { - return (ticks + Minecraft.getInstance().getRenderPartialTicks()) / 20; + return ticks + Minecraft.getInstance().getRenderPartialTicks(); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java b/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java index 432a7d471..f524efac6 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import com.mojang.blaze3d.platform.GlStateManager; -import com.simibubi.create.Create; import com.simibubi.create.CreateClientConfig; import com.simibubi.create.foundation.utility.TessellatorHelper; import com.simibubi.create.modules.contraptions.base.KineticTileEntity; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/WrenchItemRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/WrenchItemRenderer.java index 68c21b399..42144b3ff 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/WrenchItemRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/WrenchItemRenderer.java @@ -21,7 +21,7 @@ public class WrenchItemRenderer extends ItemStackTileEntityRenderer { GlStateManager.translatef(0.5F, 0.5F, 0.5F); itemRenderer.renderItem(stack, mainModel.getBakedModel()); - float angle = worldTime * -10 % 360; + float angle = worldTime * -.5f % 360; float xOffset = -1/32f; float zOffset = 0; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java b/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java index 3e4bcb1eb..5ce7cb632 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java @@ -23,7 +23,7 @@ public interface IRotate extends IWrenchable { public int getColor() { return this == NONE ? 0x22FF22 : this == MEDIUM ? 0x0084FF : 0xFF55FF; } - + public int getParticleSpeed() { return this == NONE ? 10 : this == MEDIUM ? 20 : 30; } @@ -38,6 +38,19 @@ public interface IRotate extends IWrenchable { } return NONE; } + + public float getSpeedValue() { + switch (this) { + case FAST: + return CreateConfig.parameters.fastSpeed.get().floatValue(); + case MEDIUM: + return CreateConfig.parameters.mediumSpeed.get().floatValue(); + case NONE: + default: + return 0; + } + } + } public enum StressImpact { @@ -57,11 +70,11 @@ public interface IRotate extends IWrenchable { public default SpeedLevel getMinimumRequiredSpeedLevel() { return SpeedLevel.NONE; } - + public default boolean hideStressImpact() { return false; } - + public default boolean showCapacityWithAnnotation() { return false; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java index fbeb20ac0..43f0caac4 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java @@ -23,7 +23,8 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; -import net.minecraft.particles.RedstoneParticleData; +import net.minecraft.particles.IParticleData; +import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; @@ -48,12 +49,14 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick public float maxStress; public float currentStress; protected boolean overStressed; - public UUID networkID; public UUID newNetworkID; public boolean updateNetwork; protected boolean initNetwork; + // Client + float overStressedEffect; + public KineticTileEntity(TileEntityType typeIn) { super(typeIn); speed = 0; @@ -161,6 +164,21 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick super.read(compound); } + @Override + public void readClientUpdate(CompoundNBT tag) { + boolean overStressedBefore = overStressed; + super.readClientUpdate(tag); + if (overStressedBefore != overStressed && speed != 0) { + if (overStressed) { + overStressedEffect = 1; + spawnEffect(ParticleTypes.SMOKE, 0.2f, 5); + } else { + overStressedEffect = -1; + spawnEffect(ParticleTypes.CLOUD, .075f, 2); + } + } + } + public boolean isSource() { return getGeneratedSpeed() != 0; } @@ -177,15 +195,6 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick public void setSpeed(float speed) { this.speed = speed; - if (hasWorld() && speed != 0 && world.isRemote) { - Random r = getWorld().rand; - for (int i = 0; i < 2; i++) { - float x = getPos().getX() + (r.nextFloat() - .5f) / 2f + .5f; - float y = getPos().getY() + (r.nextFloat() - .5f) / 2f + .5f; - float z = getPos().getZ() + (r.nextFloat() - .5f) / 2f + .5f; - this.getWorld().addParticle(new RedstoneParticleData(1, 1, 1, 1), x, y, z, 0, 0, 0); - } - } } public boolean hasSource() { @@ -274,8 +283,15 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick public void tick() { super.tick(); - if (world.isRemote) + if (world.isRemote) { + if (overStressedEffect != 0) { + overStressedEffect -= overStressedEffect * .1f; + if (Math.abs(overStressedEffect) < 1 / 128f) + overStressedEffect = 0; + } return; + } + if (speedChangeCounter > 0) speedChangeCounter--; @@ -344,6 +360,19 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick particleSpawnCountdown = 2; } + protected void spawnEffect(IParticleData particle, float maxMotion, int amount) { + if (!hasWorld()) + return; + if (!world.isRemote) + return; + Random r = getWorld().rand; + for (int i = 0; i < amount; i++) { + Vec3d motion = VecHelper.offsetRandomly(Vec3d.ZERO, r, maxMotion); + Vec3d position = VecHelper.getCenterOf(pos); + this.getWorld().addParticle(particle, position.x, position.y, position.z, motion.x, motion.y, motion.z); + } + } + protected void spawnRotationIndicators() { if (getSpeed() == 0) return; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java index dc98fc369..9d42f66ad 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java @@ -38,7 +38,7 @@ public class KineticTileEntityRenderer extends TileEntityRendererFast 0) + buffer.color(ColorHelper.mixColors(white, 0xFF0000, te.overStressedEffect)); + else + buffer.color(ColorHelper.mixColors(white, 0x00FFBB, -te.overStressedEffect)); + else + buffer.color(white); } return buffer; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/BlockBreakingKineticTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/BlockBreakingKineticTileEntity.java index 185ac6c1c..69cc64afa 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/BlockBreakingKineticTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/BlockBreakingKineticTileEntity.java @@ -144,7 +144,7 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity { } protected float getBreakSpeed() { - return Math.abs(speed / 100f); + return Math.abs(getSpeed() / 100f); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillTileEntityRenderer.java index 514f728f2..5b15788c4 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillTileEntityRenderer.java @@ -34,7 +34,7 @@ public class DrillTileEntityRenderer extends KineticTileEntityRenderer { ? context.getAnimationSpeed() : 0); Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state); - float time = AnimationTickHolder.getRenderTick(); + float time = AnimationTickHolder.getRenderTick() / 20; float angle = (float) (((time * speed) % 360) / 180 * (float) Math.PI); return buffer.rotateCentered(axis, angle); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/HarvesterTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/HarvesterTileEntityRenderer.java index 29d28e0b2..93db412eb 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/HarvesterTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/HarvesterTileEntityRenderer.java @@ -32,7 +32,7 @@ public class HarvesterTileEntityRenderer extends TileEntityRenderer 7 * Math.PI / 4f; + boolean canDisassemble = Math.abs(angle) < 45 || Math.abs(angle) > 7 * 45; if (speed == 0 && (canDisassemble || movedContraption == null || movedContraption.getContraption().blocks.isEmpty())) { disassembleConstruct(); @@ -162,14 +167,14 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp float angularSpeed = getAngularSpeed(); float newAngle = angle + angularSpeed; - angle = (float) (newAngle % (2 * Math.PI)); + angle = (float) (newAngle % 360); applyRotation(); } private void applyRotation() { if (movedContraption != null) { Direction direction = getBlockState().get(BlockStateProperties.FACING); - Vec3d vec = new Vec3d(1, 1, 1).scale(angle * 180 / Math.PI).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); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/bearing/MechanicalBearingTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/bearing/MechanicalBearingTileEntityRenderer.java index 52cf87338..f600cde43 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/bearing/MechanicalBearingTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/bearing/MechanicalBearingTileEntityRenderer.java @@ -25,7 +25,7 @@ public class MechanicalBearingTileEntityRenderer extends KineticTileEntityRender SuperByteBuffer superBuffer = CreateClient.bufferCache.renderBlockState(KINETIC_TILE, capState); float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks); - kineticRotationTransform(superBuffer, bearingTe, facing.getAxis(), interpolatedAngle, getWorld()); + kineticRotationTransform(superBuffer, bearingTe, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), getWorld()); superBuffer.translate(x, y, z).renderInto(buffer); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntity.java index a7f7c7777..2bb690a0b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntity.java @@ -236,7 +236,7 @@ public class MechanicalPistonTileEntity extends KineticTileEntity implements ICo Direction pistonDirection = getBlockState().get(BlockStateProperties.FACING); int movementModifier = pistonDirection.getAxisDirection().getOffset() * (pistonDirection.getAxis() == Axis.Z ? -1 : 1); - return getSpeed() * -movementModifier / 1024f; + return getSpeed() * -movementModifier / 512f; } public Vec3d getConstructOffset(float partialTicks) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntity.java index c0476dc01..809a74bc8 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntity.java @@ -178,7 +178,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { public int getCountDownSpeed() { if (getSpeed() == 0) return 0; - return MathHelper.clamp((int) Math.abs(getSpeed() / 2), 1, 250); + return MathHelper.clamp((int) Math.abs(getSpeed()), 4, 250); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crank/HandCrankTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crank/HandCrankTileEntity.java index a6c2243aa..28ccf8673 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crank/HandCrankTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crank/HandCrankTileEntity.java @@ -9,17 +9,17 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity { public boolean backwards; public float independentAngle; public float chasingVelocity; - + public HandCrankTileEntity() { super(AllTileEntities.HAND_CRANK.type); } - + public void turn(boolean back) { boolean update = false; - + if (getGeneratedSpeed() == 0 || back != backwards) update = true; - + inUse = 10; this.backwards = back; if (update && !world.isRemote) @@ -28,21 +28,21 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity { @Override public float getGeneratedSpeed() { - return inUse == 0 ? 0 : backwards ? -128 : 128; + return inUse == 0 ? 0 : backwards ? -32 : 32; } - + @Override public void tick() { super.tick(); - + float actualSpeed = getSpeed(); - chasingVelocity += (actualSpeed - chasingVelocity) * .25f; + chasingVelocity += ((actualSpeed * 10 / 3f) - chasingVelocity) * .25f; independentAngle += chasingVelocity; - + if (inUse > 0) { inUse--; - - if (inUse == 0 && !world.isRemote) + + if (inUse == 0 && !world.isRemote) updateGeneratedRotation(); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerBlock.java index 7e47f0aad..5c55d0513 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerBlock.java @@ -10,6 +10,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; +import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.BlockItemUseContext; @@ -81,9 +82,13 @@ public class CrushingWheelControllerBlock extends Block implements IHaveNoBlockI if (!(tileEntity instanceof CrushingWheelControllerTileEntity)) return; CrushingWheelControllerTileEntity te = (CrushingWheelControllerTileEntity) tileEntity; + if (te.crushingspeed == 0) + return; + if (entityIn instanceof ItemEntity) + ((ItemEntity) entityIn).setPickupDelay(10); if (te.isOccupied()) return; - if ((entityIn instanceof PlayerEntity) && ((PlayerEntity) entityIn).isCreative()) + if ((entityIn instanceof PlayerEntity) && ((PlayerEntity) entityIn).isCreative()) return; te.startCrushing(entityIn); @@ -167,16 +172,15 @@ public class CrushingWheelControllerBlock extends Block implements IHaveNoBlockI @Override public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { - if (worldIn.getTileEntity(pos) == null) - return; - - CrushingWheelControllerTileEntity te = (CrushingWheelControllerTileEntity) worldIn.getTileEntity(pos); - for (int slot = 0; slot < te.inventory.getSizeInventory(); slot++) { - InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), - te.inventory.getStackInSlot(slot)); - } - if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) { + if (worldIn.getTileEntity(pos) == null) + return; + CrushingWheelControllerTileEntity te = (CrushingWheelControllerTileEntity) worldIn.getTileEntity(pos); + for (int slot = 0; slot < te.inventory.getSizeInventory(); slot++) { + InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), + te.inventory.getStackInSlot(slot)); + } + worldIn.removeTileEntity(pos); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerTileEntity.java index 1588f1fc3..0138a98e7 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerTileEntity.java @@ -24,6 +24,7 @@ import net.minecraft.particles.ItemParticleData; import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; public class CrushingWheelControllerTileEntity extends SyncedTileEntity implements ITickableTileEntity { @@ -59,12 +60,14 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen if (crushingspeed == 0) return; - float speed = crushingspeed / 2.5f; + float speed = crushingspeed * 4; Vec3d outPos = VecHelper.getCenterOf(pos); if (!hasEntity()) { - float processingSpeed = speed / (!inventory.appliedRecipe ? inventory.getStackInSlot(0).getCount() : 1); + float processingSpeed = MathHelper.clamp( + (speed) / (!inventory.appliedRecipe ? MathHelper.log2(inventory.getStackInSlot(0).getCount()) : 1), + .25f, 20); inventory.remainingTime -= processingSpeed; spawnParticles(inventory.getStackInSlot(0)); @@ -122,6 +125,7 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen } ItemEntity itemEntity = (ItemEntity) processingEntity; + itemEntity.setPickupDelay(20); if (processingEntity.posY < pos.getY() + .25f) { insertItem(itemEntity); itemEntity.remove(); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java index 1d2309202..d4db2f745 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java @@ -141,7 +141,7 @@ public class DeployerTileEntity extends KineticTileEntity { } protected int getTimerSpeed() { - return (int) (getSpeed() == 0 ? 0 : MathHelper.clamp(Math.abs(getSpeed()) / 2, 8, 512)); + return (int) (getSpeed() == 0 ? 0 : MathHelper.clamp(Math.abs(getSpeed() * 2), 8, 512)); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java index 98ac63c5f..9c16c31b4 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java @@ -22,10 +22,12 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.item.BlockItem; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; @@ -53,23 +55,24 @@ public class DeployerTileEntityRenderer extends TileEntityRenderer 0) speed = MathHelper.clamp(speed, 80, 64 * 20); if (speed < 0) speed = MathHelper.clamp(speed, -64 * 20, -80); - float angle = (time * speed) % 360; + float angle = (time * speed * 3/10f) % 360; angle = angle / 180f * (float) Math.PI; SuperByteBuffer superByteBuffer = CreateClient.bufferCache.renderBlockState(KINETIC_TILE, diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntity.java index 7adff8303..260aabc93 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntity.java @@ -136,7 +136,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { if (!world.isRemote && runningTicks == 20) { if (processingTicks < 0) { - processingTicks = (MathHelper.log2((int) (8000 / speed))) * 15 + 1; + processingTicks = MathHelper.clamp((MathHelper.log2((int) (512 / speed))) * 15 + 1, 1, 512); } else { processingTicks--; if (processingTicks == 0) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java index ed2b3b362..e0ba45cbe 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java @@ -29,7 +29,7 @@ public class MechanicalMixerTileEntityRenderer extends KineticTileEntityRenderer float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks); float speed = mixer.getRenderedHeadRotationSpeed(partialTicks); float time = AnimationTickHolder.getRenderTick(); - float angle = (float) (((time * speed * 2) % 360) / 180 * (float) Math.PI); + float angle = (float) (((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI); SuperByteBuffer poleRender = CreateClient.bufferCache.renderGenericBlockModel(poleState); poleRender.translate(x, y - renderedHeadOffset, z).light(packedLightmapCoords).renderInto(buffer); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java index 2aa49755c..7d03e9c1a 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java @@ -74,13 +74,15 @@ public class MotorBlock extends HorizontalKineticBlock @Override public void onScroll(BlockState state, IWorld world, BlockPos pos, double delta) { - withTileEntityDo(world, pos, te -> te - .setSpeedValueLazily((int) (te.newGeneratedSpeed * (delta > 0 ^ te.newGeneratedSpeed < 0 ? 2 : .5f)))); + withTileEntityDo(world, pos, te -> { + int d = Math.abs(te.newGeneratedSpeed) < 32 ? 4 : 16; + te.setSpeedValueLazily((int) (te.newGeneratedSpeed + delta * d)); + }); } @Override public String getValueName(BlockState state, IWorld world, BlockPos pos) { - return Lang.translate("generic.speed"); + return Lang.translate("generic.speed") + " (" + Lang.translate("generic.unit.rpm") + ")"; } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java index 4e8f4cb44..85daf165f 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java @@ -53,12 +53,7 @@ public class MotorTileEntity extends GeneratingKineticTileEntity { if (newGeneratedSpeed == speed) return; Integer max = CreateConfig.parameters.maxMotorSpeed.get(); - if (newGeneratedSpeed > 0 && speed == 0) - newGeneratedSpeed = -1; - else if (newGeneratedSpeed < 0 && speed == 0) - newGeneratedSpeed = 1; - else - newGeneratedSpeed = MathHelper.clamp(speed, -max, max); + newGeneratedSpeed = MathHelper.clamp(speed, -max, max); this.lastModified = 0; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableBlock.java index e03302a92..7a28376b5 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableBlock.java @@ -47,7 +47,7 @@ public class TurntableBlock extends KineticBlock { if (e.getMotion().y > 0) return; - float speed = ((KineticTileEntity) te).getSpeed() / 20; + float speed = ((KineticTileEntity) te).getSpeed() * 3/10; World world = e.getEntityWorld(); if (speed == 0) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableHandler.java b/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableHandler.java index 5f7f9e7f5..9c6bd75bc 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableHandler.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableHandler.java @@ -23,7 +23,7 @@ public class TurntableHandler { return; KineticTileEntity te = (KineticTileEntity) mc.world.getTileEntity(pos); - float speed = te.getSpeed() / 19; + float speed = te.getSpeed() * 3/10; if (speed == 0) return; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/waterwheel/WaterWheelBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/waterwheel/WaterWheelBlock.java index b7f73cf1e..2dc75ab48 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/waterwheel/WaterWheelBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/waterwheel/WaterWheelBlock.java @@ -99,7 +99,7 @@ public class WaterWheelBlock extends HorizontalKineticBlock { flow = flowVec.y > 0 ^ !clockwise ? -flowVec.y * clockwiseMultiplier : -flowVec.y; } - te.setFlow(f, (int) (flow * 20)); + te.setFlow(f, (int) (flow * 5)); } private void updateWheelSpeed(IWorld world, BlockPos pos) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/processing/ProcessingInventory.java b/src/main/java/com/simibubi/create/modules/contraptions/processing/ProcessingInventory.java index 8bcdbba8d..037a97e1f 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/processing/ProcessingInventory.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/processing/ProcessingInventory.java @@ -9,8 +9,8 @@ import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.wrapper.RecipeWrapper; public class ProcessingInventory extends RecipeWrapper implements IItemHandler { - public int remainingTime; - public int recipeDuration; + public float remainingTime; + public float recipeDuration; public boolean appliedRecipe; public ProcessingInventory() { @@ -32,8 +32,8 @@ public class ProcessingInventory extends RecipeWrapper implements IItemHandler { stacks.add(stack); } ItemStackHelper.saveAllItems(nbt, stacks); - nbt.putInt("ProcessingTime", remainingTime); - nbt.putInt("RecipeTime", recipeDuration); + nbt.putFloat("ProcessingTime", remainingTime); + nbt.putFloat("RecipeTime", recipeDuration); nbt.putBoolean("AppliedRecipe", appliedRecipe); } @@ -44,8 +44,8 @@ public class ProcessingInventory extends RecipeWrapper implements IItemHandler { for (int slot = 0; slot < stacks.size(); slot++) inventory.setInventorySlotContents(slot, stacks.get(slot)); - inventory.remainingTime = nbt.getInt("ProcessingTime"); - inventory.recipeDuration = nbt.getInt("RecipeTime"); + inventory.remainingTime = nbt.getFloat("ProcessingTime"); + inventory.recipeDuration = nbt.getFloat("RecipeTime"); inventory.appliedRecipe = nbt.getBoolean("AppliedRecipe"); return inventory; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java index c5024c8a4..8be5f4760 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java @@ -105,6 +105,13 @@ public class BeltTileEntity extends KineticTileEntity { toRemove.forEach(passengers::remove); } + @Override + public float getStressApplied() { + if (!isController()) + return 0; + return super.getStressApplied(); + } + @Override public AxisAlignedBB getRenderBoundingBox() { if (!isController()) @@ -205,14 +212,14 @@ public class BeltTileEntity extends KineticTileEntity { } public float getBeltMovementSpeed() { - return getSpeed() / 1600f; + return getSpeed() / 480f; } public float getDirectionAwareBeltMovementSpeed() { int offset = getBeltFacing().getAxisDirection().getOffset(); if (getBeltFacing().getAxis() == Axis.X) offset *= -1; - return getSpeed() / 1600f * offset; + return getBeltMovementSpeed() * offset; } public boolean hasPulley() { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntityRenderer.java index 5c1922bbe..a57d91648 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntityRenderer.java @@ -71,7 +71,7 @@ public class BeltTileEntityRenderer extends TileEntityRenderer { * te.getBlockState().get(HORIZONTAL_FACING).getAxisDirection().getOffset(); if (renderedState.get(BeltBlock.HORIZONTAL_FACING).getAxis() == Axis.X) speed = -speed; - int textureIndex = (int) ((speed * time / 8) % 16); + int textureIndex = (int) ((speed * time / 36) % 16); if (textureIndex < 0) textureIndex += 16; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/SplitShaftTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/SplitShaftTileEntityRenderer.java index d910243fd..03fd91311 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/SplitShaftTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/SplitShaftTileEntityRenderer.java @@ -30,7 +30,7 @@ public class SplitShaftTileEntityRenderer extends KineticTileEntityRenderer { continue; float offset = getRotationOffsetForPosition(te, pos, axis); - float angle = (time * te.getSpeed()) % 360; + float angle = (time * te.getSpeed() * 3f / 10) % 360; float modifier = 1; if (te instanceof SplitShaftTileEntity) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeInformationRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeInformationRenderer.java new file mode 100644 index 000000000..742d62d9c --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeInformationRenderer.java @@ -0,0 +1,214 @@ +package com.simibubi.create.modules.contraptions.relays.gauge; + +import static net.minecraft.util.text.TextFormatting.DARK_GRAY; +import static net.minecraft.util.text.TextFormatting.GRAY; + +import java.util.ArrayList; +import java.util.List; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllItems; +import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.item.ItemDescription; +import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.modules.contraptions.base.GeneratingKineticTileEntity; +import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel; +import com.simibubi.create.modules.contraptions.base.IRotate.StressImpact; +import com.simibubi.create.modules.contraptions.base.KineticTileEntity; + +import net.minecraft.block.BlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; + +@EventBusSubscriber(value = Dist.CLIENT) +public class GaugeInformationRenderer { + + @SubscribeEvent + public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) { + if (event.getType() != ElementType.HOTBAR) + return; + + RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver; + if (!(objectMouseOver instanceof BlockRayTraceResult)) + return; + + BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; + Minecraft mc = Minecraft.getInstance(); + ClientWorld world = mc.world; + BlockPos pos = result.getPos(); + BlockState state = world.getBlockState(pos); + ItemStack goggles = mc.player.getItemStackFromSlot(EquipmentSlotType.HEAD); + + if (!AllItems.GOGGLES.typeOf(goggles)) + return; + if (mc.player.isSneaking()) + return; + + List tooltip = new ArrayList<>(); + TileEntity te = world.getTileEntity(pos); + + if (state.getBlock() instanceof GaugeBlock) + addGaugeTooltip(state, tooltip, te); + if (te instanceof GeneratingKineticTileEntity) + addGeneratorTooltip(state, tooltip, (GeneratingKineticTileEntity) te); + if (te instanceof KineticTileEntity) + addStressTooltip(state, tooltip, (KineticTileEntity) te); + + if (tooltip.isEmpty()) + return; + + GlStateManager.pushMatrix(); + Screen tooltipScreen = new Screen(null) { + + @Override + public void init(Minecraft mc, int width, int height) { + this.minecraft = mc; + this.itemRenderer = mc.getItemRenderer(); + this.font = mc.fontRenderer; + this.width = width; + this.height = height; + } + + }; + + tooltipScreen.init(mc, mc.mainWindow.getScaledWidth(), mc.mainWindow.getScaledHeight()); + tooltipScreen.renderTooltip(tooltip, tooltipScreen.width / 2, tooltipScreen.height / 2); + ScreenElementRenderer.render3DItem(() -> { + GlStateManager.translated(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16, 0); + return goggles; + }); + GlStateManager.popMatrix(); + + } + + private static void addStressTooltip(BlockState state, List tooltip, KineticTileEntity te) { + String spacing = " "; + float stressApplied = te.getStressApplied(); + if (stressApplied == 0) + return; + + tooltip.add(spacing + Lang.translate("gui.goggles.kinetic_stats")); + tooltip.add(spacing + GRAY + Lang.translate("tooltip.stressImpact")); + String addedCapacity = TextFormatting.AQUA + "" + stressApplied + Lang.translate("generic.unit.stress") + " " + + DARK_GRAY + Lang.translate("gui.goggles.at_current_speed"); + tooltip.add(spacing + " " + addedCapacity); + } + + private static void addGeneratorTooltip(BlockState state, List tooltip, GeneratingKineticTileEntity te) { + String spacing = " "; + float addedStressCapacity = te.getAddedStressCapacity(); + if (addedStressCapacity == 0) + return; + + tooltip.add(spacing + Lang.translate("gui.goggles.generator_stats")); + tooltip.add(spacing + GRAY + Lang.translate("tooltip.capacityProvided")); + + float actualSpeed = Math.abs(te.speed); + float relativeCap = 0; + if (actualSpeed != 0) + relativeCap = addedStressCapacity * actualSpeed; + + String addedCapacity = TextFormatting.AQUA + "" + addedStressCapacity + Lang.translate("generic.unit.stress") + + " " + DARK_GRAY + Lang.translate("gui.goggles.at_current_speed"); + String addedCapacityAtBase = GRAY + "" + (relativeCap) + Lang.translate("generic.unit.stress") + " " + DARK_GRAY + + Lang.translate("gui.goggles.base_value"); + tooltip.add(spacing + " " + addedCapacity); + tooltip.add(spacing + " " + addedCapacityAtBase); + } + + private static void addGaugeTooltip(BlockState state, List tooltip, TileEntity te) { + String spacing = " "; + tooltip.add(spacing + Lang.translate("gui.gauge.info_header")); + + if (AllBlocks.STRESS_GAUGE.typeOf(state)) { + if (!(te instanceof StressGaugeTileEntity)) + return; + StressGaugeTileEntity stressGauge = (StressGaugeTileEntity) te; + List stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high"); + double stress = stressGauge.currentStress; + double cap = stressGauge.maxStress; + double relStress = stress / (cap == 0 ? 1 : cap); + StressImpact impactId = relStress > 1 ? null + : (relStress > .75f) ? StressImpact.HIGH + : (relStress > .5f ? StressImpact.MEDIUM : StressImpact.LOW); + + TextFormatting color = TextFormatting.RED; + if (impactId == StressImpact.LOW) + color = TextFormatting.GREEN; + if (impactId == StressImpact.MEDIUM) + color = TextFormatting.YELLOW; + if (impactId == StressImpact.HIGH) + color = TextFormatting.GOLD; + + String level = TextFormatting.DARK_RED + ItemDescription.makeProgressBar(3, 2) + "" + + Lang.translate("gui.stress_gauge.overstressed"); + if (impactId != null) { + int index = impactId.ordinal(); + level = color + ItemDescription.makeProgressBar(3, index) + stressLevels.get(index); + } + + level += " (" + (int) (relStress * 100) + "%)"; + + float actualSpeed = stressGauge.speed; + if (actualSpeed == 0) + level = DARK_GRAY + ItemDescription.makeProgressBar(3, -1) + + Lang.translate("gui.stress_gauge.no_rotation"); + + tooltip.add(spacing + GRAY + Lang.translate("gui.stress_gauge.title")); + tooltip.add(spacing + level); + + if (actualSpeed != 0) { + tooltip.add(spacing + GRAY + Lang.translate("gui.stress_gauge.capacity")); + + String capacity = color + "" + ((cap - stress) / Math.abs(actualSpeed)) + + Lang.translate("generic.unit.stress") + " " + DARK_GRAY + + Lang.translate("gui.goggles.at_current_speed"); + String capacityAtBase = GRAY + "" + (cap - stress) + Lang.translate("generic.unit.stress") + " " + DARK_GRAY + + Lang.translate("gui.goggles.base_value"); + tooltip.add(spacing + " " + capacity); + tooltip.add(spacing + " " + capacityAtBase); + + } + + } + + if (AllBlocks.SPEED_GAUGE.typeOf(state)) { + if (!(te instanceof SpeedGaugeTileEntity)) + return; + SpeedGaugeTileEntity speedGauge = (SpeedGaugeTileEntity) te; + boolean overstressed = speedGauge.currentStress > speedGauge.maxStress && speedGauge.speed != 0; + + SpeedLevel speedLevel = SpeedLevel.of(speedGauge.speed); + String color = speedLevel.getTextColor() + ""; + if (overstressed) + color = DARK_GRAY + "" + TextFormatting.STRIKETHROUGH; + + List speedLevels = Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high"); + int index = speedLevel.ordinal(); + String level = color + ItemDescription.makeProgressBar(3, index) + + (speedLevel != SpeedLevel.NONE ? speedLevels.get(index) : ""); + level += " (" + Math.abs(speedGauge.speed) + "" + Lang.translate("generic.unit.rpm") + ") "; + + tooltip.add(spacing + GRAY + Lang.translate("gui.speed_gauge.title")); + tooltip.add(spacing + level); + + if (overstressed) + tooltip.add(spacing + TextFormatting.DARK_RED + Lang.translate("gui.stress_gauge.overstressed")); + } + } + +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/gearbox/GearboxTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/gearbox/GearboxTileEntityRenderer.java index 9fff4e5d1..188e1ada2 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/gearbox/GearboxTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/gearbox/GearboxTileEntityRenderer.java @@ -31,7 +31,7 @@ public class GearboxTileEntityRenderer extends KineticTileEntityRenderer { BlockState state = defaultState.with(BlockStateProperties.FACING, direction); float offset = getRotationOffsetForPosition(te, pos, axis); - float angle = (time * te.getSpeed()) % 360; + float angle = (time * te.getSpeed() * 3f / 10) % 360; if (te.getSpeed() != 0 && te.hasSource()) { BlockPos source = te.getSource().subtract(te.getPos()); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/ChromaticCompoundCubeItem.java b/src/main/java/com/simibubi/create/modules/curiosities/ChromaticCompoundCubeItem.java index b98a302d1..1da15168a 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/ChromaticCompoundCubeItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/ChromaticCompoundCubeItem.java @@ -41,7 +41,7 @@ public class ChromaticCompoundCubeItem extends Item implements IItemWithColorHan Minecraft mc = Minecraft.getInstance(); float pt = mc.getRenderPartialTicks(); float progress = (float) ((mc.player.getYaw(pt)) / 180 * Math.PI) - + (AnimationTickHolder.getRenderTick() * 1f); + + (AnimationTickHolder.getRenderTick() / 10f); if (layer == 0) return ColorHelper.mixColors(0x6e5773, 0x6B3074, ((float) MathHelper.sin(progress) + 1) / 2); if (layer == 1) diff --git a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperItemRenderer.java b/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperItemRenderer.java index d0c3e0c82..cb28a82dd 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperItemRenderer.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperItemRenderer.java @@ -31,7 +31,7 @@ public class BlockzapperItemRenderer extends ItemStackTileEntityRenderer { ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); BlockzapperModel mainModel = (BlockzapperModel) itemRenderer.getModelWithOverrides(stack); float pt = Minecraft.getInstance().getRenderPartialTicks(); - float worldTime = AnimationTickHolder.getRenderTick(); + float worldTime = AnimationTickHolder.getRenderTick() / 20; GlStateManager.pushMatrix(); GlStateManager.translatef(0.5F, 0.5F, 0.5F); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/deforester/DeforesterItemRenderer.java b/src/main/java/com/simibubi/create/modules/curiosities/deforester/DeforesterItemRenderer.java index 26d7e7f75..0dd717b89 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/deforester/DeforesterItemRenderer.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/deforester/DeforesterItemRenderer.java @@ -31,7 +31,7 @@ public class DeforesterItemRenderer extends ItemStackTileEntityRenderer { GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lastCoordx, lastCoordy); GlStateManager.enableLighting(); - float angle = worldTime * -10 % 360; + float angle = worldTime * -.5f % 360; float xOffset = 0; float zOffset = 0; GlStateManager.translatef(-xOffset, 0, -zOffset); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/client/SymmetryWandItemRenderer.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/client/SymmetryWandItemRenderer.java index c73d770a9..f12500b55 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/client/SymmetryWandItemRenderer.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/client/SymmetryWandItemRenderer.java @@ -17,7 +17,7 @@ public class SymmetryWandItemRenderer extends ItemStackTileEntityRenderer { ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); SymmetryWandModel mainModel = (SymmetryWandModel) itemRenderer.getModelWithOverrides(stack); - float worldTime = AnimationTickHolder.getRenderTick(); + float worldTime = AnimationTickHolder.getRenderTick() / 20; GlStateManager.pushMatrix(); GlStateManager.translatef(0.5F, 0.5F, 0.5F); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperItem.java b/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperItem.java index 3ab8c9c41..71d872ade 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperItem.java @@ -51,6 +51,17 @@ public class SandPaperItem extends Item { return new ActionResult<>(ActionResultType.PASS, itemstack); } + Hand otherHand = handIn == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND; + ItemStack itemInOtherHand = playerIn.getHeldItem(otherHand); + if (SandPaperPolishingRecipe.canPolish(worldIn, itemInOtherHand)) { + ItemStack item = itemInOtherHand.copy(); + ItemStack toPolish = item.split(1); + playerIn.setActiveHand(handIn); + itemstack.getOrCreateTag().put("Polishing", toPolish.serializeNBT()); + playerIn.setHeldItem(otherHand, item); + return new ActionResult<>(ActionResultType.SUCCESS, itemstack); + } + RayTraceResult raytraceresult = rayTrace(worldIn, playerIn, RayTraceContext.FluidMode.NONE); if (!(raytraceresult instanceof BlockRayTraceResult)) return FAIL; diff --git a/src/main/resources/assets/create/lang/en_us.json b/src/main/resources/assets/create/lang/en_us.json index b75ab0ff1..04287485b 100644 --- a/src/main/resources/assets/create/lang/en_us.json +++ b/src/main/resources/assets/create/lang/en_us.json @@ -266,6 +266,8 @@ "create.generic.unit.ticks": "Ticks", "create.generic.unit.seconds": "Seconds", "create.generic.unit.minutes": "Minutes", + "create.generic.unit.rpm": "rpm", + "create.generic.unit.stress": "sU", "create.action.scroll": "Scroll", "create.action.confirm": "Confirm", @@ -325,6 +327,18 @@ "create.logistics.firstFrequency": "Freq. #1", "create.logistics.secondFrequency": "Freq. #2", + "create.gui.goggles.generator_stats": "Generator Stats:", + "create.gui.goggles.kinetic_stats": "Kinetic Stats:", + "create.gui.goggles.at_current_speed": "At current Speed", + "create.gui.goggles.base_value": "Base Value", + + "create.gui.gauge.info_header": "Gauge Information:", + "create.gui.speed_gauge.title": "Rotation Speed", + "create.gui.stress_gauge.title": "Network Stress", + "create.gui.stress_gauge.capacity": "Remaining Capacity", + "create.gui.stress_gauge.overstressed": "Overstressed", + "create.gui.stress_gauge.no_rotation": "No Rotation", + "create.gui.flexcrate.title": "Adjustable Crate", "create.gui.flexcrate.storageSpace": "Storage Space", diff --git a/src/main/resources/data/create/recipes/crushing/cobblestone.json b/src/main/resources/data/create/recipes/crushing/cobblestone.json index 28f0ef021..4cce6aa7e 100644 --- a/src/main/resources/data/create/recipes/crushing/cobblestone.json +++ b/src/main/resources/data/create/recipes/crushing/cobblestone.json @@ -12,5 +12,5 @@ "count": 1 } ], - "processingTime": 50 + "processingTime": 250 } \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/crushing/gravel.json b/src/main/resources/data/create/recipes/crushing/gravel.json index 241ba5b60..ac476f5cd 100644 --- a/src/main/resources/data/create/recipes/crushing/gravel.json +++ b/src/main/resources/data/create/recipes/crushing/gravel.json @@ -22,5 +22,5 @@ "chance": 0.2 } ], - "processingTime": 50 + "processingTime": 250 } \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/crushing/sand.json b/src/main/resources/data/create/recipes/crushing/sand.json index 3d88700c4..45773d802 100644 --- a/src/main/resources/data/create/recipes/crushing/sand.json +++ b/src/main/resources/data/create/recipes/crushing/sand.json @@ -22,5 +22,5 @@ "chance": 0.05 } ], - "processingTime": 50 + "processingTime": 150 } \ No newline at end of file