diff options
Diffstat (limited to 'src/main/java/jp/plusplus/fbs/storage')
50 files changed, 2762 insertions, 0 deletions
diff --git a/src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.class b/src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.class Binary files differnew file mode 100644 index 0000000..4386ff3 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/BlockMealCrystal.class 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 Binary files differnew file mode 100644 index 0000000..aff9ebf --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/BlockMealInlet.class 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 Binary files differnew file mode 100644 index 0000000..cfbfcb9 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/BlockMealOutletSingle.class 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 Binary files differnew file mode 100644 index 0000000..daf1082 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/BlockMealTerminal.class 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 Binary files differnew file mode 100644 index 0000000..42a7fbb --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$IChunkLoader.class diff --git a/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$Pos.class b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$Pos.class Binary files differnew file mode 100644 index 0000000..97068ac --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager$Pos.class diff --git a/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.class b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.class Binary files differnew file mode 100644 index 0000000..d6545a7 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ChunkLoadManager.class 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<Pos, ForgeChunkManager.Ticket> tickets=new HashMap<Pos, ForgeChunkManager.Ticket>();
+
+ //インスタンスの取得
+ 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<ChunkCoordIntPair, ForgeChunkManager.Ticket> 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<ForgeChunkManager.Ticket> 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<Pos, ForgeChunkManager.Ticket> 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 Binary files differnew file mode 100644 index 0000000..cec3592 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal$SlotTerminal.class diff --git a/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.class b/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.class Binary files differnew file mode 100644 index 0000000..0f778c5 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ContainerMealTerminal.class 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 Binary files differnew file mode 100644 index 0000000..ec87d82 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/GuiMealTerminal.class 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 Binary files differnew file mode 100644 index 0000000..69478b8 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/IMealDevice.class 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 Binary files differnew file mode 100644 index 0000000..6585c62 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/InventoryTerminal.class 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<itemStacks.length;i++) itemStacks[i]=null;
+ for(int i=0;i<allItem.length;i++) itemStacks[i]=allItem[i];
+ }
+ else{
+ //スクロールに合わせて変更
+ int shift=(int)(((allItem.length-54)/9+1)*scroll);
+ for(int i=0;i<54;i++){
+ int index=i+shift*9;
+ if(index<allItem.length) itemStacks[i]=allItem[index];
+ else itemStacks[i]=null;
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return 54;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int p_70301_1_) {
+ return itemStacks[p_70301_1_];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int index, int stackSize) {
+ if (this.itemStacks[index] != null) {
+ ItemStack itemstack;
+
+ if (this.itemStacks[index].stackSize <= stackSize) {
+ itemstack = this.itemStacks[index].copy();
+ this.itemStacks[index] = null;
+ this.markDirty();
+ return itemstack;
+ } else {
+ itemstack = this.itemStacks[index].splitStack(stackSize);
+
+ if (this.itemStacks[index].stackSize == 0) {
+ this.itemStacks[index] = null;
+ }
+
+ this.markDirty();
+ return itemstack;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
+ return null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
+ //meal.insertItemStack(p_70299_2_);
+ itemStacks[p_70299_1_]=p_70299_2_;
+ markDirty();
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "fbs.terminal";
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return Integer.MAX_VALUE;
+ }
+
+ @Override
+ public void markDirty() {
+ updateItemList();
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
+ return true;
+ }
+
+ @Override
+ public void openInventory() {
+ updateItemList();
+ }
+
+ @Override
+ public void closeInventory() {
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
+ return true;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/storage/ItemMealFragment.class b/src/main/java/jp/plusplus/fbs/storage/ItemMealFragment.class Binary files differnew file mode 100644 index 0000000..283d62f --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ItemMealFragment.class diff --git a/src/main/java/jp/plusplus/fbs/storage/ItemMealFragment.java b/src/main/java/jp/plusplus/fbs/storage/ItemMealFragment.java new file mode 100644 index 0000000..ec8649f --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ItemMealFragment.java @@ -0,0 +1,95 @@ +package jp.plusplus.fbs.storage;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import cpw.mods.fml.server.FMLServerHandler;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.item.ItemBase;
+import jp.plusplus.fbs.item.ItemCore;
+import net.minecraft.client.multiplayer.WorldClient;
+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.StatCollector;
+import net.minecraft.world.World;
+import net.minecraft.world.WorldProvider;
+import net.minecraftforge.common.DimensionManager;
+import net.minecraftforge.common.ForgeChunkManager;
+import net.minecraftforge.common.MinecraftForge;
+
+import java.awt.*;
+import java.util.List;
+
+/**
+ * Created by plusplus_F on 2016/03/07.
+ */
+public class ItemMealFragment extends ItemBase{
+ public static final String DIM="MEAL_DIM";
+ public static final String X="MEAL_X";
+ public static final String Y="MEAL_Y";
+ public static final String Z="MEAL_Z";
+
+ public ItemMealFragment(){
+ setUnlocalizedName("mealFragment");
+ setTextureName("mealFragment");
+ setCreativeTab(null);
+ }
+
+ public static ItemStack getItemStack(World w, int x, int y, int z){
+ NBTTagCompound nbt=new NBTTagCompound();
+ nbt.setInteger(DIM, w.provider.dimensionId);
+ nbt.setInteger(X, x);
+ nbt.setInteger(Y, y);
+ nbt.setInteger(Z, z);
+
+ ItemStack ret=new ItemStack(ItemCore.mealFragment);
+ ret.setTagCompound(nbt);
+ return ret;
+ }
+
+ public static TileEntityMeal getTileEntity(ItemStack fragment){
+ if(fragment==null) {
+ FBS.logger.info("fragment is null");
+ return null;
+ }
+ NBTTagCompound nbt=fragment.getTagCompound();
+ if(nbt==null){
+ FBS.logger.info("nbt is null");
+ return null;
+ }
+
+ int id=nbt.getInteger(DIM);
+ int x=nbt.getInteger(X);
+ int y=nbt.getInteger(Y);
+ int z=nbt.getInteger(Z);
+
+ World world=ChunkLoadManager.getWorld(id);
+ if(world==null){
+ FBS.logger.info("world is null");
+ return null;
+ }
+ if(!world.getChunkFromBlockCoords(x,z).isChunkLoaded){
+ FBS.logger.info("chunk is not loaded");
+ return null;
+ }
+
+ TileEntity te=world.getTileEntity(x,y,z);
+ return (te instanceof TileEntityMeal)?(TileEntityMeal)te:null;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) {
+ String name = "???";
+
+ NBTTagCompound nbt = p_77624_1_.getTagCompound();
+ if(nbt==null) return;
+
+ World w=DimensionManager.getWorld(nbt.getInteger(DIM));
+ if(w!=null && w.provider!=null) {
+ name = w.provider.getDimensionName();
+ }
+ p_77624_3_.add(name + "(" + nbt.getInteger(X) + "," + nbt.getInteger(Y) + "," + nbt.getInteger(Z) + ")");
+
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal$Handler.class b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal$Handler.class Binary files differnew file mode 100644 index 0000000..028cc61 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal$Handler.class diff --git a/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal$HandlerClient.class b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal$HandlerClient.class Binary files differnew file mode 100644 index 0000000..7030fdd --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal$HandlerClient.class diff --git a/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal.class b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal.class Binary files differnew file mode 100644 index 0000000..37ebf1a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal.class diff --git a/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal.java b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal.java new file mode 100644 index 0000000..bcafdd8 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminal.java @@ -0,0 +1,109 @@ +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 jp.plusplus.fbs.packet.PacketHandler;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.common.DimensionManager;
+
+import java.util.Iterator;
+
+/**
+ * Created by plusplus_F on 2016/03/08.
+ */
+public class MessageMealTerminal implements IMessage {
+ public int type;
+ public TileEntityMeal tem;
+ public ItemStack itemStack;
+ public EntityPlayer player;
+
+ public MessageMealTerminal(){}
+
+ public MessageMealTerminal(EntityPlayer player, TileEntityMeal te, int type, ItemStack itemStack){
+ tem=te;
+ this.type=type;
+ this.itemStack=itemStack;
+ this.player=player;
+ }
+
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+
+ type=ByteBufUtils.readVarInt(buf, 4);
+ int id=Integer.parseInt(ByteBufUtils.readUTF8String(buf));
+ int x=Integer.parseInt(ByteBufUtils.readUTF8String(buf));
+ int y=Integer.parseInt(ByteBufUtils.readUTF8String(buf));
+ int z=Integer.parseInt(ByteBufUtils.readUTF8String(buf));
+ itemStack=ByteBufUtils.readItemStack(buf);
+ String name=ByteBufUtils.readUTF8String(buf);
+
+ tem=(TileEntityMeal)ChunkLoadManager.getWorld(id).getTileEntity(x, y, z);
+ player=tem.getWorldObj().getPlayerEntityByName(name);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ ByteBufUtils.writeVarInt(buf, type, 4);
+ ByteBufUtils.writeUTF8String(buf, "" + tem.getWorldObj().provider.dimensionId);
+ ByteBufUtils.writeUTF8String(buf, "" + tem.xCoord);
+ ByteBufUtils.writeUTF8String(buf, "" + tem.yCoord);
+ ByteBufUtils.writeUTF8String(buf, "" + tem.zCoord);
+ ByteBufUtils.writeItemStack(buf, itemStack);
+ ByteBufUtils.writeUTF8String(buf, player.getCommandSenderName());
+ }
+
+ public static class Handler implements IMessageHandler<MessageMealTerminal, IMessage>{
+
+ @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<MessageMealTerminal, IMessage>{
+
+ @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 Binary files differnew file mode 100644 index 0000000..40888ab --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll$Handler.class diff --git a/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.class b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.class Binary files differnew file mode 100644 index 0000000..770f0c8 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/MessageMealTerminalScroll.class 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<MessageMealTerminalScroll, IMessage>{
+ @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 Binary files differnew file mode 100644 index 0000000..f68029e --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ModelMealCrystal.class 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 Binary files differnew file mode 100644 index 0000000..ccc5c10 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/ModelMealInlet.class 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 Binary files differnew file mode 100644 index 0000000..557f2ce --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/RenderMealCrystal.class 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 Binary files differnew file mode 100644 index 0000000..6bc22b9 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet$1.class diff --git a/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.class b/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.class Binary files differnew file mode 100644 index 0000000..4fbdd1c --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/RenderMealInlet.class 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 Binary files differnew file mode 100644 index 0000000..db2ce4d --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/RenderMealTerminal.class 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 Binary files differnew file mode 100644 index 0000000..6c25b58 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal$1.class diff --git a/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.class b/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.class Binary files differnew file mode 100644 index 0000000..d4ccfe6 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/TileEntityMeal.class 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<ItemStack> listBlocks=new ArrayList<ItemStack>();
+ protected ArrayList<ItemStack> listItems=new ArrayList<ItemStack>();
+
+ private LinkedList<ItemStack> cache=new LinkedList<ItemStack>();
+
+ 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<nbttaglist.tagCount();i++){
+ NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
+ ItemStack it=ItemStack.loadItemStackFromNBT(nbt);
+ it.stackSize=nbt.getInteger("StackSize");
+ listItems.add(it);
+ }
+
+ nbttaglist = (NBTTagList)par1NBTTagCompound.getTag("Blocks");
+ listBlocks.clear();
+ for (int i=0;i<nbttaglist.tagCount();i++){
+ NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
+ ItemStack it=ItemStack.loadItemStackFromNBT(nbt);
+ it.stackSize=nbt.getInteger("StackSize");
+ listBlocks.add(it);
+ }
+ }
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+
+ par1NBTTagCompound.setInteger("FragmentTicks", fragmentTicks);
+
+ NBTTagList nbttaglist = new NBTTagList();
+ for(ItemStack it : listItems){
+ NBTTagCompound nbt = new NBTTagCompound();
+ it.writeToNBT(nbt);
+ nbt.setInteger("StackSize", it.stackSize);
+ nbttaglist.appendTag(nbt);
+ }
+ par1NBTTagCompound.setTag("Items", nbttaglist);
+
+ nbttaglist = new NBTTagList();
+ for(ItemStack it : listBlocks){
+ NBTTagCompound nbt = new NBTTagCompound();
+ it.writeToNBT(nbt);
+ nbt.setInteger("StackSize", it.stackSize);
+ nbttaglist.appendTag(nbt);
+ }
+ par1NBTTagCompound.setTag("Blocks", nbttaglist);
+ }
+
+ private boolean isItemEquals(ItemStack i1, ItemStack i2){
+ if(i1==null && i2==null) return true;
+ if(i1==null && i2!=null) return false;
+ if(i1!=null && i2==null) return false;
+
+ return i1.isItemEqual(i2) && ItemStack.areItemStackTagsEqual(i1, i2);
+ }
+
+ public void sendUpdate(){
+ //if(worldObj.isRemote) return;
+
+ /*
+ for(int i=0;i<worldObj.playerEntities.size();i++){
+ EntityPlayer ep=(EntityPlayer)worldObj.playerEntities.get(i);
+ if(ep.openContainer instanceof ContainerMealTerminal){
+ PacketHandler.INSTANCE.sendTo(new MessageMealTerminal(), (EntityPlayerMP)ep);
+ }
+ }
+ */
+
+ //PacketHandler.INSTANCE.sendToAll(new MessageMealTerminal());
+ }
+
+ /**
+ * 指定したアイテムをリストに格納する
+ * @param itemStack
+ */
+ public void insertItemStack(ItemStack itemStack){
+ if(worldObj.isRemote) return;
+ if(itemStack==null) return;
+
+ FBS.logger.info("inserted:"+itemStack.toString());
+
+ //キャッシュを見る
+ int size=cache.size();
+ for(int i=0;i<size;i++){
+ ItemStack t=cache.get(i);
+ if(isItemEquals(itemStack, t)){
+ //キャッシュにあれば
+ t.stackSize+=itemStack.stackSize;
+
+ //キャッシュ更新
+ cache.remove(i);
+ updateCache(t);
+
+ sendUpdate();
+ return;
+ }
+ }
+
+ //突っ込むリストの決定
+ ArrayList<ItemStack> 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();
+ }
+
+ /**
+ * 全てのアイテムを得る<br>
+ * ただし、ここでは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<sizeBlock;i++) ret[i]=listBlocks.get(i);
+ for(int k=0;k<sizeItem;k++) ret[i+k]=listItems.get(k);
+
+ Arrays.sort(ret, new Comparator<ItemStack>() {
+ @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<ItemStack>[] lists=new ArrayList[]{listBlocks, listItems};
+ for(ArrayList<ItemStack> list : lists){
+ int size=list.size();
+ for(int i=0;i<size;){
+ ItemStack itemStack=list.get(i);
+ if(itemStack==null || itemStack.stackSize<=0){
+ list.remove(i);
+ size--;
+ }
+ else i++;
+ }
+ }
+ }
+
+ /**
+ * 指定したItemStackを取り出す
+ * @param req 指定アイテムスタック
+ * @param stackSize 取り出すスタックサイズ
+ * @return
+ */
+ public ItemStack exportItemStack(ItemStack req, int stackSize){
+ if(worldObj.isRemote) return null;
+ if(req==null || req.getItem()==null || stackSize<=0) return null;
+ if(req.getMaxStackSize()<stackSize) stackSize=req.getMaxStackSize();
+
+ req.stackSize=stackSize;
+ FBS.logger.info("exported:" + req.toString());
+
+ //キャッシュを見る
+ int size=cache.size();
+ for(int i=0;i<size;i++){
+ ItemStack itemStack=cache.get(i);
+ 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;
+
+ //キャッシュ更新
+ cache.remove(i);
+
+ if(itemStack.stackSize>0) updateCache(itemStack);
+ else refreshList();
+
+ sendUpdate();
+ return ret;
+ }
+ }
+
+ //リストを見る
+ ArrayList<ItemStack> 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<list.size();i++){
+ EntityPlayer ep=(EntityPlayer)list.get(i);
+ if(!ep.capabilities.isCreativeMode && worldObj.rand.nextInt(16)==0) FBSEntityPropertiesAPI.LoseSanity(ep, 1, 6, true);
+ }
+ }
+ }
+
+ if(!loaded && getBlockMetadata()==0){
+ ChunkLoadManager.setChunkLoader(worldObj, xCoord, yCoord, zCoord);
+ loaded=true;
+ }
+ }
+
+ @SideOnly(Side.CLIENT)
+ public AxisAlignedBB getRenderBoundingBox() {
+ return AxisAlignedBB.getBoundingBox(xCoord,yCoord,zCoord,xCoord+1,yCoord+2,zCoord+1);
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/storage/TileEntityMealInlet.class b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealInlet.class Binary files differnew file mode 100644 index 0000000..cbbf483 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealInlet.class diff --git a/src/main/java/jp/plusplus/fbs/storage/TileEntityMealInlet.java b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealInlet.java new file mode 100644 index 0000000..d10af3d --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealInlet.java @@ -0,0 +1,138 @@ +package jp.plusplus.fbs.storage;
+
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.ISidedInventory;
+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.tileentity.TileEntityChest;
+import net.minecraftforge.common.util.ForgeDirection;
+
+/**
+ * Created by plusplus_F on 2016/03/07.
+ */
+public class TileEntityMealInlet extends TileEntity implements IMealDevice {
+ public ItemStack fragment;
+
+ @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);
+ if(par1NBTTagCompound.hasKey("Fragment")) fragment=ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Fragment"));
+ else fragment=null;
+ }
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+ if(fragment!=null) par1NBTTagCompound.setTag("Fragment", fragment.writeToNBT(new NBTTagCompound()));
+ }
+
+ @Override
+ public ItemStack getFragment() {
+ return fragment;
+ }
+
+ @Override
+ public void setFragment(ItemStack f){
+ fragment=f;
+ }
+
+ @Override
+ public boolean hasFragment() {
+ return fragment!=null;
+ }
+
+ @Override
+ public void updateEntity(){
+ if(!worldObj.isRemote && worldObj.getWorldTime()%10==0){
+ ItemStack packet=null;
+ TileEntityMeal tem=ItemMealFragment.getTileEntity(fragment);
+ if(tem==null) return;
+
+ //パケットを得る
+ ForgeDirection dir=ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)&7);
+ TileEntity te=worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ);
+ if(te instanceof ISidedInventory){
+ ISidedInventory inv=(ISidedInventory)te;
+ int side=dir.ordinal()^1;
+ int[] index=inv.getAccessibleSlotsFromSide(side);
+
+ for(int i=0;i<index.length;i++){
+ ItemStack itemStack=inv.getStackInSlot(index[i]);
+ if(itemStack!=null && inv.canExtractItem(index[i], itemStack, side)){
+ packet=itemStack.copy();
+ packet.stackSize=1;
+ itemStack.stackSize--;
+ if(itemStack.stackSize<=0) inv.setInventorySlotContents(index[i], null);
+ te.markDirty();
+ break;
+ }
+ }
+ }
+ else if(te instanceof TileEntityChest){
+ TileEntityChest[] c=new TileEntityChest[2];
+ c[0]=(TileEntityChest)te;
+
+ if(c[0].adjacentChestXPos!=null) c[1]=c[0].adjacentChestXPos;
+ if(c[0].adjacentChestXNeg!=null) c[1]=c[0].adjacentChestXNeg;
+ if(c[0].adjacentChestZPos!=null) c[1]=c[0].adjacentChestZPos;
+ if(c[0].adjacentChestZNeg!=null) c[1]=c[0].adjacentChestZNeg;
+
+ for(TileEntityChest inv : c){
+ if(inv==null) break;
+
+ boolean f=false;
+ int size=inv.getSizeInventory();
+ for(int i=0;i<size;i++){
+ ItemStack itemStack=inv.getStackInSlot(i);
+ if(itemStack!=null){
+ packet=itemStack.copy();
+ packet.stackSize=1;
+ itemStack.stackSize--;
+ if(itemStack.stackSize<=0) inv.setInventorySlotContents(i, null);
+ te.markDirty();
+ f=true;
+ break;
+ }
+ }
+
+ if(f) break;
+ }
+ }
+ else if(te instanceof IInventory){
+ IInventory inv=(IInventory)te;
+ int size=inv.getSizeInventory();
+ for(int i=0;i<size;i++){
+ ItemStack itemStack=inv.getStackInSlot(i);
+ if(itemStack!=null){
+ packet=itemStack.copy();
+ packet.stackSize=1;
+ itemStack.stackSize--;
+ if(itemStack.stackSize<=0) inv.setInventorySlotContents(i, null);
+ te.markDirty();
+ break;
+ }
+ }
+ }
+
+ //パケットがあったら転送
+ if(packet!=null){
+ tem.insertItemStack(packet);
+ }
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/storage/TileEntityMealOutletSingle.class b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealOutletSingle.class Binary files differnew file mode 100644 index 0000000..4afbb9f --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealOutletSingle.class diff --git a/src/main/java/jp/plusplus/fbs/storage/TileEntityMealOutletSingle.java b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealOutletSingle.java new file mode 100644 index 0000000..e79ca17 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealOutletSingle.java @@ -0,0 +1,124 @@ +package jp.plusplus.fbs.storage;
+
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.tileentity.TileEntityChest;
+import net.minecraft.tileentity.TileEntityFurnace;
+import net.minecraftforge.common.util.ForgeDirection;
+
+/**
+ * Created by plusplus_F on 2016/03/07.
+ */
+public class TileEntityMealOutletSingle extends TileEntityMealInlet {
+ public ItemStack requirement;
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound){
+ super.readFromNBT(par1NBTTagCompound);
+ if(par1NBTTagCompound.hasKey("Requirement")) requirement=ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Requirement"));
+ else requirement=null;
+ }
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+ if(requirement!=null) par1NBTTagCompound.setTag("Requirement", requirement.writeToNBT(new NBTTagCompound()));
+ }
+
+ public boolean hasRequirement(){
+ return requirement!=null;
+ }
+ public ItemStack getRequirement(){
+ return requirement;
+ }
+ public void setRequirement(ItemStack req){
+ requirement=req;
+ }
+
+ protected ItemStack getItemStack(){
+ if(!hasRequirement() && !hasFragment()) return null;
+
+ TileEntityMeal tem=ItemMealFragment.getTileEntity(getFragment());
+ return tem.exportItemStack(requirement, requirement.stackSize);
+ }
+
+ @Override
+ public void updateEntity(){
+ if(!worldObj.isRemote && requirement!=null && worldObj.getWorldTime()%10==0){
+ TileEntityMeal tem=ItemMealFragment.getTileEntity(fragment);
+ if(tem==null) return;
+
+ ForgeDirection dir=ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)&7);
+ TileEntity te=worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ);
+
+ if(te instanceof ISidedInventory){
+ ISidedInventory inv=(ISidedInventory)te;
+ int side=dir.ordinal()^1;
+ int[] index=inv.getAccessibleSlotsFromSide(side);
+
+ for(int i=0;i<index.length;i++){
+ if(((ISidedInventory) te).canInsertItem(index[i], requirement, side)){
+ ItemStack itemStack=inv.getStackInSlot(index[i]);
+ if((itemStack==null || (itemStack.isItemEqual(requirement) && ItemStack.areItemStackTagsEqual(itemStack, requirement) && itemStack.stackSize+1<=itemStack.getMaxStackSize()))){
+ ItemStack p=tem.exportItemStack(requirement, 1);
+ if(p==null) return;
+
+ if(itemStack==null) inv.setInventorySlotContents(i, p.copy());
+ else itemStack.stackSize++;
+
+ te.markDirty();
+ return;
+ }
+ }
+ }
+ }
+ else if(te instanceof TileEntityChest){
+ TileEntityChest[] c=new TileEntityChest[2];
+ c[0]=(TileEntityChest)te;
+
+ if(c[0].adjacentChestXPos!=null) c[1]=c[0].adjacentChestXPos;
+ if(c[0].adjacentChestXNeg!=null) c[1]=c[0].adjacentChestXNeg;
+ if(c[0].adjacentChestZPos!=null) c[1]=c[0].adjacentChestZPos;
+ if(c[0].adjacentChestZNeg!=null) c[1]=c[0].adjacentChestZNeg;
+
+ for(TileEntityChest inv : c){
+ if(inv==null) break;
+
+ int size=inv.getSizeInventory();
+ for(int i=0;i<size;i++){
+ ItemStack itemStack=inv.getStackInSlot(i);
+ if((itemStack==null || (itemStack.isItemEqual(requirement) && ItemStack.areItemStackTagsEqual(itemStack, requirement) && itemStack.stackSize+1<=itemStack.getMaxStackSize()))){
+ ItemStack p=tem.exportItemStack(requirement, 1);
+ if(p==null) return;
+
+ if(itemStack==null) inv.setInventorySlotContents(i, p.copy());
+ else itemStack.stackSize++;
+
+ te.markDirty();
+ return;
+ }
+ }
+ }
+ }
+ else if(te instanceof IInventory){
+ IInventory inv=(IInventory)te;
+ int size=inv.getSizeInventory();
+ for(int i=0;i<size;i++){
+ ItemStack itemStack=inv.getStackInSlot(i);
+ if((itemStack==null || (itemStack.isItemEqual(requirement) && ItemStack.areItemStackTagsEqual(itemStack, requirement) && itemStack.stackSize+1<=itemStack.getMaxStackSize()))){
+ ItemStack p=tem.exportItemStack(requirement, 1);
+ if(p==null) return;
+
+ if(itemStack==null) inv.setInventorySlotContents(i, p.copy());
+ else itemStack.stackSize++;
+
+ te.markDirty();
+ return;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/storage/TileEntityMealTerminal.class b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealTerminal.class Binary files differnew file mode 100644 index 0000000..21160d8 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealTerminal.class diff --git a/src/main/java/jp/plusplus/fbs/storage/TileEntityMealTerminal.java b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealTerminal.java new file mode 100644 index 0000000..4414d6e --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/storage/TileEntityMealTerminal.java @@ -0,0 +1,55 @@ +package jp.plusplus.fbs.storage;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.tileentity.TileEntity;
+
+/**
+ * Created by plusplus_F on 2016/03/08.
+ */
+public class TileEntityMealTerminal extends TileEntity implements IMealDevice {
+ public ItemStack fragment;
+
+ @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);
+ if(par1NBTTagCompound.hasKey("Fragment")) fragment=ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Fragment"));
+ else fragment=null;
+ }
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+ if(fragment!=null) par1NBTTagCompound.setTag("Fragment", fragment.writeToNBT(new NBTTagCompound()));
+ }
+
+ @Override
+ public ItemStack getFragment() {
+ return fragment;
+ }
+
+ @Override
+ public void setFragment(ItemStack f){
+ fragment=f;
+ markDirty();
+ worldObj.markBlockForUpdate(xCoord,yCoord,zCoord);
+ }
+
+ @Override
+ public boolean hasFragment() {
+ return fragment!=null;
+ }
+}
|
