From 70c1354a4a96698758a88c032866288f79de6f5a Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Sat, 24 Aug 2024 08:16:37 -0400 Subject: Initial commit --- .../jp/plusplus/fbs/storage/BlockMealCrystal.class | Bin 0 -> 9236 bytes .../jp/plusplus/fbs/storage/BlockMealCrystal.java | 206 +++++++++++++ .../jp/plusplus/fbs/storage/BlockMealInlet.class | Bin 0 -> 8198 bytes .../jp/plusplus/fbs/storage/BlockMealInlet.java | 190 ++++++++++++ .../fbs/storage/BlockMealOutletSingle.class | Bin 0 -> 4547 bytes .../fbs/storage/BlockMealOutletSingle.java | 92 ++++++ .../plusplus/fbs/storage/BlockMealTerminal.class | Bin 0 -> 7329 bytes .../jp/plusplus/fbs/storage/BlockMealTerminal.java | 159 ++++++++++ .../storage/ChunkLoadManager$IChunkLoader.class | Bin 0 -> 296 bytes .../fbs/storage/ChunkLoadManager$Pos.class | Bin 0 -> 789 bytes .../jp/plusplus/fbs/storage/ChunkLoadManager.class | Bin 0 -> 6423 bytes .../jp/plusplus/fbs/storage/ChunkLoadManager.java | 144 +++++++++ .../ContainerMealTerminal$SlotTerminal.class | Bin 0 -> 798 bytes .../fbs/storage/ContainerMealTerminal.class | Bin 0 -> 8114 bytes .../fbs/storage/ContainerMealTerminal.java | 301 +++++++++++++++++++ .../jp/plusplus/fbs/storage/GuiMealTerminal.class | Bin 0 -> 4791 bytes .../jp/plusplus/fbs/storage/GuiMealTerminal.java | 150 ++++++++++ .../java/jp/plusplus/fbs/storage/IMealDevice.class | Bin 0 -> 270 bytes .../java/jp/plusplus/fbs/storage/IMealDevice.java | 12 + .../plusplus/fbs/storage/InventoryTerminal.class | Bin 0 -> 3081 bytes .../jp/plusplus/fbs/storage/InventoryTerminal.java | 126 ++++++++ .../jp/plusplus/fbs/storage/ItemMealFragment.class | Bin 0 -> 4043 bytes .../jp/plusplus/fbs/storage/ItemMealFragment.java | 95 ++++++ .../fbs/storage/MessageMealTerminal$Handler.class | Bin 0 -> 3364 bytes .../MessageMealTerminal$HandlerClient.class | Bin 0 -> 2017 bytes .../plusplus/fbs/storage/MessageMealTerminal.class | Bin 0 -> 3092 bytes .../plusplus/fbs/storage/MessageMealTerminal.java | 109 +++++++ .../MessageMealTerminalScroll$Handler.class | Bin 0 -> 1820 bytes .../fbs/storage/MessageMealTerminalScroll.class | Bin 0 -> 1865 bytes .../fbs/storage/MessageMealTerminalScroll.java | 53 ++++ .../jp/plusplus/fbs/storage/ModelMealCrystal.class | Bin 0 -> 3825 bytes .../jp/plusplus/fbs/storage/ModelMealCrystal.java | 158 ++++++++++ .../jp/plusplus/fbs/storage/ModelMealInlet.class | Bin 0 -> 2409 bytes .../jp/plusplus/fbs/storage/ModelMealInlet.java | 75 +++++ .../plusplus/fbs/storage/RenderMealCrystal.class | Bin 0 -> 2902 bytes .../jp/plusplus/fbs/storage/RenderMealCrystal.java | 61 ++++ .../plusplus/fbs/storage/RenderMealInlet$1.class | Bin 0 -> 1070 bytes .../jp/plusplus/fbs/storage/RenderMealInlet.class | Bin 0 -> 3788 bytes .../jp/plusplus/fbs/storage/RenderMealInlet.java | 102 +++++++ .../plusplus/fbs/storage/RenderMealTerminal.class | Bin 0 -> 3027 bytes .../plusplus/fbs/storage/RenderMealTerminal.java | 84 ++++++ .../jp/plusplus/fbs/storage/TileEntityMeal$1.class | Bin 0 -> 1384 bytes .../jp/plusplus/fbs/storage/TileEntityMeal.class | Bin 0 -> 9844 bytes .../jp/plusplus/fbs/storage/TileEntityMeal.java | 328 +++++++++++++++++++++ .../plusplus/fbs/storage/TileEntityMealInlet.class | Bin 0 -> 5477 bytes .../plusplus/fbs/storage/TileEntityMealInlet.java | 138 +++++++++ .../fbs/storage/TileEntityMealOutletSingle.class | Bin 0 -> 5391 bytes .../fbs/storage/TileEntityMealOutletSingle.java | 124 ++++++++ .../fbs/storage/TileEntityMealTerminal.class | Bin 0 -> 2617 bytes .../fbs/storage/TileEntityMealTerminal.java | 55 ++++ 50 files changed, 2762 insertions(+) create mode 100644 src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/BlockMealInlet.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/BlockMealInlet.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/BlockMealOutletSingle.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/BlockMealOutletSingle.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/BlockMealTerminal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/BlockMealTerminal.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$IChunkLoader.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$Pos.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal$SlotTerminal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/GuiMealTerminal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/GuiMealTerminal.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/IMealDevice.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/IMealDevice.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/InventoryTerminal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/InventoryTerminal.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/ItemMealFragment.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/ItemMealFragment.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal$Handler.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal$HandlerClient.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll$Handler.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/ModelMealCrystal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/ModelMealCrystal.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/ModelMealInlet.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/ModelMealInlet.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/RenderMealCrystal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/RenderMealCrystal.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/RenderMealInlet$1.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/RenderMealTerminal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/RenderMealTerminal.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/TileEntityMeal$1.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/TileEntityMealInlet.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/TileEntityMealInlet.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/TileEntityMealOutletSingle.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/TileEntityMealOutletSingle.java create mode 100644 src/main/java/jp/plusplus/fbs/storage/TileEntityMealTerminal.class create mode 100644 src/main/java/jp/plusplus/fbs/storage/TileEntityMealTerminal.java (limited to 'src/main/java/jp/plusplus/fbs/storage') diff --git a/src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.class b/src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.class new file mode 100644 index 0000000..4386ff3 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.java b/src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.java new file mode 100644 index 0000000..127ed2f --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.java @@ -0,0 +1,206 @@ +package jp.plusplus.fbs.storage; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import jp.plusplus.fbs.FBS; +import jp.plusplus.fbs.api.FBSEntityPropertiesAPI; +import jp.plusplus.fbs.block.BlockBase; +import jp.plusplus.fbs.item.ItemMonocle; +import jp.plusplus.fbs.particle.EntityGlowFX; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import java.util.Random; + +/** + * Created by plusplus_F on 2016/03/07. + */ +public class BlockMealCrystal extends BlockBase implements ITileEntityProvider,ChunkLoadManager.IChunkLoader { + private static boolean breaking=false; + + public BlockMealCrystal() { + super(Material.rock); + setStepSound(soundTypeGlass); + setBlockName("mealCrystal"); + setBlockTextureName("mealCrystal"); + setResistance(10000); + setHardness(0.5f); + setHarvestLevel("pickaxe", Item.ToolMaterial.EMERALD.getHarvestLevel()); + + infoName="mealCrystal"; + infoRow=1; + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return p_149915_2_==0?new TileEntityMeal():null; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + @Override + public int quantityDropped(Random p_149745_1_) { + return 0; + } + + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + int m=world.getBlockMetadata(x,y,z); + TileEntityMeal te=null; + if(m==0) te=(TileEntityMeal)world.getTileEntity(x,y,z); + else te=(TileEntityMeal)world.getTileEntity(x,y-1,z); + if(te==null || !te.hasFragment()) return false; + + ItemStack ret=te.getFragment(true); + if(!world.isRemote){ + if(ret!=null){ + player.entityDropItem(ret, player.getEyeHeight()); + if(!player.capabilities.isCreativeMode) FBSEntityPropertiesAPI.LoseSanity(player, 1, 6, true); + } + } + te.markDirty(); + world.markBlockForUpdate(x,y,z); + + return true; + } + + @Override + public boolean canLoad(World w, int x, int y, int z) { + return true; + } + + @Override + public void breakBlock(World par1World, int x, int y, int z, Block block, int par6){ + TileEntityMeal te = (TileEntityMeal)par1World.getTileEntity(x, y, z); + if(te!=null){ + ItemStack[] list=te.getAllItemStacks(); + for(ItemStack itemstack : list){ + if (itemstack != null){ + float f = this.rand.nextFloat() * 0.8F + 0.1F; + float f1 = this.rand.nextFloat() * 0.8F + 0.1F; + float f2 = this.rand.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0){ + int k1 = itemstack.getMaxStackSize(); + if (k1 > itemstack.stackSize){ + k1 = itemstack.stackSize; + } + itemstack.stackSize -= k1; + + EntityItem entityitem = new EntityItem(par1World, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + if (itemstack.hasTagCompound()){ + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3); + par1World.spawnEntityInWorld(entityitem); + } + } + } + if(par6==0) ChunkLoadManager.removeChunkLoader(par1World, x,y,z); + } + + if(!breaking){ + breaking=true; + switch (par6){ + case 0: + if(par1World.getBlock(x,y+1,z)==this) par1World.func_147480_a(x,y+1,z, false); + break; + case 1: + if(par1World.getBlock(x,y-1,z)==this) par1World.func_147480_a(x,y-1,z, false); + break; + } + breaking=false; + } + + super.breakBlock(par1World, x, y, z, block, par6); + } + + @Override + public boolean canPlaceBlockAt(World w, int x, int y, int z) { + for(int i=0;i<2;i++){ + if(!w.getBlock(x,y+i,z).isReplaceable(w,x,y+i,z)) return false; + } + return true; + } + + @Override + public void onPostBlockPlaced(World w, int x, int y, int z, int meta) { + } + + @Override + public int onBlockPlaced(World w, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int meta) { + w.setBlock(x,y+1,z,this,1,2); + return meta; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return FBS.renderMealId; + } + + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return 15; + } + + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random rand) { + EntityPlayer ep = FBS.proxy.getEntityPlayerInstance(); + if (ep == null) return; + + TileEntityMeal tem=null; + if (world.getBlockMetadata(x, y, z) == 0) tem=(TileEntityMeal)world.getTileEntity(x,y,z); + else if(world.getBlock(x,y-1,z)==this) tem=(TileEntityMeal)world.getTileEntity(x,y-1,z); + if(tem==null || !tem.hasFragment()) return; + + float f = (float) x + 0.5F; + float f1 = (float) y + 0.5f; + float f2 = (float) z + 0.5F; + for(int i=0;i<2;i++){ + float f3 = (0.2f+0.3f*rand.nextFloat())*(rand.nextBoolean()?-1:1); + float f4 = rand.nextFloat() * 0.8F - 0.4F; + float f5 = (0.2f+0.3f*rand.nextFloat())*(rand.nextBoolean()?-1:1); + spawnParticle(world, (double) (f+f3), (double) (f1+f4), (double) (f2 + f5)); + } + /* + f4 = rand.nextFloat() * 0.6F - 0.3F; + f5 =rand.nextFloat()*0.75f; + spawnParticle(world, (double) (f + f4), (double) (f1+f5), (double) (f2 - f3)); + f4 = rand.nextFloat() * 0.6F - 0.3F; + f5 =rand.nextFloat()*0.75f; + spawnParticle(world, (double) (f + f4), (double) (f1+f5), (double) (f2 + f3)); + */ + } + + @SideOnly(Side.CLIENT) + protected void spawnParticle(World world, double x, double y, double z){ + EntityGlowFX e=new EntityGlowFX(world, x,y,z); + e.setRBGColorF(0.8f+0.2f*rand.nextFloat(), 0.8f+0.2f*rand.nextFloat(), 0); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(e); + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/BlockMealInlet.class b/src/main/java/jp/plusplus/fbs/storage/BlockMealInlet.class new file mode 100644 index 0000000..aff9ebf Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/BlockMealInlet.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/BlockMealInlet.java b/src/main/java/jp/plusplus/fbs/storage/BlockMealInlet.java new file mode 100644 index 0000000..80458a5 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/BlockMealInlet.java @@ -0,0 +1,190 @@ +package jp.plusplus.fbs.storage; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import jp.plusplus.fbs.FBS; +import jp.plusplus.fbs.block.BlockBase; +import jp.plusplus.fbs.item.ItemCore; +import jp.plusplus.fbs.particle.EntityGlowFX; +import net.minecraft.block.Block; +import net.minecraft.block.BlockTorch; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +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.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import java.util.Random; + +/** + * Created by plusplus_F on 2016/03/07. + */ +public class BlockMealInlet extends BlockBase implements ITileEntityProvider { + public BlockMealInlet() { + super(Material.rock); + setBlockName("mealInlet"); + setBlockTextureName("mealCrystal"); + setStepSound(soundTypeGlass); + + infoName="mealInlet"; + infoRow=1; + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileEntityMealInlet(); + } + + @Override + public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) { + //world.setBlockMetadataWithNotify(x,y,z,side,2); + return side^1; + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + IMealDevice te=(IMealDevice)world.getTileEntity(x,y,z); + if(te==null) return false; + + ItemStack hav=player.getCurrentEquippedItem(); + if(te.hasFragment()){ + //ミールを取り出す + if(!world.isRemote){ + player.entityDropItem(te.getFragment().copy(), 0); + } + te.setFragment(null); + + ((TileEntity)te).markDirty(); + player.inventory.markDirty(); + world.markBlockForUpdate(x, y, z); + return true; + } + else if(hav!=null && hav.getItem()==ItemCore.mealFragment){ + //ミールを設定する + ItemStack f=hav.copy(); + f.stackSize=1; + te.setFragment(f); + + if(!world.isRemote){ + hav.stackSize--; + if(hav.stackSize<=0){ + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + } + ((TileEntity)te).markDirty(); + player.inventory.markDirty(); + world.markBlockForUpdate(x, y, z); + return true; + } + + return false; + } + + @Override + public void breakBlock(World par1World, int x, int y, int z, Block block, int par6){ + //ミールの欠片をドロップさせる + IMealDevice te = (IMealDevice)par1World.getTileEntity(x, y, z); + if(te!=null && te.hasFragment()){ + float f = this.rand.nextFloat() * 0.8F + 0.1F; + float f1 = this.rand.nextFloat() * 0.8F + 0.1F; + float f2 = this.rand.nextFloat() * 0.8F + 0.1F; + ItemStack fragment=te.getFragment(); + EntityItem entityitem = new EntityItem(par1World, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(fragment.getItem(), fragment.stackSize, fragment.getItemDamage())); + if (fragment.hasTagCompound()){ + entityitem.getEntityItem().setTagCompound((NBTTagCompound)fragment.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3); + par1World.spawnEntityInWorld(entityitem); + } + super.breakBlock(par1World, x, y, z, block, par6); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return FBS.renderMealInletId; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { + int meta=w.getBlockMetadata(x,y,z); + switch (meta){ + case 0: setBlockBounds(0,0,0,1,0.5f,1); break; + case 1: setBlockBounds(0,0.5f,0,1,1,1); break; + case 2: setBlockBounds(0,0,0,1,1,0.5f); break; + case 3: setBlockBounds(0,0,0.5f,1,1,1); break; + case 4: setBlockBounds(0,0,0,0.5f,1,1); break; + case 5: setBlockBounds(0.5f,0,0,1,1,1); break; + } + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World w, int x, int y, int z) { + setBlockBoundsBasedOnState(w,x,y,z); + return super.getCollisionBoundingBoxFromPool(w,x,y,z); + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World w, int x, int y, int z) { + setBlockBoundsBasedOnState(w,x,y,z); + return super.getSelectedBoundingBoxFromPool(w, x, y, z); + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + TileEntity te=world.getTileEntity(x,y,z); + if(te instanceof IMealDevice){ + return ((IMealDevice) te).hasFragment()?15:0; + } + return 15; + } + + + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random rand) { + EntityPlayer ep = FBS.proxy.getEntityPlayerInstance(); + if (ep == null) return; + + IMealDevice tem=(IMealDevice)world.getTileEntity(x,y,z); + if(tem==null || !tem.hasFragment()) return; + + float f = (float) x + 0.5F; + float f1 = (float) y + 0.5f; + float f2 = (float) z + 0.5F; + for(int i=0;i<2;i++){ + float f3 = 0.3f*rand.nextFloat()-0.15f; + float f4 = rand.nextFloat() * 0.4F - 0.2F; + float f5 = 0.3f*rand.nextFloat()-0.15f; + spawnParticle(world, (double) (f+f3), (double) (f1+f4), (double) (f2 + f5)); + } + } + + @SideOnly(Side.CLIENT) + protected void spawnParticle(World world, double x, double y, double z){ + EntityGlowFX e=new EntityGlowFX(world, x,y,z); + e.setRBGColorF(0.8f+0.2f*rand.nextFloat(), 0.8f+0.2f*rand.nextFloat(), 0); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(e); + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/BlockMealOutletSingle.class b/src/main/java/jp/plusplus/fbs/storage/BlockMealOutletSingle.class new file mode 100644 index 0000000..cfbfcb9 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/BlockMealOutletSingle.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/BlockMealOutletSingle.java b/src/main/java/jp/plusplus/fbs/storage/BlockMealOutletSingle.java new file mode 100644 index 0000000..80f39d4 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/BlockMealOutletSingle.java @@ -0,0 +1,92 @@ +package jp.plusplus.fbs.storage; + +import jp.plusplus.fbs.block.BlockCore; +import jp.plusplus.fbs.item.ItemCore; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +/** + * Created by plusplus_F on 2016/03/08. + */ +public class BlockMealOutletSingle extends BlockMealInlet { + public BlockMealOutletSingle() { + super(); + setBlockName("mealOutletSingle"); + infoName="mealOutlet"; + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileEntityMealOutletSingle(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + TileEntityMealOutletSingle temos=(TileEntityMealOutletSingle)world.getTileEntity(x,y,z); + if(temos==null) return false; + + //リクエストを取り出す + if(temos.hasRequirement()){ + if(!world.isRemote){ + player.entityDropItem(temos.getRequirement().copy(), player.getEyeHeight()); + temos.setRequirement(null); + } + temos.markDirty(); + world.markBlockForUpdate(x,y,z); + return true; + } + + //リクエストを設定する + ItemStack hav=player.getCurrentEquippedItem(); + if(hav!=null && temos.hasFragment()){ + if(!world.isRemote){ + ItemStack f=hav.copy(); + f.stackSize=1; + temos.setRequirement(f); + + hav.stackSize--; + if(hav.stackSize<=0){ + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + player.addChatComponentMessage(new ChatComponentText("Set requirement : "+f.getDisplayName())); + } + player.inventory.markDirty(); + world.markBlockForUpdate(x, y, z); + return true; + } + + return super.onBlockActivated(world, x, y, z, player, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); + } + + @Override + public void breakBlock(World par1World, int x, int y, int z, Block block, int par6){ + TileEntityMealOutletSingle te = (TileEntityMealOutletSingle)par1World.getTileEntity(x, y, z); + if(te!=null && te.hasRequirement()){ + float f = this.rand.nextFloat() * 0.8F + 0.1F; + float f1 = this.rand.nextFloat() * 0.8F + 0.1F; + float f2 = this.rand.nextFloat() * 0.8F + 0.1F; + ItemStack fragment=te.getRequirement(); + EntityItem entityitem = new EntityItem(par1World, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(fragment.getItem(), fragment.stackSize, fragment.getItemDamage())); + if (fragment.hasTagCompound()){ + entityitem.getEntityItem().setTagCompound((NBTTagCompound)fragment.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3); + par1World.spawnEntityInWorld(entityitem); + } + super.breakBlock(par1World, x, y, z, block, par6); + } + +} diff --git a/src/main/java/jp/plusplus/fbs/storage/BlockMealTerminal.class b/src/main/java/jp/plusplus/fbs/storage/BlockMealTerminal.class new file mode 100644 index 0000000..daf1082 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/BlockMealTerminal.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/BlockMealTerminal.java b/src/main/java/jp/plusplus/fbs/storage/BlockMealTerminal.java new file mode 100644 index 0000000..7d881b1 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/BlockMealTerminal.java @@ -0,0 +1,159 @@ +package jp.plusplus.fbs.storage; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import jp.plusplus.fbs.FBS; +import jp.plusplus.fbs.block.BlockBase; +import jp.plusplus.fbs.item.ItemCore; +import jp.plusplus.fbs.particle.EntityGlowFX; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import java.util.Random; + +/** + * Created by plusplus_F on 2016/03/08. + */ +public class BlockMealTerminal extends BlockBase implements ITileEntityProvider { + public BlockMealTerminal() { + super(Material.rock); + setBlockName("mealTerminal"); + setBlockTextureName("mealCrystal"); + stepSound=soundTypeGlass; + infoName="mealTerminal"; + infoRow=1; + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileEntityMealTerminal(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + IMealDevice te=(IMealDevice)world.getTileEntity(x,y,z); + if(te==null) return false; + + ItemStack hav=player.getCurrentEquippedItem(); + if(te.hasFragment()){ + if(hav==null && !player.isSneaking()){ + //ミールを取り出す + if(!world.isRemote){ + player.entityDropItem(te.getFragment().copy(), 0); + } + te.setFragment(null); + + ((TileEntity)te).markDirty(); + player.inventory.markDirty(); + world.markBlockForUpdate(x, y, z); + return true; + } + else{ + if(!world.isRemote && ItemMealFragment.getTileEntity(te.getFragment())!=null) player.openGui(FBS.instance, -1, world, x,y,z); + return true; + } + } + else if(hav!=null && hav.getItem()==ItemCore.mealFragment){ + //ミールを設定する + ItemStack f=hav.copy(); + f.stackSize=1; + te.setFragment(f); + + if(!world.isRemote){ + hav.stackSize--; + if(hav.stackSize<=0){ + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + } + ((TileEntity)te).markDirty(); + player.inventory.markDirty(); + world.markBlockForUpdate(x, y, z); + return true; + } + + return false; + } + + @Override + public void breakBlock(World par1World, int x, int y, int z, Block block, int par6){ + //ミールの欠片をドロップさせる + IMealDevice te = (IMealDevice)par1World.getTileEntity(x, y, z); + if(te!=null && te.hasFragment()){ + float f = this.rand.nextFloat() * 0.8F + 0.1F; + float f1 = this.rand.nextFloat() * 0.8F + 0.1F; + float f2 = this.rand.nextFloat() * 0.8F + 0.1F; + ItemStack fragment=te.getFragment(); + EntityItem entityitem = new EntityItem(par1World, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(fragment.getItem(), fragment.stackSize, fragment.getItemDamage())); + if (fragment.hasTagCompound()){ + entityitem.getEntityItem().setTagCompound((NBTTagCompound)fragment.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3); + par1World.spawnEntityInWorld(entityitem); + } + super.breakBlock(par1World, x, y, z, block, par6); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return FBS.renderMealTerminalId; + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + TileEntity te=world.getTileEntity(x,y,z); + if(te instanceof IMealDevice){ + return ((IMealDevice) te).hasFragment()?15:0; + } + return 0; + } + + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random rand) { + EntityPlayer ep = FBS.proxy.getEntityPlayerInstance(); + if (ep == null) return; + + IMealDevice tem=(IMealDevice)world.getTileEntity(x,y,z); + if(tem==null || !tem.hasFragment()) return; + + float f = (float) x + 0.5F; + float f1 = (float) y + 0.6f; + float f2 = (float) z + 0.5F; + for(int i=0;i<2;i++){ + float f3 = 0.3f*rand.nextFloat()-0.15f; + float f4 = rand.nextFloat() * 0.4F - 0.2F; + float f5 = 0.3f*rand.nextFloat()-0.15f; + spawnParticle(world, (double) (f+f3), (double) (f1+f4), (double) (f2 + f5)); + } + } + + @SideOnly(Side.CLIENT) + protected void spawnParticle(World world, double x, double y, double z){ + EntityGlowFX e=new EntityGlowFX(world, x,y,z); + e.setRBGColorF(0.8f+0.2f*rand.nextFloat(), 0.8f+0.2f*rand.nextFloat(), 0); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(e); + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$IChunkLoader.class b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$IChunkLoader.class new file mode 100644 index 0000000..42a7fbb Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$IChunkLoader.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$Pos.class b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$Pos.class new file mode 100644 index 0000000..97068ac Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$Pos.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.class b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.class new file mode 100644 index 0000000..d6545a7 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.java b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.java new file mode 100644 index 0000000..bb9a1f5 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.java @@ -0,0 +1,144 @@ +package jp.plusplus.fbs.storage; + +import com.google.common.collect.ImmutableSetMultimap; +import jp.plusplus.fbs.FBS; +import net.minecraft.block.Block; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeChunkManager; + +import java.util.Dictionary; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by plusplus_F on 2016/03/07. + */ +public class ChunkLoadManager implements ForgeChunkManager.LoadingCallback{ + private static ChunkLoadManager obj=new ChunkLoadManager(); + private static HashMap tickets=new HashMap(); + + //インスタンスの取得 + public static ChunkLoadManager instance(){ + return obj; + } + + //チャンクローダの登録 + public static void setChunkLoader(World w, int x, int y, int z){ + if(w==null){ + FBS.logger.error("Error! World is null."); + return; + } + + Pos p=new Pos(x,y,z); + for(Pos pos : tickets.keySet()){ + if(pos.equals(p)){ + FBS.logger.error("Error! Already registered."); + return; + } + } + + //チケットの要求 + ForgeChunkManager.Ticket t=ForgeChunkManager.requestTicket(FBS.instance, w, ForgeChunkManager.Type.NORMAL); + if(t==null){ + FBS.logger.error("Error! Couldn't get ticket."); + return; + } + + //チケットに情報書き込み + t.getModData().setString("type", "block"); + t.getModData().setInteger("x", x); + t.getModData().setInteger("y", y); + t.getModData().setInteger("z", z); + + //チケットをどうたら + tickets.put(p, t); + ForgeChunkManager.forceChunk(t, w.getChunkFromBlockCoords(x, z).getChunkCoordIntPair()); + FBS.logger.info("Added ChunkLoader at "+w.provider.getDimensionName()+"("+x+","+y+","+z+")"); + } + + //チャンクローダの削除 + public static void removeChunkLoader(World world, int x, int y, int z){ + Pos p=new Pos(x,y,z); + + //チケットが存在するか確認 + for(Pos pos : tickets.keySet()){ + if(pos.equals(p)){ + //チャンクロードの停止 + ForgeChunkManager.Ticket t=tickets.get(pos); + + World w=t.world; + if(w!=null){ + ImmutableSetMultimap map=ForgeChunkManager.getPersistentChunksFor(t.world); + if(map!=null && !map.isEmpty()){ + ForgeChunkManager.unforceChunk(t, world.getChunkFromBlockCoords(x, z).getChunkCoordIntPair()); + FBS.logger.info("Removed chunk loader at "+world.provider.getDimensionName()+"("+x+","+y+","+z+")"); + } + } + + //削除 + tickets.remove(p); + return; + } + } + + FBS.logger.error("Error! Couldn't found chunk loader at "+world.provider.getDimensionName()+"("+x+","+y+","+z+")"); + } + + @Override + public void ticketsLoaded(List tickets, World world) { + ChunkLoadManager.tickets.clear(); + + //チケット全部見てなんか処理してる + for(ForgeChunkManager.Ticket t : tickets){ + if(t.getModData().getString("type").equals("block")){ + int x = t.getModData().getInteger("x"); + int y = t.getModData().getInteger("y"); + int z = t.getModData().getInteger("z"); + Block b=world.getBlock(x,y,z); + + //チャンクローダか判定してそれぞれ処理 + if(b instanceof IChunkLoader){ + if(((IChunkLoader)b).canLoad(world, x, y, z)){ + setChunkLoader(world, x, y, z); + } + } + } + } + } + + public static HashMap getTickets(){ + return tickets; + } + + public static World getWorld(int dId){ + for(ForgeChunkManager.Ticket t : tickets.values()){ + if(t.world.provider.dimensionId==dId){ + return t.world; + } + } + return null; + } + + public interface IChunkLoader{ + public boolean canLoad(World w, int x, int y, int z); + } + + private static class Pos{ + int x,y,z; + + public Pos(int x, int y, int z){ + this.x=x; + this.y=y; + this.z=z; + } + + @Override + public boolean equals(Object obj){ + if(!(obj instanceof Pos)) return false; + Pos p=(Pos)obj; + return x==p.x && y==p.y && z==p.z; + } + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal$SlotTerminal.class b/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal$SlotTerminal.class new file mode 100644 index 0000000..cec3592 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal$SlotTerminal.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.class b/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.class new file mode 100644 index 0000000..0f778c5 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.java b/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.java new file mode 100644 index 0000000..7e6e3d8 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.java @@ -0,0 +1,301 @@ +package jp.plusplus.fbs.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import jp.plusplus.fbs.FBS; +import jp.plusplus.fbs.ProxyClient; +import jp.plusplus.fbs.block.BlockCore; +import jp.plusplus.fbs.packet.PacketHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.*; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.lang.reflect.Field; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +/** + * Created by plusplus_F on 2016/03/08. + */ +public class ContainerMealTerminal extends Container { + public InventoryTerminal inv; + public TileEntityMeal meal; + private int state; + private int fuck1=-1; + private Set fuckSet1=new HashSet(); + public EntityPlayer player; + + public ContainerMealTerminal(EntityPlayer player, TileEntityMealTerminal meal){ + this.player=player; + this.meal=ItemMealFragment.getTileEntity(meal.getFragment()); + inv=new InventoryTerminal(this.meal); + inv.openInventory(); + + SlotTerminal.dontUpdate=inv.dontUpdate=true; + for(int i=0;i<54;i++) addSlotToContainer(new SlotTerminal(inv, i, 8+18*(i%9), 18+18*(i/9))); + + for(int i=0;i<27;i++) addSlotToContainer(new Slot(player.inventory, 9+i, 8+18*(i%9), 140+18*(i/9))); + for(int i=0;i<9;i++) addSlotToContainer(new Slot(player.inventory, i, 8+18*(i%9), 198+18*(i/9))); + SlotTerminal.dontUpdate=inv.dontUpdate=false; + } + + public void scrollTo(float f){ + int preShift=(int)(((inv.allItem.length-54)/9+1)*inv.scroll); + + inv.scroll=f; + inv.markDirty(); + + if(player.worldObj.isRemote && preShift!=(int)(((inv.allItem.length-54)/9+1)*inv.scroll)){ + PacketHandler.INSTANCE.sendToServer(new MessageMealTerminalScroll(player.worldObj.provider.dimensionId, player, inv.scroll)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return meal.getWorldObj().getBlock(meal.xCoord, meal.yCoord, meal.zCoord)==BlockCore.mealCrystal; + } + + @Override + public void onContainerClosed(EntityPlayer p_75134_1_) { + super.onContainerClosed(p_75134_1_); + inv.closeInventory(); + } + + @Override + @SideOnly(Side.CLIENT) + public void putStacksInSlots(ItemStack[] p_75131_1_) { + SlotTerminal.dontUpdate=true; + super.putStacksInSlots(p_75131_1_); + SlotTerminal.dontUpdate=false; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { + Slot slot=(Slot)inventorySlots.get(p_82846_2_); + if(slot instanceof SlotTerminal || slot.getStack()==null) return null; + + ItemStack itemStack=slot.getStack(); + slot.putStack(null); + + if(!p_82846_1_.worldObj.isRemote){ + ItemStack tmp = itemStack.copy(); + meal.insertItemStack(tmp); + inv.markDirty(); + } + + + return null; + } + + /* + @Mojang +     fニヽ +     |_|| +     |= | +     | | +     |= | +    i⌒| |⌒i_ +   /| | | | ヽ +  | ( ( ( ( | +  |/      | +  |       | +   \      ノ +    \    / +    |   | + */ + @Override + public ItemStack slotClick(int slotIndex, int button, int type, EntityPlayer player) { + boolean isClient=(player.worldObj.isRemote); + + //FBS.logger.info("slot:"+slotIndex+","+button+","+type+","+player.toString()); + + ItemStack itemstack = null; + InventoryPlayer inventoryplayer = player.inventory; + int i1; + //ItemStack itemstack3; + //FBS.logger.info("item:"+inventoryplayer.getItemStack()); + + //通常のスロットであれば普通に処理する + if (slotIndex!=-999 && (slotIndex<0 || !(inventorySlots.get(slotIndex) instanceof SlotTerminal))){ + return super.slotClick(slotIndex, button, type, player); + } + + try{ + Class c=Container.class; + Field field=c.getDeclaredField("field_94536_g"); + field.setAccessible(true); + if(field.getInt(this)!=0){ + func_94533_d(); + return null; + } + }catch (Exception e){ + FBS.logger.error(e); + } + + if(state!=0){ + this.func_94533_d(); + return null; + } + + Slot slot2; + int size; + ItemStack itemstack5; + + if(slotIndex==-999 && button==0 && type==0){ + return inventoryplayer.getItemStack(); + } + if(type==1){ + return inventoryplayer.getItemStack(); + } + + if(!isClient) return inventoryplayer.getItemStack(); + + /////////////////////////////////////////////////////////////////////////////////////// + // + // シフトを押さない左または右クリック + // + /////////////////////////////////////////////////////////////////////////////////////// + if (type==0 && (button == 0 || button == 1)) { + if (slotIndex == -999) { + /////////////////////////////////////////////////////////////////////////////////////// + // + // 持っているアイテムを捨てる処理 + // + /////////////////////////////////////////////////////////////////////////////////////// + + if (inventoryplayer.getItemStack() != null && slotIndex == -999) { + if (button == 0) { + player.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack(), true); + inventoryplayer.setItemStack((ItemStack) null); + } + + if (button == 1) { + player.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack().splitStack(1), true); + + if (inventoryplayer.getItemStack().stackSize == 0) { + inventoryplayer.setItemStack((ItemStack) null); + } + } + } + } else { + if (slotIndex < 0) { + return null; + } + + slot2 = (Slot) this.inventorySlots.get(slotIndex); + if (slot2 == null) return null; + + ItemStack slotItem = slot2.getStack(); + ItemStack playerCurrentItem = inventoryplayer.getItemStack(); + if (slotItem != null) itemstack = slotItem.copy(); + + if (slotItem == null) { + //////////////////////////////////////////////////////////////////////////////////////// + // + // スロットが空の場合 + // + //////////////////////////////////////////////////////////////////////////////////////// + if (playerCurrentItem != null && slot2.isItemValid(playerCurrentItem)) { + //////////////////////////////////////////////////////////////////////////////////////// + // + // 空のスロットに持っているアイテムを置く処理 + // + //////////////////////////////////////////////////////////////////////////////////////// + size = button == 0 ? playerCurrentItem.stackSize : 1; + playerCurrentItem.splitStack(size); + + ItemStack tmp = playerCurrentItem.copy(); + tmp.stackSize = size; + //meal.insertItemStack(tmp); + //inv.markDirty(); + + if (isClient) { + PacketHandler.INSTANCE.sendToServer(new MessageMealTerminal(player, meal, 0, tmp)); + } + + if (playerCurrentItem.stackSize == 0) { + inventoryplayer.setItemStack((ItemStack) null); + } + + } + } else if (slot2.canTakeStack(player)) { + if (playerCurrentItem == null) { + //////////////////////////////////////////////////////////////////////////////////////// + // + // 何も持っていないときにスロットからアイテムを取り出す処理 + // + //////////////////////////////////////////////////////////////////////////////////////// + size = (button == 0 ? slotItem.stackSize : (slotItem.stackSize + 1) / 2); + if (size > slotItem.getMaxStackSize()) size = slotItem.getMaxStackSize(); + + //itemstack5 = slot2.decrStackSize(size); + itemstack5=slotItem.copy(); + itemstack5.stackSize=size; + inventoryplayer.setItemStack(itemstack5); + + FBS.logger.info("picked up:"+itemstack5); + + ItemStack tmp = itemstack5.copy(); + //meal.exportItemStack(tmp, tmp.stackSize); + //inv.markDirty(); + + if(isClient){ + //PacketHandler.INSTANCE.sendTo(new MessageMealTerminal(player, meal, 1, tmp), (EntityPlayerMP) player); + PacketHandler.INSTANCE.sendToServer(new MessageMealTerminal(player, meal, 1, tmp)); + } + + //slot2.onPickupFromSlot(player, inventoryplayer.getItemStack()); + } else if (slot2.isItemValid(playerCurrentItem)) { + //////////////////////////////////////////////////////////////////////////////////////// + // + // アイテムをミールへ送る処理 + // + //////////////////////////////////////////////////////////////////////////////////////// + size = button == 0 ? playerCurrentItem.stackSize : 1; + + playerCurrentItem.splitStack(size); + if (playerCurrentItem.stackSize == 0) { + inventoryplayer.setItemStack((ItemStack) null); + } + + ItemStack tmp = playerCurrentItem.copy(); + tmp.stackSize = size; + //meal.insertItemStack(tmp); + //inv.markDirty(); + + if(isClient){ + PacketHandler.INSTANCE.sendToServer(new MessageMealTerminal(player, meal, 0, tmp)); + } + } + } + } + } + return itemstack; + } + + + @Override + protected void func_94533_d() { + super.func_94533_d(); + state = 0; + fuckSet1.clear(); + } + + public static class SlotTerminal extends Slot{ + public static boolean dontUpdate; + + public SlotTerminal(InventoryTerminal inv, int index, int x, int y) { + super(inv, index, x, y); + } + + @Override + public int getSlotStackLimit() { + return Integer.MAX_VALUE; + } + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/GuiMealTerminal.class b/src/main/java/jp/plusplus/fbs/storage/GuiMealTerminal.class new file mode 100644 index 0000000..ec87d82 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/GuiMealTerminal.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/GuiMealTerminal.java b/src/main/java/jp/plusplus/fbs/storage/GuiMealTerminal.java new file mode 100644 index 0000000..9af4f73 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/GuiMealTerminal.java @@ -0,0 +1,150 @@ +package jp.plusplus.fbs.storage; + +import jp.plusplus.fbs.FBS; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.gui.inventory.GuiContainerCreative; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.resources.I18n; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.inventory.Container; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +/** + * Created by plusplus_F on 2016/03/08. + */ +public class GuiMealTerminal extends GuiContainer { + private static final ResourceLocation rl = new ResourceLocation(FBS.MODID+":textures/gui/terminal.png"); + + private float currentScroll; + private boolean isScrolling; + private boolean wasClicking; + private GuiTextField searchField; + private boolean field_147057_D; + + public GuiMealTerminal(Container p_i1072_1_) { + super(p_i1072_1_); + this.allowUserInput = true; + this.xSize = 195; + this.ySize = 222; + } + + @Override + public void initGui() { + super.initGui(); + this.buttonList.clear(); + Keyboard.enableRepeatEvents(true); + this.searchField = new GuiTextField(this.fontRendererObj, this.guiLeft + 80, this.guiTop + 5, 89, this.fontRendererObj.FONT_HEIGHT); + this.searchField.setMaxStringLength(15); + this.searchField.setEnableBackgroundDrawing(false); + this.searchField.setVisible(false); + this.searchField.setTextColor(16777215); + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + Keyboard.enableRepeatEvents(false); + } + + @Override + protected void keyTyped(char p_73869_1_, int p_73869_2_) { + if (this.field_147057_D) { + this.field_147057_D = false; + this.searchField.setText(""); + } + + if (!this.checkHotbarKeys(p_73869_2_)) { + if (this.searchField.textboxKeyTyped(p_73869_1_, p_73869_2_)) { + this.updateSearch(); + } else { + super.keyTyped(p_73869_1_, p_73869_2_); + } + } + } + + protected void updateSearch(){ + + } + + @Override + public void handleMouseInput() { + super.handleMouseInput(); + + int i = Mouse.getEventDWheel(); + if (i != 0) { + ContainerMealTerminal cmt=(ContainerMealTerminal)inventorySlots; + int j = cmt.inv.allItem.length / 9 - 5 + 1; + + if (i > 0) i = 1; + if (i < 0) i = -1; + + this.currentScroll = (float) ((double) this.currentScroll - (double) i / (double) j); + if (this.currentScroll < 0.0F) this.currentScroll = 0.0F; + if (this.currentScroll > 1.0F) this.currentScroll = 1.0F; + + cmt.scrollTo(currentScroll); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(rl); + + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + + //GuiContainerCreative + this.drawTexturedModalRect(k+175, l+18+ (int)((196.f-15.f) * this.currentScroll), 232, 0, 12, 15); + } + + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + GL11.glDisable(GL11.GL_BLEND); + this.fontRendererObj.drawString(I18n.format("tile.fbs.mealCrystal.name"), 8, 6, 4210752); + } + + + public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) { + boolean flag = Mouse.isButtonDown(0); + int k = this.guiLeft; + int l = this.guiTop; + int i1 = k + 175; + int j1 = l + 18; + int k1 = i1 + 14; + int l1 = j1 + 196; + + ContainerMealTerminal cmt=(ContainerMealTerminal)inventorySlots; + + if (!this.wasClicking && flag && p_73863_1_ >= i1 && p_73863_2_ >= j1 && p_73863_1_ < k1 && p_73863_2_ < l1) { + this.isScrolling = true; + } + + if (!flag) { + this.isScrolling = false; + } + + this.wasClicking = flag; + + if (this.isScrolling) { + this.currentScroll = ((float) (p_73863_2_ - j1) - 7.5F) / ((float) (l1 - j1) - 15.0F); + + if (this.currentScroll < 0.0F) this.currentScroll = 0.0F; + if (this.currentScroll > 1.0F) this.currentScroll = 1.0F; + + cmt.scrollTo(this.currentScroll); + } + + super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/IMealDevice.class b/src/main/java/jp/plusplus/fbs/storage/IMealDevice.class new file mode 100644 index 0000000..69478b8 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/IMealDevice.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/IMealDevice.java b/src/main/java/jp/plusplus/fbs/storage/IMealDevice.java new file mode 100644 index 0000000..6d4a9f5 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/IMealDevice.java @@ -0,0 +1,12 @@ +package jp.plusplus.fbs.storage; + +import net.minecraft.item.ItemStack; + +/** + * Created by plusplus_F on 2016/03/07. + */ +public interface IMealDevice { + public ItemStack getFragment(); + public void setFragment(ItemStack f); + public boolean hasFragment(); +} diff --git a/src/main/java/jp/plusplus/fbs/storage/InventoryTerminal.class b/src/main/java/jp/plusplus/fbs/storage/InventoryTerminal.class new file mode 100644 index 0000000..6585c62 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/InventoryTerminal.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/InventoryTerminal.java b/src/main/java/jp/plusplus/fbs/storage/InventoryTerminal.java new file mode 100644 index 0000000..e806ea5 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/InventoryTerminal.java @@ -0,0 +1,126 @@ +package jp.plusplus.fbs.storage; + +import jp.plusplus.fbs.FBS; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +/** + * Created by plusplus_F on 2016/03/08. + */ +public class InventoryTerminal implements IInventory { + public ItemStack[] allItem; + public ItemStack[] itemStacks=new ItemStack[54]; + public TileEntityMeal meal; + public float scroll; + + public boolean dontUpdate; + + public InventoryTerminal(TileEntityMeal meal){ + this.meal=meal; + } + + public void updateItemList(){ + if(!dontUpdate){ + allItem=meal.getAllItemStacks(); + if(allItem.length<=54){ + for(int i=0;i{ + + @Override + public IMessage onMessage(MessageMealTerminal message, MessageContext ctx) { + if (message.itemStack == null) return null; + + if (message.type == 0) { + message.tem.insertItemStack(message.itemStack); + if(message.player.openContainer instanceof ContainerMealTerminal){ + message.player.inventory.setItemStack(null); + } + } else if (message.type == 1) { + message.tem.exportItemStack(message.itemStack, message.itemStack.stackSize); + if(message.player.openContainer instanceof ContainerMealTerminal){ + message.player.inventory.setItemStack(message.itemStack.copy()); + } + } + + Iterator it=message.tem.getWorldObj().playerEntities.iterator(); + while(it.hasNext()){ + EntityPlayer ep=(EntityPlayer)it.next(); + + if(ep.openContainer instanceof ContainerMealTerminal){ + ((ContainerMealTerminal)ep.openContainer).inv.markDirty(); + } + } + + //return new MessageMealTerminal(message.player, message.tem, message.type, message.itemStack); + //return new MessageMealTerminal(); + + PacketHandler.INSTANCE.sendToAll(new MessageMealTerminal(message.player, message.tem, message.type, message.itemStack)); + + return null; + } + } + + public static class HandlerClient implements IMessageHandler{ + + @Override + public IMessage onMessage(MessageMealTerminal message, MessageContext ctx) { + EntityPlayer player=FBS.proxy.getEntityPlayerInstance(); + if(player!=null && player.openContainer instanceof ContainerMealTerminal){ + ((ContainerMealTerminal) player.openContainer).inv.markDirty(); + //FBS.logger.info("list updated"); + } + return null; + } + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll$Handler.class b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll$Handler.class new file mode 100644 index 0000000..40888ab Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll$Handler.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.class b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.class new file mode 100644 index 0000000..770f0c8 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.java b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.java new file mode 100644 index 0000000..3682a8e --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.java @@ -0,0 +1,53 @@ +package jp.plusplus.fbs.storage; + +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; +import jp.plusplus.fbs.FBS; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraftforge.common.DimensionManager; + +/** + * Created by plusplus_F on 2016/03/09. + */ +public class MessageMealTerminalScroll implements IMessage { + public int dId; + public EntityPlayer player; + public float scroll; + + public MessageMealTerminalScroll(){} + public MessageMealTerminalScroll(int id, EntityPlayer ep, float f){ + dId=id; + player=ep; + scroll=f; + } + + @Override + public void fromBytes(ByteBuf buf) { + dId=buf.readInt(); + player= DimensionManager.getWorld(dId).getPlayerEntityByName(ByteBufUtils.readUTF8String(buf)); + scroll=buf.readFloat(); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(dId); + ByteBufUtils.writeUTF8String(buf, player.getCommandSenderName()); + buf.writeFloat(scroll); + } + + public static class Handler implements IMessageHandler{ + @Override + public IMessage onMessage(MessageMealTerminalScroll message, MessageContext ctx) { + Container container=message.player.openContainer; + if(container instanceof ContainerMealTerminal){ + ((ContainerMealTerminal) container).scrollTo(message.scroll); + //FBS.logger.info("scroll to " + message.scroll); + } + return null; + } + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/ModelMealCrystal.class b/src/main/java/jp/plusplus/fbs/storage/ModelMealCrystal.class new file mode 100644 index 0000000..f68029e Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/ModelMealCrystal.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/ModelMealCrystal.java b/src/main/java/jp/plusplus/fbs/storage/ModelMealCrystal.java new file mode 100644 index 0000000..0118878 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ModelMealCrystal.java @@ -0,0 +1,158 @@ +// Date: 2016/03/07 13:58:43 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + + + + + + +package jp.plusplus.fbs.storage; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import org.lwjgl.opengl.GL11; + +public class ModelMealCrystal extends ModelBase { + //fields + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + ModelRenderer Shape5; + ModelRenderer Shape6; + ModelRenderer Shape7; + ModelRenderer Shape8; + ModelRenderer Shape9; + ModelRenderer Shape10; + ModelRenderer Shape11; + ModelRenderer Shape12; + ModelRenderer Shape13; + ModelRenderer Shape14; + + public ModelMealCrystal() { + textureWidth = 64; + textureHeight = 32; + + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.addBox(-4F, 0F, -4F, 8, 18, 8); + Shape1.setRotationPoint(0F, 0F, 0F); + Shape1.setTextureSize(64, 32); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); + Shape2 = new ModelRenderer(this, 32, 24); + Shape2.addBox(-3.5F, -1F, -3.5F, 7, 1, 7); + Shape2.setRotationPoint(0F, 0F, 0F); + Shape2.setTextureSize(64, 32); + Shape2.mirror = true; + setRotation(Shape2, 0F, 0F, 0F); + Shape3 = new ModelRenderer(this, 32, 17); + Shape3.addBox(-3F, -2F, -3F, 6, 1, 6); + Shape3.setRotationPoint(0F, 0F, 0F); + Shape3.setTextureSize(64, 32); + Shape3.mirror = true; + setRotation(Shape3, 0F, 0F, 0F); + Shape4 = new ModelRenderer(this, 32, 11); + Shape4.addBox(-2.5F, -3F, -2.5F, 5, 1, 5); + Shape4.setRotationPoint(0F, 0F, 0F); + Shape4.setTextureSize(64, 32); + Shape4.mirror = true; + setRotation(Shape4, 0F, 0F, 0F); + Shape5 = new ModelRenderer(this, 32, 6); + Shape5.addBox(-2F, -4F, -2F, 4, 1, 4); + Shape5.setRotationPoint(0F, 0F, 0F); + Shape5.setTextureSize(64, 32); + Shape5.mirror = true; + setRotation(Shape5, 0F, 0F, 0F); + Shape6 = new ModelRenderer(this, 53, 28); + Shape6.addBox(-1F, -6F, -1F, 2, 1, 2); + Shape6.setRotationPoint(0F, 0F, 0F); + Shape6.setTextureSize(64, 32); + Shape6.mirror = true; + setRotation(Shape6, 0F, 0F, 0F); + Shape7 = new ModelRenderer(this, 32, 2); + Shape7.addBox(-1.5F, -5F, -1.5F, 3, 1, 3); + Shape7.setRotationPoint(0F, 0F, 0F); + Shape7.setTextureSize(64, 32); + Shape7.mirror = true; + setRotation(Shape7, 0F, 0F, 0F); + Shape8 = new ModelRenderer(this, 53, 26); + Shape8.addBox(-0.5F, -7F, -0.5F, 1, 1, 1); + Shape8.setRotationPoint(0F, 0F, 0F); + Shape8.setTextureSize(64, 32); + Shape8.mirror = true; + setRotation(Shape8, 0F, 0F, 0F); + Shape9 = new ModelRenderer(this, 32, 24); + Shape9.addBox(-3.5F, 18F, -3.5F, 7, 1, 7); + Shape9.setRotationPoint(0F, 0F, 0F); + Shape9.setTextureSize(64, 32); + Shape9.mirror = true; + setRotation(Shape9, 0F, 0F, 0F); + Shape10 = new ModelRenderer(this, 32, 17); + Shape10.addBox(-3F, 19F, -3F, 6, 1, 6); + Shape10.setRotationPoint(0F, 0F, 0F); + Shape10.setTextureSize(64, 32); + Shape10.mirror = true; + setRotation(Shape10, 0F, 0F, 0F); + Shape11 = new ModelRenderer(this, 32, 11); + Shape11.addBox(-2.5F, 20F, -2.5F, 5, 1, 5); + Shape11.setRotationPoint(0F, 0F, 0F); + Shape11.setTextureSize(64, 32); + Shape11.mirror = true; + setRotation(Shape11, 0F, 0F, 0F); + Shape12 = new ModelRenderer(this, 32, 6); + Shape12.addBox(-2F, 21F, -2F, 4, 1, 4); + Shape12.setRotationPoint(0F, 0F, 0F); + Shape12.setTextureSize(64, 32); + Shape12.mirror = true; + setRotation(Shape12, 0F, 0F, 0F); + Shape13 = new ModelRenderer(this, 32, 2); + Shape13.addBox(-1.5F, 22F, -1.5F, 3, 1, 3); + Shape13.setRotationPoint(0F, 0F, 0F); + Shape13.setTextureSize(64, 32); + Shape13.mirror = true; + setRotation(Shape13, 0F, 0F, 0F); + Shape14 = new ModelRenderer(this, 53, 26); + Shape14.addBox(-0.5F, 23F, -0.5F, 1, 1, 1); + Shape14.setRotationPoint(0F, 0F, 0F); + Shape14.setTextureSize(64, 32); + Shape14.mirror = true; + setRotation(Shape14, 0F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5); + } + + public void renderCrystal(float f5, float tick){ + GL11.glRotatef(16*tick/20*(float)(2*Math.PI/(5)), 0, 1, 0); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + Shape6.render(f5); + Shape7.render(f5); + Shape8.render(f5); + Shape9.render(f5); + Shape10.render(f5); + Shape11.render(f5); + Shape12.render(f5); + Shape13.render(f5); + Shape14.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) { + super.setRotationAngles(f, f1, f2, f3, f4, f5, null); + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/ModelMealInlet.class b/src/main/java/jp/plusplus/fbs/storage/ModelMealInlet.class new file mode 100644 index 0000000..ccc5c10 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/ModelMealInlet.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/ModelMealInlet.java b/src/main/java/jp/plusplus/fbs/storage/ModelMealInlet.java new file mode 100644 index 0000000..d625e08 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ModelMealInlet.java @@ -0,0 +1,75 @@ +// Date: 2016/03/07 16:29:33 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + + + + + + +package jp.plusplus.fbs.storage; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelMealInlet extends ModelBase { + //fields + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + + public ModelMealInlet(boolean io) { + textureWidth = 64; + textureHeight = 32; + + Shape1 = new ModelRenderer(this, 0, io?19:6); + Shape1.addBox(-5F, 5F, -5F, 10, 3, 10); + Shape1.setRotationPoint(0F, 0F, 0F); + Shape1.setTextureSize(64, 32); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); + Shape2 = new ModelRenderer(this, 0, 23); + Shape2.addBox(-0.3333333F, 0.06666667F, -6F, 2, 4, 2); + Shape2.setRotationPoint(0F, 0F, 0F); + Shape2.setTextureSize(64, 32); + Shape2.mirror = true; + setRotation(Shape2, 0.7716627F, -1.07818F, 0F); + Shape3 = new ModelRenderer(this, 40, 25); + Shape3.addBox(-1F, 1F, 1F, 3, 4, 3); + Shape3.setRotationPoint(0F, 0F, 0F); + Shape3.setTextureSize(64, 32); + Shape3.mirror = true; + setRotation(Shape3, 0F, -0.3717861F, 0F); + Shape4 = new ModelRenderer(this, 30, 23); + Shape4.addBox(-0.6F, 1F, 2.733333F, 2, 4, 2); + Shape4.setRotationPoint(0F, 0F, 0F); + Shape4.setTextureSize(64, 32); + Shape4.mirror = true; + setRotation(Shape4, -0.3717861F, -2.41661F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5); + Shape1.render(f5); + } + public void renderCrystal(float f5){ + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) { + super.setRotationAngles(f, f1, f2, f3, f4, f5, null); + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/RenderMealCrystal.class b/src/main/java/jp/plusplus/fbs/storage/RenderMealCrystal.class new file mode 100644 index 0000000..557f2ce Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/RenderMealCrystal.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/RenderMealCrystal.java b/src/main/java/jp/plusplus/fbs/storage/RenderMealCrystal.java new file mode 100644 index 0000000..b6bed91 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/RenderMealCrystal.java @@ -0,0 +1,61 @@ +package jp.plusplus.fbs.storage; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import jp.plusplus.fbs.FBS; +import jp.plusplus.fbs.block.model.ModelAlchemyCauldron; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.IBlockAccess; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +/** + * Created by plusplus_F on 2016/03/07. + */ +public class RenderMealCrystal extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler { + public static ResourceLocation rl = new ResourceLocation(FBS.MODID, "textures/models/MealCrystal.png"); + protected ModelMealCrystal model = new ModelMealCrystal(); + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return getRenderId()==modelId; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return false; + } + + @Override + public int getRenderId() { + return FBS.renderMealId; + } + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float p_147500_8_) { + int meta = te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord, te.zCoord); + if (meta!=0) return; + + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5f, (float) y + 1.5f+1.0f/16.0f, (float) z + 0.5f); + GL11.glRotatef(180.0f, 0, 0, 1); + float scale = 0.0625f; + GL11.glScalef(scale, scale, scale); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + this.bindTexture(rl); + model.render(null, 0, 0, 0, 0, 0, 1.0f); + model.renderCrystal(1.f, (float)te.getWorldObj().getTotalWorldTime()+p_147500_8_); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet$1.class b/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet$1.class new file mode 100644 index 0000000..6bc22b9 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet$1.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.class b/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.class new file mode 100644 index 0000000..4fbdd1c Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.java b/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.java new file mode 100644 index 0000000..943bce9 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.java @@ -0,0 +1,102 @@ +package jp.plusplus.fbs.storage; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import jp.plusplus.fbs.FBS; +import jp.plusplus.fbs.block.BlockCore; +import jp.plusplus.fbs.block.model.ModelHerb; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +/** + * Created by plusplus_F on 2016/03/07. + */ +public class RenderMealInlet extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler { + public static ResourceLocation rl = new ResourceLocation(FBS.MODID + ":textures/models/MealInlet.png"); + protected ModelMealInlet inlet=new ModelMealInlet(false); + protected ModelMealInlet outlet=new ModelMealInlet(true); + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + if (modelId != getRenderId()) return; + + GL11.glPushMatrix(); + GL11.glTranslatef(0.5f, 0.5f, 0.5f); + GL11.glRotatef(180, 0, 0, 1); + + float scale = 0.0625f; + scale *= 1.25f; + GL11.glScalef(scale, scale, scale); + + bindTexture(rl); + if (block == BlockCore.mealInlet) { + inlet.render(null, 0, 0, 0, 0, 0, 1.0f); + inlet.renderCrystal(1.0f); + } else { + outlet.render(null, 0, 0, 0, 0, 0, 1.0f); + outlet.renderCrystal(1.0f); + } + + bindTexture(TextureMap.locationBlocksTexture); + + GL11.glScalef(1f, 1f, 1f); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return modelId==getRenderId(); + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return FBS.renderMealInletId; + } + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float p_147500_8_) { + ForgeDirection dir=ForgeDirection.getOrientation(te.getBlockMetadata()&7); + + bindTexture(rl); + + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5f, (float) y + 0.5f, (float) z + 0.5f); + switch (dir){ + case DOWN: GL11.glRotatef(180, 0, 0, 1); break; + case UP: GL11.glRotatef(0, 0, 0, 1); break; + case NORTH: GL11.glRotatef(90, -1, 0, 0); break; + case SOUTH: GL11.glRotatef(90, 1, 0, 0); break; + case WEST: GL11.glRotatef(90, 0, 0, 1); break; + case EAST: GL11.glRotatef(90, 0, 0, -1); break; + } + float scale = 0.0625f; + GL11.glScalef(scale, scale, scale); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + ModelMealInlet model; + if(te.getBlockType()==BlockCore.mealInlet) model=inlet; + else model=outlet; + + model.render(null, 0,0,0,0,0,1.f); + if(((IMealDevice)te).hasFragment()) model.renderCrystal(1.f); + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + + bindTexture(TextureMap.locationBlocksTexture); + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/RenderMealTerminal.class b/src/main/java/jp/plusplus/fbs/storage/RenderMealTerminal.class new file mode 100644 index 0000000..db2ce4d Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/RenderMealTerminal.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/RenderMealTerminal.java b/src/main/java/jp/plusplus/fbs/storage/RenderMealTerminal.java new file mode 100644 index 0000000..3390b27 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/RenderMealTerminal.java @@ -0,0 +1,84 @@ +package jp.plusplus.fbs.storage; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import jp.plusplus.fbs.FBS; +import jp.plusplus.fbs.block.BlockCore; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +/** + * Created by plusplus_F on 2016/03/08. + */ +public class RenderMealTerminal extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler { + public static ResourceLocation rl = new ResourceLocation(FBS.MODID + ":textures/models/MealInlet.png"); + protected ModelMealInlet inlet=new ModelMealInlet(false); + protected ModelMealInlet outlet=new ModelMealInlet(true); + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + if (modelId != getRenderId()) return; + + GL11.glPushMatrix(); + GL11.glTranslatef(0.5f, 0.5f, 0.5f); + GL11.glRotatef(180, 0, 0, 1); + + float scale = 0.0625f; + scale *= 1.25f; + GL11.glScalef(scale, scale, scale); + + bindTexture(rl); + outlet.render(null, 0, 0, 0, 0, 0, 1.0f); + GL11.glTranslatef(0,-3/1.25f, 0); + inlet.render(null, 0, 0, 0, 0, 0, 1.0f); + inlet.renderCrystal(1.0f); + bindTexture(TextureMap.locationBlocksTexture); + + GL11.glScalef(1f, 1f, 1f); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return modelId==getRenderId(); + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return FBS.renderMealTerminalId; + } + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float p_147500_8_) { + bindTexture(rl); + + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5f, (float) y + 0.5f, (float) z + 0.5f); + GL11.glRotatef(180, 0, 0, 1); + float scale = 0.0625f; + GL11.glScalef(scale, scale, scale); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + outlet.render(null, 0, 0, 0, 0, 0, 1.f); + GL11.glTranslatef(0, -3, 0); + inlet.render(null, 0,0,0,0,0,1.f); + if(((IMealDevice)te).hasFragment()) inlet.renderCrystal(1.f); + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + + bindTexture(TextureMap.locationBlocksTexture); + } +} diff --git a/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal$1.class b/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal$1.class new file mode 100644 index 0000000..6c25b58 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal$1.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.class b/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.class new file mode 100644 index 0000000..d4ccfe6 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.class differ diff --git a/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.java b/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.java new file mode 100644 index 0000000..65999b6 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.java @@ -0,0 +1,328 @@ +package jp.plusplus.fbs.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import jp.plusplus.fbs.FBS; +import jp.plusplus.fbs.api.FBSEntityPropertiesAPI; +import jp.plusplus.fbs.packet.PacketHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; + +import java.util.*; + +/** + * Created by plusplus_F on 2016/03/07. + */ +public class TileEntityMeal extends TileEntity { + protected ArrayList listBlocks=new ArrayList(); + protected ArrayList listItems=new ArrayList(); + + private LinkedList cache=new LinkedList(); + + public static final int FRAGEMNT_INTERVAL=20*60*5; + protected int fragmentTicks=FRAGEMNT_INTERVAL; + + private boolean loaded; + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbtTagCompound = new NBTTagCompound(); + this.writeToNBT(nbtTagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTagCompound); + } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + this.readFromNBT(pkt.func_148857_g()); + } + + @Override + public void readFromNBT(NBTTagCompound par1NBTTagCompound){ + super.readFromNBT(par1NBTTagCompound); + + cache.clear(); + + fragmentTicks=par1NBTTagCompound.getInteger("FragmentTicks"); + + NBTTagList nbttaglist = (NBTTagList)par1NBTTagCompound.getTag("Items"); + listItems.clear(); + for (int i=0;i list=null; + if(itemStack.getItem() instanceof ItemBlock) list=listBlocks; + else list=listItems; + + //どこに突っ込むか探す + boolean found=false; + for(ItemStack it : list){ + if(isItemEquals(it, itemStack)){ + it.stackSize+=itemStack.stackSize; + found=true; + + //キャッシュの更新 + updateCache(it); + break; + } + } + if(!found){ + ItemStack a=itemStack.copy(); + list.add(a); + + //キャッシュの更新 + updateCache(a); + } + + //更新 + markDirty(); + sendUpdate(); + } + + /** + * 全てのアイテムを得る
+ * ただし、ここではItemStackはコピーされないので注意 + * @return + */ + public ItemStack[] getAllItemStacks(){ + int sizeBlock=listBlocks.size(), sizeItem=listItems.size(); + ItemStack[] ret=new ItemStack[sizeBlock+sizeItem]; + + if(ret.length>0){ + int i=0; + for(;i() { + @Override + public int compare(ItemStack o1, ItemStack o2) { + int t=Item.getIdFromItem(o1.getItem())-Item.getIdFromItem(o2.getItem()); + return t!=0?t:o1.getItemDamage()-o2.getItemDamage(); + } + }); + } + + return ret; + } + + /** + * キャッシュを更新する + * @param itemStack + */ + private void updateCache(ItemStack itemStack){ + cache.addFirst(itemStack); + if(cache.size()>10) cache.removeLast(); + } + + /** + * リストを走査して、存在しないItemStackが含まれていた場合、それを削除する + */ + private void refreshList(){ + ArrayList[] lists=new ArrayList[]{listBlocks, listItems}; + for(ArrayList list : lists){ + int size=list.size(); + for(int i=0;i0) updateCache(itemStack); + else refreshList(); + + sendUpdate(); + return ret; + } + } + + //リストを見る + ArrayList list=(req.getItem() instanceof ItemBlock)?listBlocks:listItems; + for(ItemStack itemStack : list){ + if(isItemEquals(itemStack, req)){ + stackSize=Math.min(stackSize, itemStack.stackSize); + stackSize=Math.min(stackSize, itemStack.getMaxStackSize()); + ItemStack ret=itemStack.copy(); + itemStack.stackSize-=stackSize; + ret.stackSize=stackSize; + + if(itemStack.stackSize>0) updateCache(itemStack); + else refreshList(); + + sendUpdate(); + return ret; + } + } + + return null; + } + + public boolean hasFragment(){ + return fragmentTicks>=FRAGEMNT_INTERVAL; + } + public ItemStack getFragment(boolean reset){ + if(reset) fragmentTicks=0; + return ItemMealFragment.getItemStack(worldObj, xCoord, yCoord, zCoord); + } + + @Override + public void updateEntity(){ + if(!worldObj.isRemote){ + if (fragmentTicks < FRAGEMNT_INTERVAL) fragmentTicks++; + else if (fragmentTicks == FRAGEMNT_INTERVAL) { + fragmentTicks++; + markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + if(worldObj.getWorldTime()%20==0){ + AxisAlignedBB aabb=AxisAlignedBB.getBoundingBox(xCoord-2, yCoord-1, zCoord-2, xCoord+3, yCoord+3, yCoord+3); + List list=worldObj.getEntitiesWithinAABB(EntityPlayer.class, aabb); + for(int i=0;i