diff --git a/build.gradle b/build.gradle index 6d87b0d..105355f 100644 --- a/build.gradle +++ b/build.gradle @@ -373,7 +373,7 @@ catch (Exception ignored) { // Pulls version first from the VERSION env and then git tag String identifiedVersion = null -String versionOverride = '0.0.17p15' +String versionOverride = '0.0.17p16' try { // Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty if (versionOverride == null) { diff --git a/src/main/java/reobf/proghatches/block/BlockAnchorAlert.java b/src/main/java/reobf/proghatches/block/BlockAnchorAlert.java new file mode 100644 index 0000000..01526ec --- /dev/null +++ b/src/main/java/reobf/proghatches/block/BlockAnchorAlert.java @@ -0,0 +1,83 @@ +package reobf.proghatches.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; + +public class BlockAnchorAlert extends BlockContainer{ + + public BlockAnchorAlert(Material p_i45386_1_) { + super(p_i45386_1_); + + setHardness(1); + setHarvestLevel("pickaxe", 1); + setBlockName("proghatch.chunk_loading_alert"); + } +@Override +public void onBlockPlacedBy(World worldIn, int x, int y, int z, EntityLivingBase placer, ItemStack itemIn) { + + super.onBlockPlacedBy(worldIn, x, y, z, placer, itemIn); + + if(placer instanceof EntityPlayer){ + if(!(placer instanceof FakePlayer)) + ((TileAnchorAlert)worldIn.getTileEntity(x, y, z)).mark((EntityPlayer) placer); + } + + +}@Override +public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { + if(worldIn.isRemote)return true; + TileAnchorAlert a=((TileAnchorAlert)worldIn.getTileEntity(x, y, z)); + + if(player.getUniqueID().equals(a.owner)==false){ + player.addChatComponentMessage(new ChatComponentTranslation("proghatch.chunk_loading_alert.owner")); + return false;} + a.mode++; + if(a.mode>3)a.mode=0; + a.markDirty(); + player.addChatComponentMessage(new ChatComponentTranslation("proghatch.chunk_loading_alert.mode."+a.mode)); + + + + + return true; +} + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + + return new TileAnchorAlert(); + } + +@SideOnly(value=Side.CLIENT) +@Override +public IIcon getIcon(int side, int meta) { + + if(side<=1)return top; + + return this.side; +} +@SideOnly(value=Side.CLIENT) +IIcon side; +@SideOnly(value=Side.CLIENT) +IIcon top; +@SideOnly(value=Side.CLIENT) +@Override +public void registerBlockIcons(IIconRegister reg) { + side=reg.registerIcon("proghatches:speech_box_front"); + top=reg.registerIcon("proghatches:BlockSpatialPylon_dim"); + + super.registerBlockIcons(reg); +} + +} diff --git a/src/main/java/reobf/proghatches/block/ChunkTrackingGridCahce.java b/src/main/java/reobf/proghatches/block/ChunkTrackingGridCahce.java new file mode 100644 index 0000000..855c2d5 --- /dev/null +++ b/src/main/java/reobf/proghatches/block/ChunkTrackingGridCahce.java @@ -0,0 +1,214 @@ +package reobf.proghatches.block; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; +import java.util.WeakHashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArraySet; + +import appeng.api.networking.IGrid; +import appeng.api.networking.IGridBlock; +import appeng.api.networking.IGridHost; +import appeng.api.networking.IGridNode; +import appeng.api.networking.IGridStorage; +import appeng.api.util.DimensionalCoord; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +public class ChunkTrackingGridCahce implements IChunkTrackingGridCahce{ + public ChunkTrackingGridCahce(final IGrid g) { + this.myGrid = g; + callbacks.put(this, null); + } + private final IGrid myGrid; + + public static WeakHashMap callbacks=new WeakHashMap<>(); + + + + static class ChunkInfo implements Cloneable{ + + public String toString() { + + return chunkx+" "+ chunky+" "+dim; + + }; + ChunkInfo(int worldx,int worldy,World w){ + this.chunkx=worldx>>4; + this.chunky=worldy>>4; + this.dim=w.provider.dimensionId; + } + final int chunkx,chunky; + final int dim; + @Override + public boolean equals(Object obj) { + if(obj==null)return false; + if(!(obj instanceof ChunkInfo))return false; + ChunkInfo other=(ChunkInfo)obj; + return chunkx==other.chunkx&& + chunky==other.chunky&& + dim==other.dim; + } + @Override + public int hashCode() { + return chunkx^chunky^dim; + } + + + } + + + public HashMap track=new HashMap<>(); + + + @Override + public void onUpdateTick() { + // System.out.println(this.hashCode()+" "+track); + ; + } + + @Override + public void removeNode(IGridNode gridNode, IGridHost machine) { + if(machine instanceof TileAnchorAlert){ + terminals.remove((TileAnchorAlert) machine); + } +IGridBlock gb = gridNode.getGridBlock(); + + if(gb.isWorldAccessible()){ + DimensionalCoord loc = gb.getLocation(); + World w= loc.getWorld(); + if(w==null){ + return;//? + } + + Integer ret=track.merge(new ChunkInfo(loc.x, loc.z,w), -1, (a,b)->{ + int retu=a+b; + return retu==0?null:retu; + }); + + + } + + } + LinkedList terminals=new LinkedList<>(); + @Override + public void addNode(IGridNode gridNode, IGridHost machine) { + if(machine instanceof TileAnchorAlert){ + terminals.add((TileAnchorAlert) machine); + } + IGridBlock gb = gridNode.getGridBlock(); + + if(gb.isWorldAccessible()){ + DimensionalCoord loc = gb.getLocation(); + World w= loc.getWorld(); + if(w==null){ + return;//? + } + + track.merge(new ChunkInfo(loc.x, loc.z,w), 1, (a,b)->a+b); + } + } + + @Override + public void onSplit(IGridStorage destinationStorage) { + + + } + + @Override + public void onJoin(IGridStorage sourceStorage) { + + + } + + @Override + public void populateGridStorage(IGridStorage destinationStorage) { + + + } + + + @SuppressWarnings("rawtypes") + public void warn(ChunkInfo info,int i){ + + + HashSet playersUUIDToInform=new HashSet<>(); + HashSet dimensionsToInform=new HashSet<>(); + boolean[] informAll=new boolean[1]; + + terminals.forEach(s->{ + if(s.mode==s.ALL){informAll[0]=true;} + if(s.mode==s.DIM){dimensionsToInform.add(s.getWorldObj());} + if(s.mode==s.OWNER){playersUUIDToInform.add(s.owner);} + }); + HashSet playersToInform=new HashSet<>(); + if(informAll[0]==false) + if(playersUUIDToInform.isEmpty()==false){ + List l=MinecraftServer.getServer().getConfigurationManager().playerEntityList; + List player=l; + for(EntityPlayer p:player){ + if(playersUUIDToInform.contains(p.getUniqueID())){ + playersToInform.add(p); + } + } + } + if(informAll[0]==false) + dimensionsToInform.forEach(s->{ + playersToInform.addAll(s.playerEntities); + }); + + if(informAll[0]){ + playersToInform.addAll(MinecraftServer.getServer().getConfigurationManager().playerEntityList); + } + + + + + + for(Object o:playersToInform){ + if(((EntityPlayer)o).getEntityWorld().provider.dimensionId==info.dim) + ((EntityPlayer)o).addChatMessage(new ChatComponentTranslation( + "proghatch.chunk_loading_alert.alert", + + "X:"+info.chunkx+",Z:"+info.chunky+" "+ + "Center:"+((info.chunkx<<4)+8)+","+((info.chunky<<4)+8) + + + ,i + + ));; + } + + + System.out.println("Unload chunk:"+info+" with "+i+" Node(s) inside."); + + } + + + public void unload(Chunk o) {ChunkInfo info; + Integer tck = track.get(info=new ChunkInfo(o.xPosition<<4, o.zPosition<<4, o.worldObj)); + if(tck!=null){ + warn(info,tck); + } + } + public void unload(World o) { + track.forEach((a,b)->{ + if(a.dim==o.provider.dimensionId){ + if(b!=null) + warn(a,b); + } + }); + } + + + + +} diff --git a/src/main/java/reobf/proghatches/block/IChunkTrackingGridCahce.java b/src/main/java/reobf/proghatches/block/IChunkTrackingGridCahce.java new file mode 100644 index 0000000..7bc89ad --- /dev/null +++ b/src/main/java/reobf/proghatches/block/IChunkTrackingGridCahce.java @@ -0,0 +1,7 @@ +package reobf.proghatches.block; + +import appeng.api.networking.IGridCache; + +public interface IChunkTrackingGridCahce extends IGridCache{ + +} diff --git a/src/main/java/reobf/proghatches/block/ItemBlockAnchorAlert.java b/src/main/java/reobf/proghatches/block/ItemBlockAnchorAlert.java new file mode 100644 index 0000000..37a0362 --- /dev/null +++ b/src/main/java/reobf/proghatches/block/ItemBlockAnchorAlert.java @@ -0,0 +1,44 @@ +package reobf.proghatches.block; + +import java.util.List; + +import com.gtnewhorizons.modularui.api.KeyboardUtil; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import reobf.proghatches.lang.LangManager; + +public class ItemBlockAnchorAlert extends ItemBlock { + + + + public ItemBlockAnchorAlert(Block p_i45328_1_) { + super(p_i45328_1_); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + int i = 0; + while (true) { + String k = "tile.chunk_loading_alert.tooltip"; + + if (LangManager.translateToLocal(k).equals(Integer.valueOf(i).toString())) { + break; + } + String key = k + "." + i; + String trans = LangManager.translateToLocal(key); + + p_77624_3_.add(trans); + i++; + + } + super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } + +} diff --git a/src/main/java/reobf/proghatches/block/TileAnchorAlert.java b/src/main/java/reobf/proghatches/block/TileAnchorAlert.java new file mode 100644 index 0000000..dd49a35 --- /dev/null +++ b/src/main/java/reobf/proghatches/block/TileAnchorAlert.java @@ -0,0 +1,117 @@ +package reobf.proghatches.block; + +import java.util.EnumSet; +import java.util.UUID; + +import appeng.api.networking.GridFlags; +import appeng.api.networking.IGridNode; +import appeng.api.util.AECableType; +import appeng.api.util.DimensionalCoord; +import appeng.me.helpers.AENetworkProxy; +import appeng.me.helpers.IGridProxyable; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import reobf.proghatches.main.MyMod; +import reobf.proghatches.util.ProghatchesUtil; + +public class TileAnchorAlert extends TileEntity implements IGridProxyable{ + public static final int ALL = 0; + public static final int DIM = 1; + public static final int OWNER = 2; + int mode; + //2 inform owner only + //1 inform all players in same dim + //0 inform all online player + @Override + public IGridNode getGridNode(ForgeDirection dir) { + + return createProxy().getNode(); + } + + @Override + public AECableType getCableConnectionType(ForgeDirection dir) { + + return AECableType.SMART; + } + + @Override + public void securityBreak() { + + } + + @Override + public AENetworkProxy getProxy() { + + return createProxy(); + } + AENetworkProxy proxy; + protected AENetworkProxy createProxy() { + if(proxy!=null)return proxy; + + proxy=new AENetworkProxy(this, "proxy", new ItemStack(MyMod.alert), true); + + //proxy.setFlags(GridFlags.REQUIRE_CHANNEL); + proxy.setValidSides(EnumSet.range(ForgeDirection.DOWN, ForgeDirection.EAST)); + return proxy; } + @Override + public DimensionalCoord getLocation() { + + return new DimensionalCoord(this); + } + + @Override + public void gridChanged() { + + + } + UUID owner; + + + public void mark(EntityPlayer placer) { + createProxy().setOwner((EntityPlayer) placer); + owner=placer.getUniqueID(); + } + @Override + public void readFromNBT(NBTTagCompound compound) { + mode=compound.getInteger("m"); + owner=ProghatchesUtil.deser(compound, "OWNER_UUID"); + if(owner.getLeastSignificantBits()==0&&owner.getMostSignificantBits()==0)owner=null; + createProxy().readFromNBT(compound); + super.readFromNBT(compound); + } + @Override + public void writeToNBT(NBTTagCompound compound) { + compound.setInteger("m", mode); + if(owner!=null) + ProghatchesUtil.ser(compound, owner, "OWNER_UUID"); + createProxy().writeToNBT(compound); + super.writeToNBT(compound); + } +@Override +public void updateEntity() { + + super.updateEntity(); + if(!getProxy().isReady()) + getProxy().onReady(); +} +public void onChunkUnload() { + + this.getProxy().onChunkUnload(); +} + +public void invalidate() { + + this.getProxy().invalidate(); +} + +@Override +public void validate() { + this.getProxy().validate(); +} + + +} diff --git a/src/main/java/reobf/proghatches/eucrafting/EUUtil.java b/src/main/java/reobf/proghatches/eucrafting/EUUtil.java index 400bfe3..ea8a143 100644 --- a/src/main/java/reobf/proghatches/eucrafting/EUUtil.java +++ b/src/main/java/reobf/proghatches/eucrafting/EUUtil.java @@ -25,6 +25,8 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.ForgeDirection; +import reobf.proghatches.block.ChunkTrackingGridCahce; +import reobf.proghatches.block.IChunkTrackingGridCahce; import reobf.proghatches.eucrafting.IEUManager.EUManager; import reobf.proghatches.main.MyMod; import reobf.proghatches.net.OpenPartGuiMessage; @@ -32,6 +34,7 @@ public class EUUtil { public static void register() { AEApi.instance().registries().gridCache().registerGridCache(IEUManager.class, EUManager.class); + AEApi.instance().registries().gridCache().registerGridCache(IChunkTrackingGridCahce.class, ChunkTrackingGridCahce.class); } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java index bc70026..85ac192 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java @@ -881,7 +881,10 @@ public interface VargsFunction { } VargsFunction asFluidStack = (s) -> Arrays.stream(s).flatMap( Arrays::stream).map(f->{ if(f instanceof FluidTank){return ((FluidTank) f).getFluid();} - else if(f instanceof FluidStack){return (FluidStack)f;}else{throw new RuntimeException();} + else if(f instanceof FluidStack){return (FluidStack)f;} + else if(f==null){/*ignore*/return null;} + else + {throw new RuntimeException("only FluidStack or FluidTank are accepted");} }) .filter(a -> a != null && a.amount > 0).toArray(FluidStack[]::new); VargsFunction filterStack = (s) -> Arrays.stream(s).flatMap( Arrays::stream).filter(a -> a != null) @@ -1859,10 +1862,11 @@ public boolean endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase controller) } public void startRecipeProcessing() { if(isDummy())return; - IGrid net = getNetwork().g; - IStorageGrid cahce=null; - if(net!=null) - cahce=net.getCache(IStorageGrid.class); + + IStorageGrid cahce= (IStorageGrid) Optional.ofNullable(getNetwork()) + .map(s->s.g) + .map(s->s.getCache(IStorageGrid.class)).orElse(null); + shadowItems.clear(); shadowFluid.clear(); cachedItems.clear(); @@ -1877,7 +1881,7 @@ public void startRecipeProcessing() { cahce.getItemInventory().getStorageList().findPrecise(AEItemStack.create(is)) ).map(IAEItemStack::getItemStack).orElse(null)); shadowItems.add(ris); - cachedItems.add(ris.copy()); + cachedItems.add(Optional.ofNullable(ris).map(s->s.copy()).get()); } } for(int i=0;is.copy()).get()); } } diff --git a/src/main/java/reobf/proghatches/main/CommonProxy.java b/src/main/java/reobf/proghatches/main/CommonProxy.java index 73f943d..015a68f 100644 --- a/src/main/java/reobf/proghatches/main/CommonProxy.java +++ b/src/main/java/reobf/proghatches/main/CommonProxy.java @@ -13,9 +13,11 @@ import gregtech.api.util.GT_ModHandler; import mcp.mobius.waila.api.IWailaRegistrar; import reobf.proghatches.Tags; +import reobf.proghatches.block.BlockAnchorAlert; import reobf.proghatches.block.BlockIOHub; - +import reobf.proghatches.block.ItemBlockAnchorAlert; import reobf.proghatches.block.ItemBlockIOHub; +import reobf.proghatches.block.TileAnchorAlert; import reobf.proghatches.block.TileIOHub; import reobf.proghatches.eucrafting.BlockEUInterface; import reobf.proghatches.eucrafting.EUUtil; @@ -55,7 +57,8 @@ public void preInit(FMLPreInitializationEvent event) { GameRegistry.registerTileEntity(TileIOHub.class, "proghatches.iohub"); GameRegistry.registerTileEntity(TileWirelessPeripheralStation.class, "proghatches.peripheral_station"); GameRegistry.registerTileEntity(TileCoprocessor.class, "proghatches.coprocessor"); - + GameRegistry.registerTileEntity(TileAnchorAlert.class, "proghatches.chunk_loading_alert"); + GameRegistry.registerTileEntity(TileFluidInterface_EU.class, "proghatches.euinterface"); GameRegistry.registerItem( MyMod.plunger = new ItemMEPlunger(100000).setUnlocalizedName("proghatch_me_plunger").setTextureName("proghatches:plunger"), @@ -103,6 +106,8 @@ public void preInit(FMLPreInitializationEvent event) { MyMod.iohub = GameRegistry.registerBlock(new BlockIOHub(), ItemBlockIOHub.class, "proghatches.iohub"); + MyMod.alert = GameRegistry.registerBlock(new BlockAnchorAlert(Material.rock),ItemBlockAnchorAlert.class, "proghatches.chunk_loading_alert"); + MyMod.pstation = GameRegistry.registerBlock(new TileWirelessPeripheralStation.Block(), TileWirelessPeripheralStation.ItemBlock.class, "proghatches.peripheral_station"); diff --git a/src/main/java/reobf/proghatches/main/MyMod.java b/src/main/java/reobf/proghatches/main/MyMod.java index 1c64bc0..2379ef2 100644 --- a/src/main/java/reobf/proghatches/main/MyMod.java +++ b/src/main/java/reobf/proghatches/main/MyMod.java @@ -10,6 +10,7 @@ import net.minecraft.block.Block; import net.minecraft.client.gui.GuiButton; +import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -20,15 +21,21 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemEditableBook; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.IExtendedEntityProperties; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.event.world.BlockEvent; +import net.minecraftforge.event.world.ChunkEvent; +import net.minecraftforge.event.world.WorldEvent; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -81,6 +88,7 @@ import cpw.mods.fml.relauncher.Side; import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.net.GT_Packet_SendCoverData; @@ -91,6 +99,7 @@ import gregtech.common.covers.CoverInfo; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_HeatExchanger; import reobf.proghatches.Tags; +import reobf.proghatches.block.ChunkTrackingGridCahce; import reobf.proghatches.eucrafting.BlockEUInterface; import reobf.proghatches.eucrafting.AECover; import reobf.proghatches.eucrafting.AECover.IMemoryCardSensitive; @@ -110,6 +119,7 @@ import reobf.proghatches.net.UpgradesMessage; import reobf.proghatches.oc.WirelessPeripheralManager; import reobf.proghatches.util.ProghatchesUtil; +import tconstruct.armor.player.TPlayerStats; @Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]", dependencies = "required-after:appliedenergistics2;required-after:gregtech;" @@ -120,7 +130,7 @@ ) public class MyMod { public static MyMod instance; - {GT_MetaTileEntity_HeatExchanger.class.getDeclaredFields(); + { // BaseMetaPipeEntity.class.getDeclaredFields(); instance = this; } @@ -154,6 +164,7 @@ public class MyMod { public static Item plunger; public static Item lazer_p2p_part; public static Item upgrades; + public static Block alert; @Mod.EventHandler // preInit "Run before anything else. Read your config, create blocks, @@ -204,9 +215,14 @@ public void join(PlayerLoggedInEvent e) { //if(Config.fixCircuit) //e.player.addChatComponentMessage(new ChatComponentTranslation("proghatch.join.fixCircuit")); - if (e.player.getEntityData().hasKey("ProgrammableHatchesTutorialGet3") == false) { + /* if (e.player.getEntityData().hasKey("ProgrammableHatchesTutorialGet3") == false) { e.player.getEntityData().setBoolean("ProgrammableHatchesTutorialGet3", true); - +*/ + + if(e.player.getExtendedProperties(GET_PROGHATCHBOOK)!=null){ + Prop p=(Prop) e.player.getExtendedProperties(GET_PROGHATCHBOOK); + if(p.get){return;} + p.get=true; EntityItem entityitem = e.player.dropPlayerItemWithRandomChoice( Optional.of(tutorial("programmable_hatches.eucreafting.tutorial")).map(s -> { s.stackTagCompound.setString("proghatchesSpecialTag", "true"); @@ -220,6 +236,9 @@ public void join(PlayerLoggedInEvent e) { }).get(), false); entityitem.delayBeforeCanPickup = 0; entityitem.func_145797_a(e.player.getCommandSenderName()); + + + } ; @@ -388,5 +407,50 @@ public void breakBlock(BlockEvent.BreakEvent b) { } } + @SubscribeEvent + public void onUnload(WorldEvent.Unload event) { + try{ + ChunkTrackingGridCahce.callbacks.forEach((a,b)->{ + if(a!=null){a.unload(event.world);} + }); + }catch(Throwable t){t.printStackTrace();} + + } + @SubscribeEvent + public void onUnload(ChunkEvent.Unload event) { + try{ + ChunkTrackingGridCahce.callbacks.forEach((a,b)->{ + if(a!=null){a.unload(event.getChunk());} + }); + }catch(Throwable t){t.printStackTrace();} + } + private static final String GET_PROGHATCHBOOK="GET_PROGHATCHBOOK"; + @SubscribeEvent + + public void onEntityConstructing(EntityEvent.EntityConstructing event) { + if (event.entity instanceof EntityPlayer &&((EntityPlayer) event.entity).getExtendedProperties("GET_PROGHATCHBOOK") == null) { + event.entity.registerExtendedProperties(GET_PROGHATCHBOOK, new Prop()); + } + } + + public class Prop implements IExtendedEntityProperties { + boolean get; + @Override + public void saveNBTData(NBTTagCompound compound) { + + + compound.setBoolean(GET_PROGHATCHBOOK+"_get", get); + } + + @Override + public void loadNBTData(NBTTagCompound compound) { + get=compound.getBoolean(GET_PROGHATCHBOOK+"_get"); + } + @Override + public void init(Entity entity, World world) { + + + }} + } diff --git a/src/main/java/reobf/proghatches/main/registration/ProgHatchCreativeTab.java b/src/main/java/reobf/proghatches/main/registration/ProgHatchCreativeTab.java index 5727205..480eb90 100644 --- a/src/main/java/reobf/proghatches/main/registration/ProgHatchCreativeTab.java +++ b/src/main/java/reobf/proghatches/main/registration/ProgHatchCreativeTab.java @@ -52,7 +52,7 @@ public void displayAllReleventItems(List p_78018_1_) { p_78018_1_.add(new ItemStack(MyMod.upgrades, 1, 0)); p_78018_1_.add(new ItemStack(MyMod.upgrades, 1, 1)); p_78018_1_.add(new ItemStack(MyMod.upgrades, 1, 2)); - + p_78018_1_.add(new ItemStack(MyMod.alert, 1)); // p_78018_1_.add(new ItemStack(MyMod.euupgrade, 1)); } diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index 7c261f3..fdfa0df 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -455,3 +455,14 @@ proghatch.ingbuf.fail.insufficient.length.hatch=%s types of Fluid, only %s Hatch proghatch.ingbuf.fail.insufficient.space.bus=Bus#%s cannot hold all of %s, only %s of them are acceptable. proghatch.ingbuf.fail.insufficient.space.hatch=Hatch#%s cannot hold all of %s, only %s of them are acceptable. programmable_hatches.gt.shared=Configure shared inventory +proghatch.chunk_loading_alert.owner=Only owner can change its mode. +proghatch.chunk_loading_alert.mode.0=Inform: all players online +proghatch.chunk_loading_alert.mode.1=Inform: players in same dimension +proghatch.chunk_loading_alert.mode.2=Inform: only owner +proghatch.chunk_loading_alert.mode.3=Inform: none +tile.proghatch.chunk_loading_alert.name=Alerting Anchor +tile.chunk_loading_alert.tooltip.0=NOT an Spatial Anchor +tile.chunk_loading_alert.tooltip.1=DO NOT load chunks +tile.chunk_loading_alert.tooltip.2=Just send players alert when chunks of current ME network is unloaded. +tile.chunk_loading_alert.tooltip=3 +proghatch.chunk_loading_alert.alert=Alerting Anchor: Chunk [%s] is unloaded, containing %s ME Node(s). diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index 95eca06..d2b8a2e 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -456,3 +456,14 @@ proghatch.ingbuf.fail.insufficient.length.hatch=有%s种流体待输出,但只 proghatch.ingbuf.fail.insufficient.space.bus=%s号输出总线无法容纳全部物品%s,至多接受其中%s个 proghatch.ingbuf.fail.insufficient.space.hatch=%s号输出仓无法容纳全部流体%s,至多接受其中%sL programmable_hatches.gt.shared=配置共享物品 +proghatch.chunk_loading_alert.owner=只有拥有者能切换模式 +proghatch.chunk_loading_alert.mode.0=通知: 所有在线玩家 +proghatch.chunk_loading_alert.mode.1=通知: 同维度其它玩家 +proghatch.chunk_loading_alert.mode.2=通知: 仅拥有者 +proghatch.chunk_loading_alert.mode.3=通知: 无 +tile.proghatch.chunk_loading_alert.name=警告锚 +tile.chunk_loading_alert.tooltip.0=并不是空间锚 +tile.chunk_loading_alert.tooltip.1=本身也不能加载区块 +tile.chunk_loading_alert.tooltip.2=只是在ME网络所在任何区块被卸载时向特定玩家发出警告 +tile.chunk_loading_alert.tooltip=3 +proghatch.chunk_loading_alert.alert=警告锚:位于[%s]的区块被卸载,内含%s个ME节点 diff --git a/src/main/resources/assets/proghatches/textures/blocks/BlockSpatialPylon_dim.png b/src/main/resources/assets/proghatches/textures/blocks/BlockSpatialPylon_dim.png new file mode 100644 index 0000000..6afaf0d Binary files /dev/null and b/src/main/resources/assets/proghatches/textures/blocks/BlockSpatialPylon_dim.png differ diff --git a/src/main/resources/assets/proghatches/textures/blocks/speech_box_front.png b/src/main/resources/assets/proghatches/textures/blocks/speech_box_front.png new file mode 100644 index 0000000..dcb240e Binary files /dev/null and b/src/main/resources/assets/proghatches/textures/blocks/speech_box_front.png differ diff --git a/src/main/resources/assets/proghatches/textures/items/upgrade0.png b/src/main/resources/assets/proghatches/textures/items/upgrade0.png index 1c9919e..1f03001 100644 Binary files a/src/main/resources/assets/proghatches/textures/items/upgrade0.png and b/src/main/resources/assets/proghatches/textures/items/upgrade0.png differ diff --git a/src/main/resources/assets/proghatches/textures/items/upgrade1.png b/src/main/resources/assets/proghatches/textures/items/upgrade1.png index 99e7bed..7b3f6af 100644 Binary files a/src/main/resources/assets/proghatches/textures/items/upgrade1.png and b/src/main/resources/assets/proghatches/textures/items/upgrade1.png differ diff --git a/src/main/resources/assets/proghatches/textures/items/upgrade2.png b/src/main/resources/assets/proghatches/textures/items/upgrade2.png index e676814..f31ebfe 100644 Binary files a/src/main/resources/assets/proghatches/textures/items/upgrade2.png and b/src/main/resources/assets/proghatches/textures/items/upgrade2.png differ