Skip to content

Commit

Permalink
Add some safety checks to the reactor powah integration
Browse files Browse the repository at this point in the history
  • Loading branch information
SirEndii committed Jul 7, 2023
1 parent 7024959 commit f0977f9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.srendi.advancedperipherals.client;

import com.mojang.blaze3d.vertex.PoseStack;

import com.mojang.math.Transformation;
import com.mojang.math.Vector3f;
import dan200.computercraft.api.client.TransformedModel;
Expand All @@ -24,7 +23,7 @@ public TransformedModel getModel(T upgrade, @Nullable ITurtleAccess turtle, @Not
stack.translate(0.0f, 0.5f, 0.5f);
if (turtle != null) {
int rotationStep = DataStorageUtil.RotationCharge.get(turtle, side);
stack.mulPose(Vector3f.XN.rotationDegrees(-10 * rotationStep));
stack.mulPose(Vector3f.XN.rotationDegrees(-10f * rotationStep));
}
stack.translate(0.0f, -0.5f, -0.5f);
stack.mulPose(Vector3f.YN.rotationDegrees(90));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.srendi.advancedperipherals.lib.peripherals.BlockEntityIntegrationPeripheral;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.jetbrains.annotations.NotNull;
import owmii.powah.block.reactor.ReactorPartTile;

public class ReactorIntegration extends BlockEntityIntegrationPeripheral<ReactorPartTile> {
Expand All @@ -12,6 +13,7 @@ protected ReactorIntegration(BlockEntity entity) {
}

@Override
@NotNull
public String getType() {
return "uraniniteReactor";
}
Expand All @@ -23,51 +25,71 @@ public final String getName() {

@LuaFunction(mainThread = true)
public final boolean isRunning() {
if (blockEntity.core().isEmpty())
return false;
return blockEntity.core().get().isRunning();
}

@LuaFunction(mainThread = true)
public final double getFuel() {
if (blockEntity.core().isEmpty())
return 0.0d;
return blockEntity.core().get().fuel.perCent();
}

@LuaFunction(mainThread = true)
public final double getCarbon() {
if (blockEntity.core().isEmpty())
return 0.0d;
return blockEntity.core().get().carbon.perCent();
}

@LuaFunction(mainThread = true)
public final double getRedstone() {
if (blockEntity.core().isEmpty())
return 0.0d;
return blockEntity.core().get().redstone.perCent();
}

@LuaFunction(mainThread = true)
public final double getEnergy() {
if (blockEntity.core().isEmpty())
return 0.0d;
return blockEntity.core().get().getEnergy().getEnergyStored();
}

@LuaFunction(mainThread = true)
public final double getMaxEnergy() {
if (blockEntity.core().isEmpty())
return 0.0d;
return blockEntity.core().get().getEnergy().getMaxEnergyStored();
}

@LuaFunction(mainThread = true)
public final double getTemperature() {
if (blockEntity.core().isEmpty())
return 0.0d;
return blockEntity.core().get().temp.perCent();
}

@LuaFunction(mainThread = true)
public final ItemStack getInventoryUraninite() {
if (blockEntity.core().isEmpty())
return ItemStack.EMPTY;
return blockEntity.core().get().getInventory().getStackInSlot(1);
}

@LuaFunction(mainThread = true)
public final ItemStack getInventoryRedstone() {
if (blockEntity.core().isEmpty())
return ItemStack.EMPTY;
return blockEntity.core().get().getInventory().getStackInSlot(3);
}

@LuaFunction(mainThread = true)
public final ItemStack getInventoryCarbon() {
if (blockEntity.core().isEmpty())
return ItemStack.EMPTY;
return blockEntity.core().get().getInventory().getStackInSlot(2);
}
}

0 comments on commit f0977f9

Please sign in to comment.