Skip to content

Commit

Permalink
add constant for array creation
Browse files Browse the repository at this point in the history
  • Loading branch information
thiakil committed Jul 14, 2024
1 parent cba0bec commit e7dde77
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator implements IBoundingBlock, IEvaporationSolar {

private static final RelativeSide[] ENERGY_SIDES = {RelativeSide.FRONT, RelativeSide.BOTTOM};
private final SolarCheck[] solarChecks = new SolarCheck[8];

public TileEntityAdvancedSolarGenerator(BlockPos pos, BlockState state) {
Expand All @@ -23,7 +24,7 @@ public TileEntityAdvancedSolarGenerator(BlockPos pos, BlockState state) {

@Override
protected RelativeSide[] getEnergySides() {
return new RelativeSide[]{RelativeSide.FRONT, RelativeSide.BOTTOM};
return ENERGY_SIDES;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

public abstract class TileEntityGenerator extends TileEntityMekanism {

private static final RelativeSide[] ENERGY_SIDES = {RelativeSide.FRONT};

@Nullable
private List<BlockEnergyCapabilityCache> outputCaches;
/**
Expand All @@ -43,7 +45,7 @@ public TileEntityGenerator(IBlockProvider blockProvider, BlockPos pos, BlockStat
}

protected RelativeSide[] getEnergySides() {
return new RelativeSide[]{RelativeSide.FRONT};
return ENERGY_SIDES;
}

@NotNull
Expand All @@ -63,7 +65,7 @@ protected boolean onUpdateServer() {
Direction direction = getDirection();
RelativeSide[] energySides = getEnergySides();
outputCaches = new ArrayList<>(energySides.length);
for (RelativeSide energySide : getEnergySides()) {
for (RelativeSide energySide : energySides) {
Direction side = energySide.getDirection(direction);
outputCaches.add(BlockEnergyCapabilityCache.create((ServerLevel) level, worldPosition.relative(side), side.getOpposite()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

public class TileEntitySolarGenerator extends TileEntityGenerator {

private static final RelativeSide[] ENERGY_SIDES = {RelativeSide.BOTTOM};
private boolean seesSun;
private FloatingLong lastProductionAmount = FloatingLong.ZERO;
@WrappingComputerMethod(wrapper = ComputerIInventorySlotWrapper.class, methodNames = "getEnergyItem", docPlaceholder = "energy item slot")
Expand Down Expand Up @@ -114,7 +115,7 @@ protected float getBrightnessMultiplier(@NotNull Level world) {

@Override
protected RelativeSide[] getEnergySides() {
return new RelativeSide[]{RelativeSide.BOTTOM};
return ENERGY_SIDES;
}

protected FloatingLong getConfiguredMax() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
public class TileEntityWindGenerator extends TileEntityGenerator implements IBoundingBlock {

private static final float SPEED = 32F;
private static final RelativeSide[] ENERGY_SIDES = {RelativeSide.FRONT, RelativeSide.BOTTOM};

private double angle;
private FloatingLong currentMultiplier = FloatingLong.ZERO;
Expand All @@ -48,7 +49,7 @@ protected IInventorySlotHolder getInitialInventory(IContentsListener listener) {

@Override
protected RelativeSide[] getEnergySides() {
return new RelativeSide[]{RelativeSide.FRONT, RelativeSide.BOTTOM};
return ENERGY_SIDES;
}

@Override
Expand Down

0 comments on commit e7dde77

Please sign in to comment.