Skip to content

Commit

Permalink
Fix full block addons needing support blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Rearth committed Mar 3, 2024
1 parent c556df9 commit 2e3ff0b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class EnergyAddonBlock extends MachineAddonBlock {
private final boolean acceptEnergy;

public EnergyAddonBlock(Settings settings, boolean extender, float speedMultiplier, float efficiencyMultiplier, long addedCapacity, long addedInsert, boolean acceptEnergy) {
super(settings, extender, speedMultiplier, efficiencyMultiplier);
super(settings, extender, speedMultiplier, efficiencyMultiplier, true);
this.addedCapacity = addedCapacity;
this.addedInsert = addedInsert;
this.acceptEnergy = acceptEnergy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class InventoryProxyAddonBlock extends MachineAddonBlock {

public InventoryProxyAddonBlock(Settings settings, boolean extender, float speedMultiplier, float efficiencyMultiplier) {
super(settings, extender, speedMultiplier, efficiencyMultiplier);
super(settings, extender, speedMultiplier, efficiencyMultiplier, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import rearth.oritech.Oritech;
Expand All @@ -27,9 +28,10 @@ public class MachineAddonBlock extends WallMountedBlock implements BlockEntityPr
private final boolean extender;
private final float speedMultiplier;
private final float efficiencyMultiplier;
private final boolean needsSupport;


public MachineAddonBlock(Settings settings, boolean extender, float speedMultiplier, float efficiencyMultiplier) {
public MachineAddonBlock(Settings settings, boolean extender, float speedMultiplier, float efficiencyMultiplier, boolean needsSupport) {
super(settings);
this.setDefaultState(getDefaultState()
.with(ADDON_USED, false)
Expand All @@ -40,6 +42,7 @@ public MachineAddonBlock(Settings settings, boolean extender, float speedMultipl
this.extender = extender;
this.speedMultiplier = speedMultiplier;
this.efficiencyMultiplier = efficiencyMultiplier;
this.needsSupport = needsSupport;
}

@Override
Expand All @@ -49,6 +52,16 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> builder)
builder.add(FACE);
}

@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {

if (needsSupport) {
return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
} else {
return state;
}
}

@Override
protected MapCodec<? extends WallMountedBlock> getCodec() {
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/rearth/oritech/init/BlockContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ public class BlockContent implements BlockRegistryContainer {

public static final Block MACHINE_CORE_BASIC = new MachineCoreBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), 1);
public static final Block MACHINE_CORE_GOOD = new MachineCoreBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), 6);
public static final Block MACHINE_SPEED_ADDON = new MachineAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 0.9f, 1.05f);
public static final Block MACHINE_EFFICIENCY_ADDON = new MachineAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 1, 0.9f);
public static final Block MACHINE_SPEED_ADDON = new MachineAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 0.9f, 1.05f, true);
public static final Block MACHINE_EFFICIENCY_ADDON = new MachineAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 1, 0.9f, true);
public static final Block MACHINE_CAPACITOR_ADDON = new EnergyAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 1, 1f, 20000, 500, false);
public static final Block MACHINE_ACCEPTOR_ADDON = new EnergyAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 1, 1f, 5000, 50, true);
public static final Block MACHINE_INVENTORY_PROXY_ADDON = new InventoryProxyAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 1, 1f);
public static final Block MACHINE_EXTENDER = new MachineAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), true, 1, 1);
public static final Block MACHINE_EXTENDER = new MachineAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), true, 1, 1, false);

@Override
public void postProcessField(String namespace, Block value, String identifier, Field field) {
Expand Down

0 comments on commit 2e3ff0b

Please sign in to comment.