Skip to content

Commit

Permalink
refactor IInfraComparator to IEncoderScannable
Browse files Browse the repository at this point in the history
  • Loading branch information
LemmaEOF committed Jul 25, 2018
1 parent e6e5f70 commit f7d30bd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/elytradev/infraredstone/InfraRedstone.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import com.elytradev.concrete.network.NetworkContext;
import com.elytradev.infraredstone.container.OscillatorContainer;
import com.elytradev.infraredstone.logic.IEncoderScannable;
import com.elytradev.infraredstone.logic.network.PacketButtonClick;
import com.elytradev.infraredstone.tile.TileEntityOscillator;
import com.elytradev.concrete.inventory.IContainerInventoryHolder;
import com.elytradev.concrete.inventory.gui.client.ConcreteGui;
import com.elytradev.infraredstone.block.ModBlocks;
import com.elytradev.infraredstone.client.InRedTab;
import com.elytradev.infraredstone.item.ModItems;
import com.elytradev.infraredstone.logic.IInfraComparator;
import com.elytradev.infraredstone.logic.IInfraRedstone;
import com.elytradev.infraredstone.logic.InRedLogic;
import com.elytradev.infraredstone.logic.impl.InfraComparatorSerializer;
Expand Down Expand Up @@ -58,8 +58,8 @@ public class InfraRedstone {

@CapabilityInject(IInfraRedstone.class)
public static final Capability<IInfraRedstone> CAPABILITY_IR = null;
@CapabilityInject(IInfraComparator.class)
public static final Capability<IInfraComparator> CAPABILITY_IR_COMPARATOR = null;
@CapabilityInject(IEncoderScannable.class)
public static final Capability<IEncoderScannable> CAPABILITY_IR_COMPARATOR = null;

static {
FluidRegistry.enableUniversalBucket();
Expand All @@ -77,7 +77,7 @@ public void preInit(FMLPreInitializationEvent event) {
CONTEXT.register(PacketButtonClick.class);

CapabilityManager.INSTANCE.register(IInfraRedstone.class, new InfraRedstoneSerializer(), InfraRedstoneHandler::new);
CapabilityManager.INSTANCE.register(IInfraComparator.class, new InfraComparatorSerializer(), InfraRedstoneHandler::new);
CapabilityManager.INSTANCE.register(IEncoderScannable.class, new InfraComparatorSerializer(), InfraRedstoneHandler::new);

MinecraftForge.EVENT_BUS.register(InRedRecipes.class);
MinecraftForge.EVENT_BUS.register(InRedLogic.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This Capability describes an "inspection" signal value to InfraComparators.
*/
public interface IInfraComparator {
public interface IEncoderScannable {
/**
* @return a value from 0-63 depending on the state of your object.
* It may be helpful to format the value in binaru: `0b00_0000`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import net.minecraft.world.World;

/**
* Version of IInfraComparator that can be implemented by non-TE Blocks.
* Version of IEncoderScannable that can be implemented by non-TE Blocks.
*/
public interface ISimpleInfraComparator {
public interface ISimpleEncoderScannable {

/**
* Has extra information from the standard IInfraComparator to compensate for not having a TE
* Has extra information from the standard IEncoderScannable to compensate for not having a TE
* @param world the current world.
* @param pos the position of your object.
* @param state the current blockstate of your object.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.elytradev.infraredstone.logic.impl;

import com.elytradev.infraredstone.logic.IInfraComparator;
import com.elytradev.infraredstone.logic.IEncoderScannable;

import net.minecraft.nbt.NBTBase;
import net.minecraft.util.EnumFacing;
Expand All @@ -9,13 +9,13 @@
/**
* Don't use. Comparator readers don't store any data.
*/
public class InfraComparatorSerializer implements Capability.IStorage<IInfraComparator>{
public class InfraComparatorSerializer implements Capability.IStorage<IEncoderScannable>{
@Override
public NBTBase writeNBT(Capability<IInfraComparator> capability, IInfraComparator instance, EnumFacing side) {
public NBTBase writeNBT(Capability<IEncoderScannable> capability, IEncoderScannable instance, EnumFacing side) {
return null;
}

@Override
public void readNBT(Capability<IInfraComparator> capability, IInfraComparator instance, EnumFacing side, NBTBase nbt) {
public void readNBT(Capability<IEncoderScannable> capability, IEncoderScannable instance, EnumFacing side, NBTBase nbt) {
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.elytradev.infraredstone.logic.impl;

import com.elytradev.infraredstone.logic.IInfraComparator;
import com.elytradev.infraredstone.logic.IEncoderScannable;
import com.elytradev.infraredstone.logic.IInfraRedstone;

public class InfraRedstoneHandler implements IInfraRedstone, IInfraComparator {
public class InfraRedstoneHandler implements IInfraRedstone, IEncoderScannable {
public static final IInfraRedstone ALWAYS_OFF = new IInfraRedstone() {
@Override
public int getSignalValue() { return 0; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.elytradev.infraredstone.block.BlockBase;
import com.elytradev.infraredstone.block.BlockEncoder;
import com.elytradev.infraredstone.block.ModBlocks;
import com.elytradev.infraredstone.logic.IInfraComparator;
import com.elytradev.infraredstone.logic.IEncoderScannable;
import com.elytradev.infraredstone.logic.IMultimeterProbe;
import com.elytradev.infraredstone.logic.ISimpleInfraComparator;
import com.elytradev.infraredstone.logic.ISimpleEncoderScannable;
import com.elytradev.infraredstone.logic.InRedLogic;
import com.elytradev.infraredstone.logic.impl.InfraRedstoneHandler;
import com.google.common.base.Predicates;
Expand Down Expand Up @@ -41,10 +41,10 @@ public void update() {
EnumFacing back = state.getValue(BlockEncoder.FACING).getOpposite();
BlockPos backPos = this.getPos().offset(back);
IBlockState quantify = world.getBlockState(backPos);
if (quantify instanceof IInfraComparator) {
signal.setNextSignalValue(((IInfraComparator) quantify).getComparatorValue());
} else if (quantify instanceof ISimpleInfraComparator) {
signal.setNextSignalValue(((ISimpleInfraComparator) quantify).getComparatorValue(world, backPos, quantify, back.getOpposite()));
if (quantify instanceof IEncoderScannable) {
signal.setNextSignalValue(((IEncoderScannable) quantify).getComparatorValue());
} else if (quantify instanceof ISimpleEncoderScannable) {
signal.setNextSignalValue(((ISimpleEncoderScannable) quantify).getComparatorValue(world, backPos, quantify, back.getOpposite()));
} else if (quantify.hasComparatorInputOverride()) {
signal.setNextSignalValue(4*quantify.getComparatorInputOverride(world, backPos));
} else {
Expand Down

0 comments on commit f7d30bd

Please sign in to comment.