Release 1.1.0: Default disabled dynamo and removed multimeter
This commit is contained in:
parent
7353c30754
commit
e1398c089e
|
@ -18,11 +18,11 @@ public class SPConfig {
|
|||
public final ForgeConfigSpec.IntValue steelFlywheelSteamConsumptionPerTick;
|
||||
public final ForgeConfigSpec.IntValue steelFlywheelSteamStorage;
|
||||
|
||||
public final ForgeConfigSpec.IntValue alternatorFeMaxIn;
|
||||
public final ForgeConfigSpec.IntValue alternatorFeMaxOut;
|
||||
public final ForgeConfigSpec.IntValue alternatorFeCapacity;
|
||||
public final ForgeConfigSpec.IntValue alternatorImpact;
|
||||
public final ForgeConfigSpec.DoubleValue alternatorEfficiency;
|
||||
public final ForgeConfigSpec.IntValue dynamoFeMaxIn;
|
||||
public final ForgeConfigSpec.IntValue dynamoFeMaxOut;
|
||||
public final ForgeConfigSpec.IntValue dynamoFeCapacity;
|
||||
public final ForgeConfigSpec.IntValue dynamoImpact;
|
||||
public final ForgeConfigSpec.DoubleValue dynamoEfficiency;
|
||||
|
||||
public final ForgeConfigSpec.DoubleValue bronzeCogwheelImpact;
|
||||
public final ForgeConfigSpec.DoubleValue castIronCogwheelImpact;
|
||||
|
@ -59,21 +59,21 @@ public class SPConfig {
|
|||
}
|
||||
builder.pop();
|
||||
|
||||
builder.push("alternator");
|
||||
builder.push("dynamo").comment("If dynamo is disabled in the server config, the following will be ignored!");
|
||||
{
|
||||
alternatorFeMaxIn = builder.defineInRange("alternatorFeMaxIn", 0, 0, 8192);
|
||||
alternatorFeMaxOut = builder.defineInRange("alternatorFeMaxOut", 256, 0, 8192);
|
||||
alternatorFeCapacity = builder.defineInRange("alternatorFeCapacity", 2048, 0, 8192);
|
||||
alternatorImpact = builder.defineInRange("alternatorImpact", 16, 0, 8192);
|
||||
alternatorEfficiency = builder.defineInRange("alternatorEfficiency", 0.75D, 0, 1);
|
||||
dynamoFeMaxIn = builder.defineInRange("dynamoFeMaxIn", 0, 0, 8192);
|
||||
dynamoFeMaxOut = builder.defineInRange("dynamoFeMaxOut", 256, 0, 8192);
|
||||
dynamoFeCapacity = builder.defineInRange("dynamoFeCapacity", 2048, 0, 8192);
|
||||
dynamoImpact = builder.defineInRange("dynamoImpact", 16, 0, 8192);
|
||||
dynamoEfficiency = builder.defineInRange("dynamoEfficiency", 0.75D, 0, 1);
|
||||
}
|
||||
builder.pop();
|
||||
|
||||
builder.push("cogwheel");
|
||||
builder.push("cogwheel").comment("For those who want to make the game more challenging, you can add stress impact to cogwheels!");
|
||||
{
|
||||
bronzeCogwheelImpact = builder.defineInRange("bronzeCogwheelImpact", 0.1D, 0, 1);
|
||||
bronzeCogwheelImpact = builder.defineInRange("bronzeCogwheelImpact", 0.0D, 0, 1);
|
||||
castIronCogwheelImpact = builder.defineInRange("castIronCogwheelImpact", 0.05D, 0, 1);
|
||||
steelCogwheelImpact = builder.defineInRange("steelCogwheelImpact", 0.02D, 0, 1);
|
||||
steelCogwheelImpact = builder.defineInRange("steelCogwheelImpact", 0.0D, 0, 1);
|
||||
}
|
||||
builder.pop();
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ public class SPConfig {
|
|||
|
||||
public final ForgeConfigSpec.BooleanValue allowUnverifiedContraption;
|
||||
public final ForgeConfigSpec.BooleanValue allowCartAssembler;
|
||||
public final ForgeConfigSpec.BooleanValue disableSteamPoweredDynamo;
|
||||
|
||||
Server(ForgeConfigSpec.Builder builder) {
|
||||
builder.push("createmodify");
|
||||
|
@ -91,6 +92,11 @@ public class SPConfig {
|
|||
allowCartAssembler = builder.comment("Cart Assembler is not very \"Realistic\", so you can choose to disable it.").define("allowCartAssembler", true);
|
||||
}
|
||||
builder.pop();
|
||||
builder.push("dynamo");
|
||||
{
|
||||
disableSteamPoweredDynamo = builder.comment("Set to false to enable this mod's dynamo.").define("disableSteamPoweredDynamo", true);
|
||||
}
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,23 +19,12 @@ public class SteamPoweredClient {
|
|||
SPBlockPartials.clientInit();
|
||||
modEventBus.addListener(SteamPoweredClient::clientInit);
|
||||
modEventBus.addListener(SteamPoweredClient::setupRenderType);
|
||||
forgeEventBus.addListener(SteamPoweredClient::addTooltip);
|
||||
}
|
||||
|
||||
public static void clientInit(FMLClientSetupEvent event) {
|
||||
SPPonderIndex.register();
|
||||
}
|
||||
|
||||
public static void addTooltip(ItemTooltipEvent event) {
|
||||
Item item = event.getItemStack().getItem();
|
||||
if (item == SPBlocks.ALTERNATOR.get().asItem()) {
|
||||
event.getToolTip().add(new TranslationTextComponent("block.steampowered.alternator.tooltip.summary").withStyle(TextFormatting.GRAY));
|
||||
}
|
||||
if (item == SPItems.MULTIMETER.get()) {
|
||||
event.getToolTip().add(new TranslationTextComponent("item.steampowered.multimeter.tooltip.summary").withStyle(TextFormatting.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupRenderType(FMLClientSetupEvent event) {
|
||||
event.enqueueWork(() -> {
|
||||
RenderTypeLookup.setRenderLayer(FluidRegistry.steam.get(), RenderType.translucent());
|
||||
|
|
|
@ -1,24 +1,66 @@
|
|||
/**
|
||||
* Available under MIT the license more info at: https://tldrlegal.com/license/mit-license
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright 2021 MRH0
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction,
|
||||
* including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom t
|
||||
* he Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.teammoeg.steampowered.content.alternator;
|
||||
|
||||
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.VoxelShaper;
|
||||
import com.teammoeg.steampowered.SPConfig;
|
||||
import com.teammoeg.steampowered.block.SPShapes;
|
||||
import com.teammoeg.steampowered.registrate.SPTiles;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Adapted from: Create: Crafts & Additions
|
||||
* @author MRH0
|
||||
*/
|
||||
public class AlternatorBlock extends DirectionalKineticBlock implements ITE<AlternatorTileEntity>, IRotate {
|
||||
|
||||
public static final VoxelShaper ALTERNATOR_SHAPE = SPShapes.shape(0, 3, 0, 16, 13, 16).add(2, 0, 2, 14, 14, 14).forDirectional();
|
||||
|
@ -76,4 +118,25 @@ public class AlternatorBlock extends DirectionalKineticBlock implements ITE<Alte
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemCategory(ItemGroup group, NonNullList<ItemStack> itemStacks) {
|
||||
if (SPConfig.SERVER.disableSteamPoweredDynamo.get()) {
|
||||
// dynamo disabled
|
||||
} else {
|
||||
super.fillItemCategory(group, itemStacks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack i, IBlockReader w, List<ITextComponent> t, ITooltipFlag f) {
|
||||
if (SPConfig.SERVER.disableSteamPoweredDynamo.get()) {
|
||||
t.add(new StringTextComponent("Dynamo is disabled in the server config").withStyle(TextFormatting.RED));
|
||||
} else {
|
||||
t.add(new StringTextComponent("Dynamo adapted from the mod Create: Crafts & Additions. Credits: MRH0").withStyle(TextFormatting.RED));
|
||||
t.add(new StringTextComponent("Codes and assets under MIT License").withStyle(TextFormatting.RED));
|
||||
t.add(new TranslationTextComponent("block.steampowered.alternator.tooltip.summary").withStyle(TextFormatting.GRAY));
|
||||
}
|
||||
super.appendHoverText(i,w,t,f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
/**
|
||||
* Available under MIT the license more info at: https://tldrlegal.com/license/mit-license
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright 2021 MRH0
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction,
|
||||
* including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom t
|
||||
* he Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.teammoeg.steampowered.content.alternator;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
|
@ -5,7 +32,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
|||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.teammoeg.steampowered.SPConfig;
|
||||
import com.teammoeg.steampowered.SteamPowered;
|
||||
import com.teammoeg.steampowered.item.Multimeter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
@ -26,6 +52,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* Adapted from: Create: Crafts & Additions
|
||||
* @author MRH0
|
||||
*/
|
||||
public class AlternatorTileEntity extends KineticTileEntity {
|
||||
|
||||
|
@ -33,12 +60,12 @@ public class AlternatorTileEntity extends KineticTileEntity {
|
|||
private LazyOptional<IEnergyStorage> lazyEnergy;
|
||||
|
||||
private static final int
|
||||
MAX_FE_IN = SPConfig.COMMON.alternatorFeMaxIn.get(),
|
||||
MAX_FE_OUT = SPConfig.COMMON.alternatorFeMaxOut.get(), // FE Output
|
||||
FE_CAPACITY = SPConfig.COMMON.alternatorFeCapacity.get(), // FE Storage
|
||||
IMPACT = SPConfig.COMMON.alternatorImpact.get(); // Impact on network
|
||||
MAX_FE_IN = SPConfig.COMMON.dynamoFeMaxIn.get(),
|
||||
MAX_FE_OUT = SPConfig.COMMON.dynamoFeMaxOut.get(), // FE Output
|
||||
FE_CAPACITY = SPConfig.COMMON.dynamoFeCapacity.get(), // FE Storage
|
||||
IMPACT = SPConfig.COMMON.dynamoImpact.get(); // Impact on network
|
||||
private static final double
|
||||
EFFICIENCY = SPConfig.COMMON.alternatorEfficiency.get();
|
||||
EFFICIENCY = SPConfig.COMMON.dynamoEfficiency.get();
|
||||
|
||||
public AlternatorTileEntity(TileEntityType<?> typeIn) {
|
||||
super(typeIn);
|
||||
|
@ -49,11 +76,19 @@ public class AlternatorTileEntity extends KineticTileEntity {
|
|||
@Override
|
||||
public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) {
|
||||
tooltip.add(new StringTextComponent(spacing).append(new TranslationTextComponent(SteamPowered.MODID + ".tooltip.energy.production").withStyle(TextFormatting.GRAY)));
|
||||
tooltip.add(new StringTextComponent(spacing).append(new StringTextComponent(" " + Multimeter.format(getEnergyProductionRate((int) (isSpeedRequirementFulfilled() ? getSpeed() : 0))) + "fe/t ") // fix
|
||||
tooltip.add(new StringTextComponent(spacing).append(new StringTextComponent(" " + format(getEnergyProductionRate((int) (isSpeedRequirementFulfilled() ? getSpeed() : 0))) + "fe/t ") // fix
|
||||
.withStyle(TextFormatting.AQUA)).append(Lang.translate("gui.goggles.at_current_speed").withStyle(TextFormatting.DARK_GRAY)));
|
||||
return super.addToGoggleTooltip(tooltip, isPlayerSneaking);
|
||||
}
|
||||
|
||||
private static String format(int n) {
|
||||
if (n > 1000000)
|
||||
return Math.round((double) n / 100000d) / 10d + "M";
|
||||
if (n > 1000)
|
||||
return Math.round((double) n / 100d) / 10d + "K";
|
||||
return n + "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float calculateStressApplied() {
|
||||
this.lastStressApplied = IMPACT;
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
/**
|
||||
* Available under MIT the license more info at: https://tldrlegal.com/license/mit-license
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright 2021 MRH0
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction,
|
||||
* including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom t
|
||||
* he Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.teammoeg.steampowered.content.alternator;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
@ -10,6 +37,10 @@ import net.minecraftforge.energy.CapabilityEnergy;
|
|||
import net.minecraftforge.energy.EnergyStorage;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
/**
|
||||
* Adapted from: Create: Crafts & Additions
|
||||
* @author MRH0
|
||||
*/
|
||||
public class InternalEnergyStorage extends EnergyStorage {
|
||||
public InternalEnergyStorage(int capacity) {
|
||||
super(capacity, capacity, capacity, 0);
|
||||
|
|
|
@ -1,155 +0,0 @@
|
|||
package com.teammoeg.steampowered.item;
|
||||
|
||||
import com.teammoeg.steampowered.SteamPowered;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Adapted from: Create: Crafts & Additions
|
||||
*/
|
||||
public class Multimeter extends Item {
|
||||
|
||||
public Multimeter(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType useOn(ItemUseContext c) {
|
||||
TileEntity te = c.getLevel().getBlockEntity(c.getClickedPos());
|
||||
if (te != null && !c.getLevel().isClientSide()) {
|
||||
LazyOptional<IEnergyStorage> cap;
|
||||
cap = te.getCapability(CapabilityEnergy.ENERGY, c.getClickedFace());
|
||||
|
||||
if (cap != null) {
|
||||
IEnergyStorage energy = cap.orElse(null);
|
||||
String measur = new TranslationTextComponent("item." + SteamPowered.MODID + ".multimeter.measuring").getString(Integer.MAX_VALUE);
|
||||
CompoundNBT tag = c.getItemInHand().getTag();
|
||||
if (tag == null)
|
||||
tag = new CompoundNBT();
|
||||
if (hasPos(tag)) {
|
||||
if (posEquals(tag, c.getClickedPos(), c.getClickedFace())) {
|
||||
int de = getDeltaEnergy(tag, energy != null ? energy.getEnergyStored() : 0);
|
||||
long dt = getDeltaTime(tag, c.getLevel().getGameTime());
|
||||
measur = " [" + (dt > 0 ? de / dt : 0) + "fe/t (" + (dt) + (new TranslationTextComponent("item." + SteamPowered.MODID + ".multimeter.ticks").getString(Integer.MAX_VALUE)) + ")]";
|
||||
clearPos(tag);
|
||||
} else {
|
||||
setContent(tag, c.getClickedPos(), c.getClickedFace(), c.getLevel().getGameTime(), energy != null ? energy.getEnergyStored() : 0);
|
||||
}
|
||||
} else {
|
||||
setContent(tag, c.getClickedPos(), c.getClickedFace(), c.getLevel().getGameTime(), energy != null ? energy.getEnergyStored() : 0);
|
||||
}
|
||||
|
||||
c.getItemInHand().setTag(tag);
|
||||
|
||||
c.getPlayer().sendMessage(new TranslationTextComponent("item." + SteamPowered.MODID + ".multimeter.title")
|
||||
.append(new StringTextComponent(" ").append(getTextComponent(energy,
|
||||
new TranslationTextComponent("item." + SteamPowered.MODID + ".multimeter.no_capability").getString(Integer.MAX_VALUE), "fe")).append(new StringTextComponent(" " + measur))),
|
||||
PlayerEntity.createPlayerUUID(c.getPlayer().getGameProfile()));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
public static ITextComponent getTextComponent(IEnergyStorage ies, String nan, String unit) {
|
||||
if (ies == null)
|
||||
return new StringTextComponent(nan);
|
||||
return new StringTextComponent(format(ies.getEnergyStored()) + unit).withStyle(TextFormatting.AQUA).append(new StringTextComponent(" / ").withStyle(TextFormatting.GRAY)).append(new StringTextComponent(format(ies.getMaxEnergyStored()) + unit));
|
||||
}
|
||||
|
||||
public static ITextComponent getTextComponent(IEnergyStorage ies) {
|
||||
return getTextComponent(ies, "NaN", "fe");
|
||||
}
|
||||
|
||||
public static String format(int n) {
|
||||
if (n > 1000000)
|
||||
return Math.round((double) n / 100000d) / 10d + "M";
|
||||
if (n > 1000)
|
||||
return Math.round((double) n / 100d) / 10d + "K";
|
||||
return n + "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
||||
CompoundNBT nbt = stack.getTag();
|
||||
super.appendHoverText(stack, worldIn, tooltip, flagIn);
|
||||
if (hasPos(nbt))
|
||||
tooltip.add(new TranslationTextComponent("item." + SteamPowered.MODID + ".multimeter.measuring"));
|
||||
}
|
||||
|
||||
public static boolean hasPos(CompoundNBT nbt) {
|
||||
if (nbt == null)
|
||||
return false;
|
||||
return nbt.contains("x") && nbt.contains("y") && nbt.contains("z") && nbt.contains("side");
|
||||
}
|
||||
|
||||
public static BlockPos getPos(CompoundNBT nbt) {
|
||||
if (nbt == null)
|
||||
return null;
|
||||
return new BlockPos(nbt.getInt("x"), nbt.getInt("y"), nbt.getInt("z"));
|
||||
}
|
||||
|
||||
public static int getDeltaEnergy(CompoundNBT nbt, int now) {
|
||||
if (nbt == null)
|
||||
return 0;
|
||||
int r = now - nbt.getInt("start");
|
||||
return r;
|
||||
}
|
||||
|
||||
public static long getDeltaTime(CompoundNBT nbt, long now) {
|
||||
if (nbt == null)
|
||||
return 0;
|
||||
long r = now - nbt.getLong("tick");
|
||||
return r > 0 ? r : 0;
|
||||
}
|
||||
|
||||
public static Direction getDirection(CompoundNBT nbt) {
|
||||
if (nbt == null)
|
||||
return null;
|
||||
return Direction.from3DDataValue(nbt.getInt("side"));
|
||||
}
|
||||
|
||||
public static boolean posEquals(CompoundNBT nbt, BlockPos pos, Direction dir) {
|
||||
return nbt.getInt("x") == pos.getX() && nbt.getInt("y") == pos.getY() && nbt.getInt("z") == pos.getZ() && nbt.getInt("side") == dir.get3DDataValue();
|
||||
}
|
||||
|
||||
public static void clearPos(CompoundNBT nbt) {
|
||||
nbt.remove("x");
|
||||
nbt.remove("y");
|
||||
nbt.remove("z");
|
||||
nbt.remove("side");
|
||||
nbt.remove("tick");
|
||||
nbt.remove("start");
|
||||
}
|
||||
|
||||
public static CompoundNBT setContent(CompoundNBT nbt, BlockPos pos, Direction dir, long tick, int energy) {
|
||||
if (nbt == null)
|
||||
return new CompoundNBT();
|
||||
nbt.putInt("x", pos.getX());
|
||||
nbt.putInt("y", pos.getY());
|
||||
nbt.putInt("z", pos.getZ());
|
||||
nbt.putInt("side", dir.get3DDataValue());
|
||||
nbt.putLong("tick", tick);
|
||||
nbt.putInt("start", energy);
|
||||
return nbt;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
package com.teammoeg.steampowered.registrate;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.AllSections;
|
||||
import com.simibubi.create.foundation.data.CreateRegistrate;
|
||||
import com.simibubi.create.repack.registrate.util.entry.ItemEntry;
|
||||
import com.teammoeg.steampowered.SteamPowered;
|
||||
import com.teammoeg.steampowered.item.Multimeter;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class SPItems {
|
||||
|
@ -13,16 +10,10 @@ public class SPItems {
|
|||
private static final CreateRegistrate REGISTRATE = SteamPowered.registrate.get()
|
||||
.itemGroup(() -> SteamPowered.itemGroup);
|
||||
|
||||
public static final ItemEntry<Multimeter> MULTIMETER =
|
||||
REGISTRATE.item("multimeter", Multimeter::new)
|
||||
.properties((p) -> p.stacksTo(1))
|
||||
.register();
|
||||
|
||||
public static final ItemEntry<Item> BRONZE_SHEET =
|
||||
REGISTRATE.item("bronze_sheet", Item::new)
|
||||
.register();
|
||||
|
||||
public static void register() {
|
||||
Create.registrate().addToSection(MULTIMETER, AllSections.KINETICS);
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 846 B |
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"type": "create:mechanical_crafting",
|
||||
"pattern": [
|
||||
" IRI ",
|
||||
"ILCLI",
|
||||
"RCSCR",
|
||||
"ILCLI",
|
||||
" IRI "
|
||||
],
|
||||
"key": {
|
||||
"I": {
|
||||
"tag": "forge:ingots/iron"
|
||||
},
|
||||
"R": {
|
||||
"item": "minecraft:redstone_block"
|
||||
},
|
||||
"S": {
|
||||
"item": "create:shaft"
|
||||
},
|
||||
"C": {
|
||||
"item": "steampowered:cast_iron_cogwheel"
|
||||
},
|
||||
"L": {
|
||||
"item": "steampowered:cast_iron_large_cogwheel"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "steampowered:alternator"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue