Allow Using Veridium Blocks In Reactor
All checks were successful
EnergonRelics/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-07-22 16:40:19 -04:00
parent fe1d959ad5
commit fb8346ce0d
3 changed files with 19 additions and 10 deletions

View File

@ -8,8 +8,7 @@ import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Blocks;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
@ -27,7 +26,7 @@ public class DefensiveLaserBlock extends EnergyProviderBlock {
public static final BooleanProperty POWERED = Properties.POWERED; public static final BooleanProperty POWERED = Properties.POWERED;
public DefensiveLaserBlock() { public DefensiveLaserBlock() {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.BLACK).sounds(BlockSoundGroup.GLASS).requiresTool().strength(50.0F, 1200.0F).nonOpaque().allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> false).lightLevel(state -> state.get(POWERED) ? 7 : 0)); super(FabricBlockSettings.copy(Blocks.OBSIDIAN).sounds(BlockSoundGroup.GLASS).nonOpaque().allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> false).lightLevel(state -> state.get(POWERED) ? 7 : 0));
setDefaultState(getDefaultState().with(POWERED, false)); setDefaultState(getDefaultState().with(POWERED, false));
} }

View File

@ -9,6 +9,7 @@ import com.thebrokenrail.energonrelics.energy.helper.EnergyGeneratorBlockEntity;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.Item;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@ -35,17 +36,26 @@ public class ReactorControllerBlockEntity extends EnergyGeneratorBlockEntity {
if (getCachedState().get(ReactorControllerBlock.POWERED)) { if (getCachedState().get(ReactorControllerBlock.POWERED)) {
Reactor reactor = getReactor(); Reactor reactor = getReactor();
if (reactor != null && !reactor.core.isReacting()) { if (reactor != null && !reactor.core.isReacting()) {
boolean foundFuel = false; int fuelMultiplier = 0;
for (ReactorInputBlockEntity input : reactor.inputs) { for (ReactorInputBlockEntity input : reactor.inputs) {
if (fuelMultiplier != 0) {
break;
}
for (int i = 0; i < input.size(); i++) { for (int i = 0; i < input.size(); i++) {
if (input.getStack(i).getItem() == EnergonRelics.VERIDIUM_INGOT_ITEM) { Item item = input.getStack(i).getItem();
foundFuel = true; if (item == EnergonRelics.VERIDIUM_INGOT_ITEM) {
fuelMultiplier = 1;
} else if (item == EnergonRelics.VERIDIUM_BLOCK_BLOCK.asItem()) {
fuelMultiplier = 9;
}
if (fuelMultiplier != 0) {
input.removeStack(i, 1); input.removeStack(i, 1);
break;
} }
} }
} }
if (foundFuel) { if (fuelMultiplier != 0) {
reactor.core.startReaction(); reactor.core.startReaction(fuelMultiplier);
} }
} }
} }

View File

@ -31,8 +31,8 @@ public class ReactorCoreBlockEntity extends BlockEntity implements Tickable {
return reactionTime > 0; return reactionTime > 0;
} }
void startReaction() { void startReaction(int fuelMultiplier) {
reactionTime = HardcodedConfig.REACTOR_TIME; reactionTime = HardcodedConfig.REACTOR_TIME * fuelMultiplier;
} }
@Override @Override