package mcjty.xnet.blocks.redstoneproxy;

import mcjty.lib.McJtyRegister;
import mcjty.xnet.XNet;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;

import javax.annotation.Nullable;
import java.util.List;

public class RedstoneProxyUBlock extends RedstoneProxyBlock {

    public RedstoneProxyUBlock() {
        super(Material.IRON);
        setUnlocalizedName(XNet.MODID + ".redstone_proxy_upd");
        setRegistryName("redstone_proxy_upd");
        McJtyRegister.registerLater(this, XNet.instance, null);
        McJtyRegister.registerLater(new ItemBlock(this).setRegistryName(getRegistryName()), XNet.instance);
        setCreativeTab(XNet.tabXNet);
    }

    @Override
    public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, ITooltipFlag advanced) {
        tooltip.add("Acts as a proxy block for");
        tooltip.add("redstone. XNet can connect to this");
        tooltip.add(TextFormatting.YELLOW + "This version does a block update!");
    }

    @Override
    public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
        worldIn.notifyNeighborsOfStateChange(pos, this, true);
    }
}

@@ -499,28 +499,77 @@
 le;%0A
-import java.util.Lis
+%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Se
 t;%0A%0A
@@ -1347,32 +1347,91 @@
 date!%22);%0A    %7D%0A%0A
+    private Set%3CBlockPos%3E loopDetector = new HashSet%3C%3E();%0A%0A
     @Override%0A  
@@ -1420,32 +1420,32 @@
 %0A%0A    @Override%0A
-
     public void 
@@ -1555,62 +1555,214 @@
     
-worldIn.notifyNeighborsOfStateChange(pos, this, true);
+if(loopDetector.add(pos)) %7B%0A            try %7B%0A                worldIn.notifyNeighborsOfStateChange(pos, this, true);%0A            %7D finally %7B%0A                loopDetector.remove(pos);%0A            %7D%0A        %7D
 %0A   

Fix #230