0.0.8
EnergonRelics/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2020-08-15 23:01:24 -04:00
parent 72c85fa67b
commit 9096dbd53a
37 changed files with 694 additions and 33 deletions

View File

@ -1,5 +1,10 @@
# Changelog
**Beta 0.0.8**
* Add Phase Shifter Block
* Fix Bugs
* Add Circuit Board To REI
**Beta 0.0.7**
* Fix Structure Generation

View File

@ -92,4 +92,14 @@
## Infuser
- Uses Energy To Attempt To Convert An Item To A Different Item
- Each Item Has Multiple Outcomes And May Require Different Amount Of Energy
- Each Item Has Multiple Outcomes And May Require Different Amount Of Energy
## Phase Shifter
- Two Modes: Input And Output
- Mode Is Toggled By Redstone Input
- Can Be Dyed
- Input Blocks Phase Items
- The More Phased Items, The More Power An Input Requires
- The Longer An Item Is Phased, The Higher Its Range Is
- Periodically, Phased Items Are Rolled
- When Phased Items Are Rolled, There Is A 10% Chance Of Success, If It Succeeds it Will Transfer The Phased Item To An Output With Range That Is The Same Color

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.9.0+build.204
# Mod Properties
mod_version = 0.0.7
mod_version = 0.0.8
maven_group = com.thebrokenrail
# Dependencies

View File

@ -5,6 +5,7 @@ import com.thebrokenrail.energonrelics.block.CreativeEnergySourceBlock;
import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock;
import com.thebrokenrail.energonrelics.block.HolographicSkyBlock;
import com.thebrokenrail.energonrelics.block.InfuserBlock;
import com.thebrokenrail.energonrelics.block.PhaseShifterBlock;
import com.thebrokenrail.energonrelics.block.lightning.LightningRodBaseBlock;
import com.thebrokenrail.energonrelics.block.forcefield.ForcefieldProjectorBlock;
import com.thebrokenrail.energonrelics.block.forcefield.laser.IndustrialLaserProjectorBlock;
@ -126,6 +127,8 @@ public final class EnergonRelics implements ModInitializer {
public static final EnergyProjectorBlock ENERGY_PROJECTOR_BLOCK = new EnergyProjectorBlock();
public static final Item VERIDIUM_ORB_ITEM = new Item(new Item.Settings().group(ITEM_GROUP).rarity(Rarity.UNCOMMON));
public static final PhaseShifterBlock PHASE_SHIFTER_BLOCK = new PhaseShifterBlock();
@Override
public void onInitialize() {
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_ingot"), VERIDIUM_INGOT_ITEM);
@ -190,6 +193,8 @@ public final class EnergonRelics implements ModInitializer {
ENERGY_BEAM_BLOCK.register("energy_beam");
ENERGY_PORTAL_BLOCK.register("energy_portal");
ENERGY_PROJECTOR_BLOCK.register("energy_projector");
PHASE_SHIFTER_BLOCK.register("phase_shifter");
}
public static void playBeep(World world, BlockPos pos) {

View File

@ -1,17 +1,25 @@
package com.thebrokenrail.energonrelics.api.block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.inventory.Inventory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.Identifier;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.ApiStatus;
import java.util.function.Function;
/**
* Simple Block With Entity
*/
@SuppressWarnings("deprecation")
public abstract class SimpleBlockWithEntity extends SimpleBlock implements BlockEntityProvider {
protected BlockEntityType<BlockEntity> type;
@ -35,4 +43,35 @@ public abstract class SimpleBlockWithEntity extends SimpleBlock implements Block
public BlockEntity createBlockEntity(BlockView world) {
return getFactory().apply(type);
}
/**
* Does This Block's Block Entity Have An Inventory
* @return Has Inventory
*/
@ApiStatus.OverrideOnly
protected boolean hasInventory() {
return false;
}
@Override
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
if (state.getBlock() != newState.getBlock() && hasInventory()) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof Inventory) {
ItemScatterer.spawn(world, pos, (Inventory) blockEntity);
world.updateComparators(pos, this);
}
}
super.onStateReplaced(state, world, pos, newState, moved);
}
@Override
public boolean hasComparatorOutput(BlockState state) {
return hasInventory();
}
@Override
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
return hasInventory() ? ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos)) : 0;
}
}

View File

@ -18,6 +18,11 @@ import java.util.Objects;
public class EnergyTicker {
private static final List<EnergyTickable> scheduled = new ArrayList<>();
/**
* List of All Loaded Energy Tickers
*/
public static List<EnergyTickable> allLoaded = Collections.emptyList();
/**
* Schedule For Next Energy Tick
* @param tickable Object To Tick
@ -56,6 +61,8 @@ public class EnergyTicker {
temp2.clear();
}
allLoaded = Collections.unmodifiableList(started);
Collections.shuffle(started, world.random);
for (EnergyTickable tickable : started) {
world.getProfiler().push(() -> tickable.getID() + " logicTick");
@ -68,5 +75,7 @@ public class EnergyTicker {
world.getProfiler().pop();
}
scheduled.clear();
allLoaded = Collections.emptyList();
}
}

View File

@ -0,0 +1,14 @@
package com.thebrokenrail.energonrelics.api.item;
import net.minecraft.text.MutableText;
/**
* Implement To provide Extra Information In Multimeter
*/
public interface MultimeterExtra {
/**
* Get Extra Information
* @return Text
*/
MutableText getExtra();
}

View File

@ -0,0 +1,115 @@
package com.thebrokenrail.energonrelics.block;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.api.block.energy.EnergyBlock;
import com.thebrokenrail.energonrelics.block.entity.shifter.PhaseShifterBlockEntity;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.DyeItem;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.HopperScreenHandler;
import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Random;
import java.util.function.Function;
@SuppressWarnings("deprecation")
public class PhaseShifterBlock extends EnergyBlock {
public static final BooleanProperty POWERED = Properties.POWERED;
public static final BooleanProperty IS_OUTPUT = BooleanProperty.of("is_output");
public static final EnumProperty<DyeColor> COLOR = EnumProperty.of("color", DyeColor.class);
public PhaseShifterBlock() {
super(FabricBlockSettings.copy(Blocks.IRON_BLOCK).lightLevel(state -> state.get(POWERED) ? 13 : 0).emissiveLighting((state, world, pos) -> state.get(POWERED)));
setDefaultState(getDefaultState().with(POWERED, false).with(IS_OUTPUT, false).with(COLOR, DyeColor.WHITE));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(POWERED, IS_OUTPUT, COLOR);
}
@Override
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
return PhaseShifterBlockEntity::new;
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return getDefaultState().with(IS_OUTPUT, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
}
@Override
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
if (!world.isClient()) {
boolean bl = state.get(IS_OUTPUT);
if (bl != world.isReceivingRedstonePower(pos)) {
if (bl) {
world.getBlockTickScheduler().schedule(pos, this, 4);
} else {
world.setBlockState(pos, state.cycle(IS_OUTPUT), 2);
}
}
}
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (state.get(IS_OUTPUT) && !world.isReceivingRedstonePower(pos)) {
world.setBlockState(pos, state.cycle(IS_OUTPUT), 2);
}
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ItemStack stack = player.getStackInHand(hand);
BlockEntity entity = world.getBlockEntity(pos);
if (stack.getItem() instanceof DyeItem) {
DyeColor newColor = ((DyeItem) stack.getItem()).getColor();
if (state.get(COLOR) != newColor) {
world.setBlockState(pos, state.with(COLOR, newColor));
if (!player.isCreative()) {
stack.decrement(1);
}
return ActionResult.SUCCESS;
} else {
return ActionResult.PASS;
}
} else {
if (entity instanceof Inventory) {
if (!world.isClient()) {
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, inv, player2) -> new HopperScreenHandler(i, inv, (Inventory) entity), new TranslatableText("block." + EnergonRelics.NAMESPACE + ".phase_shifter")));
}
return ActionResult.SUCCESS;
} else {
return ActionResult.FAIL;
}
}
}
@Override
protected boolean hasInventory() {
return true;
}
}

View File

@ -22,26 +22,27 @@ import java.util.function.Function;
@SuppressWarnings("deprecation")
public class SwitchBlock extends EnergyBlock {
public static final BooleanProperty POWERED = Properties.POWERED;
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
public SwitchBlock() {
super(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1.5f, 6.0f));
setDefaultState(getDefaultState().with(POWERED, false));
setDefaultState(getDefaultState().with(POWERED, false).with(ACTIVE, false));
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return getDefaultState().with(POWERED, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
return getDefaultState().with(ACTIVE, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
}
@Override
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
if (!world.isClient()) {
boolean bl = state.get(POWERED);
boolean bl = state.get(ACTIVE);
if (bl != world.isReceivingRedstonePower(pos)) {
if (bl) {
world.getBlockTickScheduler().schedule(pos, this, 4);
} else {
world.setBlockState(pos, state.cycle(POWERED), 2);
world.setBlockState(pos, state.cycle(ACTIVE), 2);
}
}
}
@ -49,14 +50,14 @@ public class SwitchBlock extends EnergyBlock {
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (state.get(POWERED) && !world.isReceivingRedstonePower(pos)) {
world.setBlockState(pos, state.cycle(POWERED), 2);
if (state.get(ACTIVE) && !world.isReceivingRedstonePower(pos)) {
world.setBlockState(pos, state.cycle(ACTIVE), 2);
}
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(POWERED);
builder.add(POWERED, ACTIVE);
}
@Override

View File

@ -3,6 +3,7 @@ package com.thebrokenrail.energonrelics.block.entity;
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
import com.thebrokenrail.energonrelics.api.energy.Action;
import com.thebrokenrail.energonrelics.block.SwitchBlock;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import net.minecraft.block.entity.BlockEntityType;
public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
@ -12,6 +13,7 @@ public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
@Override
protected void energyTick() {
addAction(Action.createBlockStatePropertyAction(HardcodedConfig.SWITCH_ENERGY_REQUIRED, SwitchBlock.POWERED, true, false));
}
@Override
@ -31,6 +33,6 @@ public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
}
private boolean isActive() {
return getCachedState().get(SwitchBlock.POWERED);
return getCachedState().get(SwitchBlock.ACTIVE) && getCachedState().get(SwitchBlock.POWERED);
}
}

View File

@ -3,9 +3,9 @@ package com.thebrokenrail.energonrelics.block.entity.infuser;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
import com.thebrokenrail.energonrelics.api.energy.Action;
import com.thebrokenrail.energonrelics.api.item.MultimeterExtra;
import com.thebrokenrail.energonrelics.block.InfuserBlock;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.item.MultimeterItem;
import com.thebrokenrail.energonrelics.registry.infuser.data.InfuserAction;
import com.thebrokenrail.energonrelics.registry.infuser.data.InfuserEntry;
import com.thebrokenrail.energonrelics.registry.infuser.InfuserRegistry;
@ -20,7 +20,7 @@ import net.minecraft.util.Formatting;
import java.util.Objects;
public class InfuserBlockEntity extends EnergyReceiverBlockEntity implements MultimeterItem.MultimeterExtra {
public class InfuserBlockEntity extends EnergyReceiverBlockEntity implements MultimeterExtra {
public InfuserBlockEntity(BlockEntityType<?> type) {
super(type);
}

View File

@ -17,7 +17,7 @@ public class ReactorInputBlockEntity extends BlockEntity implements Inventory {
super(type);
}
private final int INVENTORY_SIZE = 5;
public final static int INVENTORY_SIZE = 5;
private final DefaultedList<ItemStack> inv = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY);

View File

@ -0,0 +1,267 @@
package com.thebrokenrail.energonrelics.block.entity.shifter;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
import com.thebrokenrail.energonrelics.api.energy.Action;
import com.thebrokenrail.energonrelics.api.energy.tick.EnergyTickable;
import com.thebrokenrail.energonrelics.api.energy.tick.EnergyTicker;
import com.thebrokenrail.energonrelics.api.item.MultimeterExtra;
import com.thebrokenrail.energonrelics.block.PhaseShifterBlock;
import com.thebrokenrail.energonrelics.block.entity.reactor.ReactorInputBlockEntity;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.util.WeightedList;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.collection.DefaultedList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class PhaseShifterBlockEntity extends EnergyReceiverBlockEntity implements Inventory, MultimeterExtra {
private final static int INVENTORY_SIZE = ReactorInputBlockEntity.INVENTORY_SIZE;
private final DefaultedList<ItemStack> inv = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY);
private int cooldown = 0;
public PhaseShifterBlockEntity(BlockEntityType<?> type) {
super(type);
}
@Override
public int size() {
return inv.size();
}
@Override
public boolean isEmpty() {
boolean empty = false;
for (ItemStack stack : inv) {
if (stack.isEmpty()) {
empty = true;
break;
}
}
return empty;
}
@Override
public ItemStack getStack(int slot) {
return inv.get(slot);
}
@Override
public ItemStack removeStack(int slot, int amount) {
ItemStack stack = Inventories.splitStack(inv, slot, amount);
if (!stack.isEmpty()) {
markDirty();
}
return stack;
}
@Override
public ItemStack removeStack(int slot) {
return Inventories.removeStack(inv, slot);
}
@Override
public void setStack(int slot, ItemStack stack) {
inv.set(slot, stack);
if (stack.getCount() > getMaxCountPerStack()) {
stack.setCount(getMaxCountPerStack());
}
}
@Override
public boolean canPlayerUse(PlayerEntity player) {
if (Objects.requireNonNull(getWorld()).getBlockEntity(getPos()) != this) {
return false;
} else {
return player.squaredDistanceTo((double) getPos().getX() + 0.5D, (double) getPos().getY() + 0.5D, (double) getPos().getZ() + 0.5D) <= 64.0D;
}
}
@Override
public void clear() {
inv.clear();
}
private final List<PhasedItem> phasedItems = new ArrayList<>();
@Override
public void fromTag(BlockState state, CompoundTag tag) {
super.fromTag(state, tag);
inv.clear();
Inventories.fromTag(tag, inv);
cooldown = tag.getInt("Cooldown");
phasedItems.clear();
Tag list = tag.get("PhasedItems");
if (list instanceof ListTag) {
ListTag itemsTag = (ListTag) list;
for (int i = 0; i < itemsTag.size(); i++) {
phasedItems.add(PhasedItem.fromTag(itemsTag.getCompound(i)));
}
}
}
private int canInsert(ItemStack stack) {
if (stack.getCount() <= getMaxCountPerStack()) {
for (int slot = 0; slot < size(); slot++) {
ItemStack oldStack = getStack(slot);
if (oldStack.isItemEqual(stack)) {
int newCount = oldStack.getCount() + stack.getCount();
if (newCount <= Math.min(oldStack.getMaxCount(), getMaxCountPerStack())) {
return slot;
}
}
}
for (int slot = 0; slot < size(); slot++) {
ItemStack oldStack = getStack(slot);
if (oldStack.isEmpty()) {
return slot;
}
}
}
return -1;
}
private long getCost() {
return getCachedState().get(PhaseShifterBlock.IS_OUTPUT) ? HardcodedConfig.PHASE_SHIFTER_OUTPUT_ENERGY_REQUIRED : HardcodedConfig.PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_BASE + (HardcodedConfig.PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_PER_ITEM * phasedItems.size());
}
@Override
protected void energyTick() {
assert getWorld() != null;
addAction(Action.createBlockStatePropertyAction(getCost(), PhaseShifterBlock.POWERED, true, false));
boolean dirty = false;
if (cooldown > 0) {
cooldown--;
dirty = true;
}
if (getCachedState().get(PhaseShifterBlock.POWERED) && !getCachedState().get(PhaseShifterBlock.IS_OUTPUT)) {
List<PhaseShifterBlockEntity> outputs = new ArrayList<>();
for (EnergyTickable tickable : EnergyTicker.allLoaded) {
if (tickable instanceof PhaseShifterBlockEntity && ((PhaseShifterBlockEntity) tickable).getCachedState().get(PhaseShifterBlock.IS_OUTPUT) && Objects.requireNonNull(((PhaseShifterBlockEntity) tickable).getWorld()).getRegistryKey() == getWorld().getRegistryKey() && ((PhaseShifterBlockEntity) tickable).cooldown == 0 && ((PhaseShifterBlockEntity) tickable).getCachedState().get(PhaseShifterBlock.COLOR) == getCachedState().get(PhaseShifterBlock.COLOR)) {
outputs.add((PhaseShifterBlockEntity) tickable);
}
}
if (phasedItems.size() > 0) {
dirty = true;
}
Iterator<PhasedItem> iterator = phasedItems.iterator();
while (iterator.hasNext()) {
PhasedItem item = iterator.next();
if (item.cooldown > 0) {
item.cooldown--;
} else {
Map<PhaseShifterBlockEntity, Integer> validOutputs = new HashMap<>();
for (PhaseShifterBlockEntity output : outputs) {
int slot = output.canInsert(item.item);
if (slot != -1 && output.getPos().isWithinDistance(getPos(), item.getRange())) {
validOutputs.put(output, slot);
}
}
boolean success = validOutputs.size() > 0 && HardcodedConfig.PHASE_SHIFTER_SUCCESS_CHANCE >= getWorld().random.nextFloat();
if (success) {
WeightedList<PhaseShifterBlockEntity> weightedList = new WeightedList<>();
for (PhaseShifterBlockEntity output : validOutputs.keySet()) {
weightedList.add(1, output);
}
PhaseShifterBlockEntity output = weightedList.pick(getWorld().random);
int slot = validOutputs.get(output);
ItemStack stack = item.item.copy();
stack.increment(output.getStack(slot).getCount());
output.setStack(slot, stack);
output.resetCooldown();
output.markDirty();
iterator.remove();
} else {
item.roll++;
item.cooldown = HardcodedConfig.PHASE_SHIFTER_INPUT_ROLL_COOLDOWN;
}
}
}
if (cooldown == 0) {
ItemStack next = ItemStack.EMPTY;
for (int slot = 0; slot < size(); slot++) {
ItemStack stack = getStack(slot);
if (!stack.isEmpty()) {
next = stack.split(1);
}
}
if (!next.isEmpty()) {
phasedItems.add(new PhasedItem(next));
resetCooldown();
dirty = true;
}
}
} else if (phasedItems.size() > 0) {
phasedItems.clear();
dirty = true;
}
if (dirty) {
markDirty();
}
}
private void resetCooldown() {
cooldown = getCachedState().get(PhaseShifterBlock.IS_OUTPUT) ? HardcodedConfig.PHASE_SHIFTER_OUTPUT_COOLDOWN : HardcodedConfig.PHASE_SHIFTER_INPUT_COOLDOWN;
}
@Override
public CompoundTag toTag(CompoundTag tag) {
super.toTag(tag);
Inventories.toTag(tag, inv);
tag.putInt("Cooldown", cooldown);
ListTag itemsTag = new ListTag();
for (PhasedItem item : phasedItems) {
itemsTag.add(item.toTag());
}
tag.put("PhasedItems", itemsTag);
return tag;
}
@Override
public MutableText getExtra() {
return getCachedState().get(PhaseShifterBlock.IS_OUTPUT) ? null : new TranslatableText("text." + EnergonRelics.NAMESPACE + ".phase_shifter_extra", new LiteralText(String.valueOf(phasedItems.size())).formatted(Formatting.WHITE));
}
}

View File

@ -0,0 +1,34 @@
package com.thebrokenrail.energonrelics.block.entity.shifter;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
class PhasedItem {
final ItemStack item;
int cooldown = 0;
int roll = 0;
PhasedItem(ItemStack item) {
this.item = item;
}
int getRange() {
return HardcodedConfig.PHASE_SHIFTER_INPUT_RANGE_BASE + (roll * HardcodedConfig.PHASE_SHIFTER_INPUT_RANGE_INCREMENT);
}
CompoundTag toTag() {
CompoundTag tag = new CompoundTag();
tag.put("Item", item.toTag(new CompoundTag()));
tag.putInt("Cooldown", cooldown);
tag.putInt("Roll", roll);
return tag;
}
static PhasedItem fromTag(CompoundTag tag) {
PhasedItem item = new PhasedItem(ItemStack.fromTag(tag.getCompound("Item")));
item.cooldown = tag.getInt("Cooldown");
item.roll = tag.getInt("Roll");
return item;
}
}

View File

@ -22,6 +22,7 @@ import net.minecraft.world.World;
import java.util.function.Function;
@SuppressWarnings("deprecation")
public class ReactorInputBlock extends SimpleBlockWithEntity {
public ReactorInputBlock() {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.YELLOW_TERRACOTTA).requiresTool().strength(1.5f, 6.0f));
@ -33,7 +34,6 @@ public class ReactorInputBlock extends SimpleBlockWithEntity {
}
@Override
@SuppressWarnings("deprecation")
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
BlockEntity entity = world.getBlockEntity(pos);
if (entity instanceof Inventory) {
@ -45,4 +45,9 @@ public class ReactorInputBlock extends SimpleBlockWithEntity {
return ActionResult.FAIL;
}
}
@Override
protected boolean hasInventory() {
return true;
}
}

View File

@ -1,9 +1,11 @@
package com.thebrokenrail.energonrelics.client;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.PhaseShifterBlock;
import com.thebrokenrail.energonrelics.block.forcefield.util.AbstractFieldBlock;
import com.thebrokenrail.energonrelics.api.block.energy.EnergyBlock;
import com.thebrokenrail.energonrelics.client.config.UserConfig;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
@ -12,6 +14,7 @@ import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
@ -51,6 +54,10 @@ public final class EnergonRelicsClient implements ClientModInitializer {
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.ENERGY_PORTAL_BLOCK, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.ENERGY_BEAM_BLOCK, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.PHASE_SHIFTER_BLOCK, RenderLayer.getCutoutMipped());
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> state.get(PhaseShifterBlock.COLOR).getFireworkColor(), EnergonRelics.PHASE_SHIFTER_BLOCK);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? HardcodedConfig.PHASE_SHIFTER_DEFAULT_COLOR.getFireworkColor() : -1);
AutoConfig.register(UserConfig.class, ReloadSerializer::new);
AttackBlockCallback.EVENT.register((playerEntity, world, hand, blockPos, direction) -> {

View File

@ -3,13 +3,19 @@ package com.thebrokenrail.energonrelics.client.rei;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.client.rei.infuser.InfuserCategory;
import com.thebrokenrail.energonrelics.client.rei.reactor.ReactorFuelCategory;
import me.shedaniel.rei.api.BuiltinPlugin;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeHelper;
import me.shedaniel.rei.api.plugins.REIPluginV0;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import java.util.ArrayList;
import java.util.List;
@Environment(EnvType.CLIENT)
public final class EnergonRelicsPlugin implements REIPluginV0 {
public static final Identifier INFUSING = new Identifier(EnergonRelics.NAMESPACE, "plugin/infusing");
@ -27,6 +33,12 @@ public final class EnergonRelicsPlugin implements REIPluginV0 {
recipeHelper.removeAutoCraftButton(INFUSING);
recipeHelper.removeAutoCraftButton(REACTOR_FUEL);
BuiltinPlugin.getInstance().registerInformation(EntryStack.create(EnergonRelics.CIRCUIT_BOARD_ITEM), new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".information.structure_generation.title"), texts -> {
List<Text> newTexts = new ArrayList<>(texts);
newTexts.add(new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".information.structure_generation.research_complex"));
return newTexts;
});
}
@Override

View File

@ -2,6 +2,7 @@ package com.thebrokenrail.energonrelics.config;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.util.DyeColor;
/**
* Hardcoded Configuration Values
@ -9,6 +10,8 @@ import net.minecraft.item.Items;
public final class HardcodedConfig {
public static final int POWER_RANGE = 64;
public static final long SWITCH_ENERGY_REQUIRED = 2;
public static final int ENERGON_LIGHT_ENERGY_REQUIRED = 5;
public static final long SOLAR_PANEL_MAX_ENERGY_OUTPUT = 50;
@ -53,4 +56,15 @@ public final class HardcodedConfig {
public static final int ENERGY_PORTAL_MULTIPLIER = 16;
public static final int ENERGY_PORTAL_Y_PADDING = 4;
public static final int ENERGY_PORTAL_Y_PADDING_EXTRA_TOP = 3;
public static final long PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_BASE = 112;
public static final long PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_PER_ITEM = 19;
public static final int PHASE_SHIFTER_INPUT_COOLDOWN = 16;
public static final int PHASE_SHIFTER_INPUT_ROLL_COOLDOWN = 6;
public static final int PHASE_SHIFTER_INPUT_RANGE_BASE = 21;
public static final int PHASE_SHIFTER_INPUT_RANGE_INCREMENT = 9;
public static final float PHASE_SHIFTER_SUCCESS_CHANCE = 0.1f;
public static final long PHASE_SHIFTER_OUTPUT_ENERGY_REQUIRED = 28;
public static final int PHASE_SHIFTER_OUTPUT_COOLDOWN = 21;
public static final DyeColor PHASE_SHIFTER_DEFAULT_COLOR = DyeColor.WHITE;
}

View File

@ -3,6 +3,7 @@ package com.thebrokenrail.energonrelics.item;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
import com.thebrokenrail.energonrelics.api.block.entity.helper.EnergyGenerator;
import com.thebrokenrail.energonrelics.api.item.MultimeterExtra;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemUsageContext;
@ -21,10 +22,6 @@ public class MultimeterItem extends Item {
super(new Settings().maxCount(1).group(EnergonRelics.ITEM_GROUP));
}
public interface MultimeterExtra {
MutableText getExtra();
}
public static MutableText format(long value) {
String str;
if (value >= Long.MAX_VALUE) {
@ -61,10 +58,13 @@ public class MultimeterItem extends Item {
}
if (entity instanceof MultimeterExtra) {
if (!world.isClient() && context.getPlayer() != null) {
if (success) {
text.append(separator);
MutableText extraText = ((MultimeterExtra) entity).getExtra();
if (extraText != null) {
if (success) {
text.append(separator);
}
text.append(extraText.formatted(Formatting.YELLOW));
}
text.append(((MultimeterExtra) entity).getExtra().formatted(Formatting.YELLOW));
}
success = true;
}

View File

@ -0,0 +1,16 @@
{
"variants": {
"powered=false,is_output=false": {
"model": "energonrelics:block/phase_shifter_off_input"
},
"powered=true,is_output=false": {
"model": "energonrelics:block/phase_shifter_on_input"
},
"powered=false,is_output=true": {
"model": "energonrelics:block/phase_shifter_off_output"
},
"powered=true,is_output=true": {
"model": "energonrelics:block/phase_shifter_on_output"
}
}
}

View File

@ -1,9 +1,9 @@
{
"variants": {
"powered=false": {
"active=false": {
"model": "energonrelics:block/switch_off"
},
"powered=true": {
"active=true": {
"model": "energonrelics:block/switch_on"
}
}

View File

@ -61,5 +61,9 @@
"category.rei.energonrelics.infusing.display_item.minecraft.tnt": "Explosion",
"category.rei.energonrelics.infusing.display_item.minecraft.fire_charge": "Nothing",
"category.rei.energonrelics.reactor_fuel.name": "Reactor Fuel",
"category.rei.energonrelics.reactor_fuel.multiplier": "%sx Reaction"
"category.rei.energonrelics.reactor_fuel.multiplier": "%sx Reaction",
"block.energonrelics.phase_shifter": "Phase Shifter",
"text.energonrelics.phase_shifter_extra": "Phased Items: %s",
"category.rei.energonrelics.information.structure_generation.title": "Structures",
"category.rei.energonrelics.information.structure_generation.research_complex": "Found In The Research Complex Underground Structure"
}

View File

@ -0,0 +1,33 @@
{
"parent": "minecraft:block/block",
"textures": {
"particle": "#all",
"tint": "energonrelics:block/phase_shifter_tint"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down"},
"up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up"},
"north": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "north"},
"south": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "south"},
"west": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "west"},
"east": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "east"}
}
},
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"down": {"uv": [0, 0, 16, 16], "texture": "#tint", "cullface": "down", "tintindex": 0},
"up": {"uv": [0, 0, 16, 16], "texture": "#tint", "cullface": "up", "tintindex": 0},
"north": {"uv": [0, 0, 16, 16], "texture": "#tint", "cullface": "north", "tintindex": 0},
"south": {"uv": [0, 0, 16, 16], "texture": "#tint", "cullface": "south", "tintindex": 0},
"west": {"uv": [0, 0, 16, 16], "texture": "#tint", "cullface": "west", "tintindex": 0},
"east": {"uv": [0, 0, 16, 16], "texture": "#tint", "cullface": "east", "tintindex": 0}
}
}
]
}

View File

@ -0,0 +1,6 @@
{
"parent": "energonrelics:block/phase_shifter",
"textures": {
"all": "energonrelics:block/phase_shifter_off_input"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "energonrelics:block/phase_shifter",
"textures": {
"all": "energonrelics:block/phase_shifter_off_output"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "energonrelics:block/phase_shifter",
"textures": {
"all": "energonrelics:block/phase_shifter_on_input"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "energonrelics:block/phase_shifter",
"textures": {
"all": "energonrelics:block/phase_shifter_on_output"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "energonrelics:block/phase_shifter_off_input"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "energonrelics:phase_shifter"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,18 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"#I#",
"IGI",
"#I#"
"#G#",
"GSG",
"#G#"
],
"key": {
"#": {
"item": "energonrelics:circuit_board"
},
"I": {
"item": "minecraft:iron_ingot"
},
"G": {
"item": "minecraft:glass"
},
"S": {
"item": "minecraft:glowstone"
}
},

View File

@ -2,7 +2,7 @@
"type": "minecraft:crafting_shaped",
"pattern": [
"#I#",
"IGI",
"IMI",
"#I#"
],
"key": {
@ -12,8 +12,8 @@
"I": {
"item": "minecraft:iron_ingot"
},
"G": {
"item": "minecraft:glowstone"
"M": {
"item": "minecraft:magma_block"
}
},
"result": {

View File

@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"#I#",
"IEI",
"#I#"
],
"key": {
"#": {
"item": "energonrelics:circuit_board"
},
"I": {
"item": "minecraft:iron_ingot"
},
"E": {
"item": "minecraft:ender_pearl"
}
},
"result": {
"item": "energonrelics:phase_shifter",
"count": 2
}
}