redstone over radio item counter

This commit is contained in:
Boblet 2023-07-06 15:33:05 +02:00
parent 69fc7b826f
commit e78406f64f
17 changed files with 514 additions and 51 deletions

View File

@ -2,13 +2,23 @@
* Industrial boiler
* A slightly taller variant of the boiler with higher capacity
* Unlike the regular boiler, it can't explode
* Redstone-over-radio counter
* Can count and send the amount of an item stored in a container
* Counting supports filters by item ID, ID+meta and ore dictionary names
* Each torch can count up to three items and output the results on different channels
* This allows for more precise control over things like assembler chests, like turning off the ejector for an item that is already full but not other ejectors
* This property makes automating things with multiple inputs a lot easier
* Due to the ore dictionary ability of the counter, buffered items can precisely match the requirements of the recipe
## Changed
* The regular boiler now only holds 16k instead of 64k (which is still a lot)
* Added labels to the large mining drill's levers
* Glyphid eggs can now be broken apart using an anvil, yielding glyphid meat, bones and experience bottles
* The assembler now uses the new multiblock system, making it less annoying to playe and less ear-piercing to break
* The conversion happens automatically so it's not necessary to remove the assemblers beforehand
## Fixed
* Fixed quantity of the fusion reactor's construction recipe not being displayed right
* Fixed fluid valve and redstone fluid valves having the wrong names
* Fixed mobs' max health getting buffed by pollution, but the actual health staying the same
* Fixed bug regarding the loot pools of satellite miners

View File

@ -793,6 +793,7 @@ public class ModBlocks {
public static Block fluid_switch;
public static Block radio_torch_sender;
public static Block radio_torch_receiver;
public static Block radio_torch_counter;
public static Block conveyor;
//public static Block conveyor_classic;
@ -1942,6 +1943,7 @@ public class ModBlocks {
fluid_switch = new FluidSwitch(Material.iron).setBlockName("fluid_switch").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
radio_torch_sender = new RadioTorchSender().setBlockName("radio_torch_sender").setHardness(0.1F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
radio_torch_receiver = new RadioTorchReceiver().setBlockName("radio_torch_receiver").setHardness(0.1F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
radio_torch_counter = new RadioTorchCounter().setBlockName("radio_torch_counter").setHardness(0.1F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":rtty_counter");
conveyor = new BlockConveyor().setBlockName("conveyor").setHardness(2.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor");
//conveyor_classic = new BlockConveyorClassic().setBlockName("conveyor_classic").setHardness(2.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor");
@ -3172,6 +3174,7 @@ public class ModBlocks {
register(fluid_switch);
register(radio_torch_sender);
register(radio_torch_receiver);
register(radio_torch_counter);
GameRegistry.registerBlock(crane_extractor, crane_extractor.getUnlocalizedName());
GameRegistry.registerBlock(crane_inserter, crane_inserter.getUnlocalizedName());

View File

@ -1,15 +1,11 @@
package com.hbm.blocks.network;
import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.inventory.gui.GUIScreenRadioTorch;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.network.TileEntityRadioTorchBase;
import com.hbm.util.I18nUtil;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
@ -18,25 +14,21 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Base class for all torch-like RTTY blocks
* @author hbm
*/
public abstract class RadioTorchBase extends BlockContainer implements IGUIProvider, ILookOverlay, ITooltipProvider {
@SideOnly(Side.CLIENT) protected IIcon iconOn;
public RadioTorchBase() {
super(Material.circuits);
}
@ -87,12 +79,6 @@ public abstract class RadioTorchBase extends BlockContainer implements IGUIProvi
return super.collisionRayTrace(world, x, y, z, vec0, vec1);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return side == 0 ? this.blockIcon : this.iconOn;
}
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float fX, float fY, float fZ, int meta) {
return side;
@ -130,36 +116,9 @@ public abstract class RadioTorchBase extends BlockContainer implements IGUIProvi
return !player.isSneaking();
}
}
@Override
@SideOnly(Side.CLIENT)
public void printHook(Pre event, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityRadioTorchBase) {
TileEntityRadioTorchBase radio = (TileEntityRadioTorchBase) te;
List<String> text = new ArrayList();
if(radio.channel != null && !radio.channel.isEmpty()) text.add(EnumChatFormatting.AQUA + "Freq: " + radio.channel);
text.add(EnumChatFormatting.RED + "Signal: " + radio.lastState);
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
addStandardInfo(stack, player, list, ext);
}
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; }
@Override
@SideOnly(Side.CLIENT)
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityRadioTorchBase)
return new GUIScreenRadioTorch((TileEntityRadioTorchBase) te);
return null;
}
}

View File

@ -0,0 +1,70 @@
package com.hbm.blocks.network;
import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.ILookOverlay;
import com.hbm.inventory.container.ContainerCounterTorch;
import com.hbm.inventory.gui.GUICounterTorch;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.network.TileEntityRadioTorchCounter;
import com.hbm.util.I18nUtil;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
public class RadioTorchCounter extends RadioTorchBase {
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(!world.isRemote && !player.isSneaking()) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true;
} else {
return !player.isSneaking();
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityRadioTorchCounter();
}
@Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerCounterTorch(player.inventory, (TileEntityRadioTorchCounter) world.getTileEntity(x, y, z));
}
@Override
@SideOnly(Side.CLIENT)
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUICounterTorch(player.inventory, (TileEntityRadioTorchCounter) world.getTileEntity(x, y, z));
}
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityRadioTorchCounter) {
TileEntityRadioTorchCounter radio = (TileEntityRadioTorchCounter) te;
List<String> text = new ArrayList();
for(int i = 0; i < 3; i++) {
if(!radio.channel[i].isEmpty()) {
text.add(EnumChatFormatting.AQUA + "Freq " + (i + 1) + ": " + radio.channel[i]);
text.add(EnumChatFormatting.RED + "Signal " + (i + 1) + ": " + radio.lastCount[i]);
}
}
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
}
}

View File

@ -0,0 +1,62 @@
package com.hbm.blocks.network;
import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.ILookOverlay;
import com.hbm.inventory.gui.GUIScreenRadioTorch;
import com.hbm.tileentity.network.TileEntityRadioTorchBase;
import com.hbm.util.I18nUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
/**
* Base class for the basic sender and receiver RTTY torch
* @author hbm
*/
public abstract class RadioTorchRWBase extends RadioTorchBase {
@SideOnly(Side.CLIENT) protected IIcon iconOn;
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return side == 0 ? this.blockIcon : this.iconOn;
}
@Override
@SideOnly(Side.CLIENT)
public void printHook(Pre event, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityRadioTorchBase) {
TileEntityRadioTorchBase radio = (TileEntityRadioTorchBase) te;
List<String> text = new ArrayList();
if(radio.channel != null && !radio.channel.isEmpty()) text.add(EnumChatFormatting.AQUA + "Freq: " + radio.channel);
text.add(EnumChatFormatting.RED + "Signal: " + radio.lastState);
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
}
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; }
@Override
@SideOnly(Side.CLIENT)
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityRadioTorchBase)
return new GUIScreenRadioTorch((TileEntityRadioTorchBase) te);
return null;
}
}

View File

@ -10,7 +10,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class RadioTorchReceiver extends RadioTorchBase {
public class RadioTorchReceiver extends RadioTorchRWBase {
public RadioTorchReceiver() {
super();

View File

@ -9,7 +9,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class RadioTorchSender extends RadioTorchBase {
public class RadioTorchSender extends RadioTorchRWBase {
public RadioTorchSender() {
super();

View File

@ -0,0 +1,76 @@
package com.hbm.inventory.container;
import com.hbm.tileentity.network.TileEntityRadioTorchCounter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerCounterTorch extends Container {
protected TileEntityRadioTorchCounter radio;
public ContainerCounterTorch(InventoryPlayer invPlayer, TileEntityRadioTorchCounter radio) {
this.radio = radio;
for(int i = 0; i < 3; i++) {
this.addSlotToContainer(new Slot(radio, i, 138, 18 + 44 * i));
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 12 + j * 18, 156 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 12 + i * 18, 214));
}
}
@Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { return null; }
@Override
public boolean canInteractWith(EntityPlayer player) {
return radio.isUseableByPlayer(player);
}
@Override
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
//L/R: 0
//M3: 3
//SHIFT: 1
//DRAG: 5
if(index < 0 || index > 2) {
return super.slotClick(index, button, mode, player);
}
Slot slot = this.getSlot(index);
ItemStack ret = null;
ItemStack held = player.inventory.getItemStack();
if(slot.getHasStack())
ret = slot.getStack().copy();
if(button == 1 && mode == 0 && slot.getHasStack()) {
radio.matcher.nextMode(radio.getWorldObj(), slot.getStack(), index);
return ret;
} else {
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
radio.matcher.initPatternStandard(radio.getWorldObj(), slot.getStack(), index);
return ret;
}
}
}

View File

@ -0,0 +1,151 @@
package com.hbm.inventory.gui;
import java.util.Arrays;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerCounterTorch;
import com.hbm.lib.RefStrings;
import com.hbm.packet.NBTControlPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.network.TileEntityRadioTorchCounter;
import com.hbm.util.I18nUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
public class GUICounterTorch extends GuiInfoContainer {
protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_rtty_counter.png");
protected TileEntityRadioTorchCounter counter;
protected GuiTextField[] frequency;
public GUICounterTorch(InventoryPlayer invPlayer, TileEntityRadioTorchCounter counter) {
super(new ContainerCounterTorch(invPlayer, counter));
this.counter = counter;
this.xSize = 218;
this.ySize = 238;
}
@Override
public void initGui() {
super.initGui();
Keyboard.enableRepeatEvents(true);
this.frequency = new GuiTextField[3];
for(int i = 0; i < 3; i++) {
this.frequency[i] = new GuiTextField(this.fontRendererObj, guiLeft + 29, guiTop + 21 + 44 * i, 86, 14);
this.frequency[i].setTextColor(0x00ff00);
this.frequency[i].setDisabledTextColour(0x00ff00);
this.frequency[i].setEnableBackgroundDrawing(false);
this.frequency[i].setMaxStringLength(10);
this.frequency[i].setText(counter.channel[i] == null ? "" : counter.channel[i]);
}
}
@Override
public void drawScreen(int x, int y, float interp) {
super.drawScreen(x, y, interp);
if(guiLeft + 193 <= x && guiLeft + 193 + 18 > x && guiTop + 8 < y && guiTop + 8 + 18 >= y) {
func_146283_a(Arrays.asList(new String[] { counter.polling ? "Polling" : "State Change" }), x, y);
}
if(guiLeft + 193 <= x && guiLeft + 193 + 18 > x && guiTop + 30 < y && guiTop + 30 + 18 >= y) {
func_146283_a(Arrays.asList(new String[] { "Save Settings" }), x, y);
}
if(this.mc.thePlayer.inventory.getItemStack() == null) {
for(int i = 0; i < 3; ++i) {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i);
if(this.isMouseOverSlot(slot, x, y) && counter.matcher.modes[i] != null) {
String label = EnumChatFormatting.YELLOW + "";
switch(counter.matcher.modes[i]) {
case "exact": label += "Item and meta match"; break;
case "wildcard": label += "Item matches"; break;
default: label += "Ore dict key matches: " + counter.matcher.modes[i]; break;
}
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);
}
}
}
}
@Override
protected void mouseClicked(int x, int y, int i) {
super.mouseClicked(x, y, i);
/*for(int j = 0; j < 3; j++) this.frequency[j].mouseClicked(x, y, i);
if(guiLeft + 193 <= x && guiLeft + 193 + 18 > x && guiTop + 8 < y && guiTop + 8 + 18 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
NBTTagCompound data = new NBTTagCompound();
data.setBoolean("polling", true);
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, counter.xCoord, counter.yCoord, counter.zCoord));
}
if(guiLeft + 193 <= x && guiLeft + 193 + 18 > x && guiTop + 30 < y && guiTop + 30 + 18 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
NBTTagCompound data = new NBTTagCompound();
for(int j = 0; j < 3; j++) data.setString("c" + j, this.frequency[j].getText());
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, counter.xCoord, counter.yCoord, counter.zCoord));
}*/
}
@Override
protected void drawGuiContainerForegroundLayer(int x, int y) {
String name = I18nUtil.resolveKey(this.counter.getInventoryName());
this.fontRendererObj.drawString(name, 184 / 2 - this.fontRendererObj.getStringWidth(name) / 2, this.guiTop + 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 16, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float interp, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(counter.polling) {
drawTexturedModalRect(guiLeft + 193, guiTop + 8, 218, 0, 18, 18);
}
for(int i = 0; i < 3; i++) this.frequency[i].drawTextBox();
}
@Override
protected void keyTyped(char c, int i) {
//for(int j = 0; j < 3; j++) if(this.frequency[j].textboxKeyTyped(c, i)) return;
super.keyTyped(c, i);
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
Keyboard.enableRepeatEvents(false);
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
}

View File

@ -253,6 +253,7 @@ public class CraftingManager {
addRecipeAuto(new ItemStack(ModBlocks.radio_torch_sender, 4), new Object[] { "G", "R", "I", 'G', "dustGlowstone", 'R', Blocks.redstone_torch, 'I', NETHERQUARTZ.gem() });
addRecipeAuto(new ItemStack(ModBlocks.radio_torch_receiver, 4), new Object[] { "G", "R", "I", 'G', "dustGlowstone", 'R', Blocks.redstone_torch, 'I', IRON.ingot() });
addRecipeAuto(new ItemStack(ModBlocks.radio_torch_counter, 4), new Object[] { "G", "R", "I", 'G', "dustGlowstone", 'R', Blocks.redstone_torch, 'I', ModItems.circuit_aluminium });
addRecipeAuto(new ItemStack(ModBlocks.conveyor, 16), new Object[] { "LLL", "I I", "LLL", 'L', Items.leather, 'I', IRON.ingot() });
addRecipeAuto(new ItemStack(ModBlocks.conveyor, 16), new Object[] { "RSR", "I I", "RSR", 'I', IRON.ingot(), 'R', DictFrame.fromOne(ModItems.plant_item, EnumPlantType.ROPE), 'S', IRON.plate() });

View File

@ -83,11 +83,10 @@ public abstract class TileEntityMachineBase extends TileEntityLoadedBase impleme
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
{
if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) {
return false;
}else{
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=128;
} else {
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 128;
}
}

View File

@ -372,6 +372,7 @@ public class TileMappings {
put(TileEntityRadioTorchSender.class, "tileentity_rtty_sender");
put(TileEntityRadioTorchReceiver.class, "tileentity_rtty_rec");
put(TileEntityRadioTorchCounter.class, "tileentity_rtty_counter");
}
private static void put(Class<? extends TileEntity> clazz, String... names) {

View File

@ -0,0 +1,125 @@
package com.hbm.tileentity.network;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.Compat;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityRadioTorchCounter extends TileEntityMachineBase implements IControlReceiver {
public String[] channel;
public int[] lastCount;
public boolean polling = false;
public ModulePatternMatcher matcher;
public TileEntityRadioTorchCounter() {
super(3);
this.channel = new String[3];
for(int i = 0; i < 3; i++) this.channel[i] = "";
this.lastCount = new int[3];
this.matcher = new ModulePatternMatcher(3);
}
@Override
public String getName() {
return "container.rttyCounter";
}
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite();
TileEntity tile = Compat.getTileStandard(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
if(tile instanceof IInventory) {
IInventory inv = (IInventory) tile;
ItemStack[] invSlots = new ItemStack[inv.getSizeInventory()];
for(int i = 0; i < invSlots.length; i++) invSlots[i] = inv.getStackInSlot(i);
for(int i = 0; i < 3; i++) {
if(channel[i].isEmpty()) continue;
if(slots[i] == null) continue;
ItemStack pattern = slots[i];
int count = 0;
for(int j = 0; j < invSlots.length; j++) {
if(invSlots[j] != null && matcher.isValidForFilter(pattern, i, invSlots[j])) {
count += invSlots[j].stackSize;
}
}
if(this.polling || this.lastCount[i] != count) {
RTTYSystem.broadcast(worldObj, this.channel[i], count);
}
this.lastCount[i] = count;
}
}
NBTTagCompound data = new NBTTagCompound();
data.setBoolean("polling", polling);
data.setIntArray("last", lastCount);
this.matcher.writeToNBT(data);
for(int i = 0; i < 3; i++) if(channel[i] != null) data.setString("c" + i, channel[i]);
this.networkPack(data, 15);
}
}
public void networkUnpack(NBTTagCompound nbt) {
this.polling = nbt.getBoolean("polling");
this.lastCount = nbt.getIntArray("last");
this.matcher.modes = new String[this.matcher.modes.length];
this.matcher.readFromNBT(nbt);
for(int i = 0; i < 3; i++) this.channel[i] = nbt.getString("c" + i);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.polling = nbt.getBoolean("p");
for(int i = 0; i < 3; i++) {
this.channel[i] = nbt.getString("c" + i);
this.lastCount[i] = nbt.getInteger("l" + i);
}
this.matcher.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("p", polling);
for(int i = 0; i < 3; i++) {
if(channel[i] != null) nbt.setString("c" + i, channel[i]);
nbt.setInteger("l" + i, lastCount[i]);
}
this.matcher.writeToNBT(nbt);
}
@Override
public boolean hasPermission(EntityPlayer player) {
return this.isUseableByPlayer(player);
}
@Override
public void receiveControl(NBTTagCompound data) {
if(data.hasKey("polling")) {
this.polling = !this.polling;
this.markChanged();
} else {
System.out.println("guh");
for(int i = 0; i < 3; i++) {
this.channel[i] = data.getString("c" + i);
}
this.markChanged();
}
}
}

View File

@ -392,6 +392,7 @@ container.reactorSmall=Atomreaktor
container.reix=Rei-X Hauptrechner
container.rtg=Radioisotopengenerator
container.rtgFurnace=RTG-Ofen
container.rttyCounter=Redstone-over-Radio Itemzähler
container.rttyReceiver=Redstone-over-Radio Empfänger
container.rttySender=Redstone-over-Radio Sender
container.safe=Panzerschrank
@ -4197,6 +4198,8 @@ tile.pribris.name=RBMK-Schutt
tile.pribris_burning.name=Flammender RBMK-Schutt
tile.pribris_digamma.name=Geschwärzter RBMK-Schutt
tile.pribris_radiating.name=Glühender RBMK-Schutt
tile.radio_torch_counter.name=Redstone-over-Radio Itemzähler
tile.radio_torch_counter.desc=Kann auf ebenen Flächen oder Komparator-kompatiblen Blöcken platziert werden$Signal basiert auf Anzahl passender Items
tile.radio_torch_receiver.name=Redstone-over-Radio Empfänger
tile.radio_torch_receiver.desc=Kann auf ebenen Flächen oder Komparator-kompatiblen Blöcken platziert werden
tile.radio_torch_sender.name=Redstone-over-Radio Sender

View File

@ -730,6 +730,7 @@ container.reactorResearch=Research Reactor
container.reix=Rei-X Mainframe
container.rtg=RT Generator
container.rtgFurnace=RTG Furnace
container.rttyCounter=Redstone-over-Radio Item Counter
container.rttyReceiver=Redstone-over-Radio Receiver
container.rttySender=Redstone-over-Radio Transmitter
container.safe=Safe
@ -5075,6 +5076,8 @@ tile.pribris.name=RBMK Debris
tile.pribris_burning.name=Flaming RBMK Debris
tile.pribris_digamma.name=Blackened RBMK Debris
tile.pribris_radiating.name=Smoldering RBMK Debris
tile.radio_torch_counter.name=Redstone-over-Radio Item Counter
tile.radio_torch_counter.desc=Placable on flat surfaces or comparator-compatible blocks$Bases signal on the amount of matching items
tile.radio_torch_receiver.name=Redstone-over-Radio Receiver
tile.radio_torch_receiver.desc=Placable on flat surfaces or comparator-compatible blocks
tile.radio_torch_sender.name=Redstone-over-Radio Transmitter

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB