diff options
| author | Benjamin Culkin <scorpress@gmail.com> | 2024-08-24 08:16:37 -0400 |
|---|---|---|
| committer | Benjamin Culkin <scorpress@gmail.com> | 2024-08-24 08:16:37 -0400 |
| commit | 70c1354a4a96698758a88c032866288f79de6f5a (patch) | |
| tree | eca51294e84b90a4cb3230bc2c7900469e784184 /src/main/java/jp/plusplus/fbs/tileentity | |
Diffstat (limited to 'src/main/java/jp/plusplus/fbs/tileentity')
29 files changed, 2094 insertions, 0 deletions
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TankFBS.class b/src/main/java/jp/plusplus/fbs/tileentity/TankFBS.class Binary files differnew file mode 100644 index 0000000..b50d4ab --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TankFBS.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TankFBS.java b/src/main/java/jp/plusplus/fbs/tileentity/TankFBS.java new file mode 100644 index 0000000..f997693 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TankFBS.java @@ -0,0 +1,50 @@ +package jp.plusplus.fbs.tileentity;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTank;
+
+/**
+ * Createdby pluslus_Fon 2015/05/16.
+ */
+public class TankFBS extends FluidTank {
+ public TankFBS(int capacity) {
+ super(capacity);
+ }
+
+ public TankFBS(FluidStack stack, int capacity) {
+ super(stack, capacity);
+ }
+
+ public TankFBS(Fluid fluid, int amount, int capacity) {
+ super(fluid, amount, capacity);
+ }
+
+ public boolean isEmpty() {
+ return (getFluid() == null) || getFluid().getFluid() == null || (getFluid().amount <= 0);
+ }
+
+ public boolean isFull() {
+ return (getFluid() != null) && (getFluid().amount == getCapacity());
+ }
+
+ public Fluid getFluidType() {
+ return getFluid() != null ? getFluid().getFluid() : null;
+ }
+
+ public String getFluidName(){
+ return (this.fluid != null) && (this.fluid.getFluid() != null) ? this.fluid.getFluid().getLocalizedName(this.fluid): "Empty";
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void setAmount(int par1){
+ if (this.fluid != null && this.fluid.getFluid() != null){
+ this.fluid.amount = par1;
+ if(fluid.amount>capacity){
+ fluid.amount=capacity;
+ }
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityAlchemyCauldron$MaterialPair.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityAlchemyCauldron$MaterialPair.class Binary files differnew file mode 100644 index 0000000..308d607 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityAlchemyCauldron$MaterialPair.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityAlchemyCauldron.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityAlchemyCauldron.class Binary files differnew file mode 100644 index 0000000..02fd483 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityAlchemyCauldron.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityAlchemyCauldron.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityAlchemyCauldron.java new file mode 100644 index 0000000..fdac55c --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityAlchemyCauldron.java @@ -0,0 +1,478 @@ +package jp.plusplus.fbs.tileentity;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.alchemy.AlchemyRegistry;
+import jp.plusplus.fbs.alchemy.characteristic.CharacteristicBase;
+import jp.plusplus.fbs.alchemy.characteristic.CharacteristicQuality;
+import jp.plusplus.fbs.api.FBSEntityPropertiesAPI;
+import jp.plusplus.fbs.exprop.FBSEntityProperties;
+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.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.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Created by plusplus_F on 2015/09/23.
+ */
+public class TileEntityAlchemyCauldron extends TileEntity implements IInventory{
+ public static final int MATERIAL=0;
+ public static final int PRODUCT=1;
+ public static final int RECIPE=2;
+ public ItemStack[] itemStacks=new ItemStack[3];
+ public ArrayList<ItemStack> inputMaterial=new ArrayList<ItemStack>();
+ public ArrayList<MaterialPair> materials=new ArrayList<MaterialPair>(); //描画用
+
+ protected ItemStack lastMaterialItemStack;
+ protected ItemStack lastProductItemStack;
+ protected ItemStack lastRecipeItemStack;
+ public AlchemyRegistry.Recipe cachedRecipe;
+
+ @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);
+
+ //アイテムスロット
+ boolean productFlag=itemStacks[PRODUCT]==null;
+ NBTTagList nbttaglist = (NBTTagList) par1NBTTagCompound.getTag("Items");
+ itemStacks = new ItemStack[getSizeInventory()];
+ for (int i = 0; i < nbttaglist.tagCount(); i++) {
+ NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
+ byte b0 = nbt.getByte("Slot");
+
+ if (b0 >= 0 && b0 < itemStacks.length) {
+ itemStacks[b0] = ItemStack.loadItemStackFromNBT(nbt);
+ }
+ }
+
+ //投入済み素材
+ nbttaglist = (NBTTagList) par1NBTTagCompound.getTag("InputMaterials");
+ inputMaterial.clear();
+ for (int i = 0; i < nbttaglist.tagCount(); i++) {
+ NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
+ inputMaterial.add(ItemStack.loadItemStackFromNBT(nbt));
+ }
+
+ //描画用素材リスト
+ nbttaglist = (NBTTagList) par1NBTTagCompound.getTag("Materials");
+ materials.clear();
+ for (int i = 0; i < nbttaglist.tagCount(); i++) {
+ NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
+ MaterialPair p=new MaterialPair(nbt.getString("Name"));
+ if(nbt.getBoolean("Satisfy")) p.set(true);
+ materials.add(p);
+ }
+
+ //キャッシュたち
+ if(par1NBTTagCompound.hasKey("LastMaterial")) lastMaterialItemStack=ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("LastMaterial"));
+ else lastMaterialItemStack=null;
+
+ if(par1NBTTagCompound.hasKey("LastProduct")) lastProductItemStack=ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("LastProduct"));
+ else lastProductItemStack=null;
+
+ if(par1NBTTagCompound.hasKey("LastRecipe")) lastRecipeItemStack=ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("LastRecipe"));
+ else lastRecipeItemStack=null;
+
+ if(par1NBTTagCompound.hasKey("CachedRecipe")) cachedRecipe=AlchemyRegistry.GetRecipe(ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("CachedRecipe")));
+ else cachedRecipe=null;
+
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+
+ //アイテムスロット
+ NBTTagList nbttaglist = new NBTTagList();
+ for (int i=0;i<itemStacks.length;i++){
+ if (itemStacks[i] != null){
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("Slot", (byte) i);
+ itemStacks[i].writeToNBT(nbt);
+ nbttaglist.appendTag(nbt);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", nbttaglist);
+
+ //投入済み素材
+ nbttaglist = new NBTTagList();
+ for (int i=0;i<inputMaterial.size();i++) {
+ NBTTagCompound nbt = new NBTTagCompound();
+ inputMaterial.get(i).writeToNBT(nbt);
+ nbttaglist.appendTag(nbt);
+ }
+ par1NBTTagCompound.setTag("InputMaterials", nbttaglist);
+
+ //描画用素材リスト
+ nbttaglist = new NBTTagList();
+ for (int i=0;i<materials.size();i++) {
+ NBTTagCompound nbt = new NBTTagCompound();
+ MaterialPair p=materials.get(i);
+ nbt.setString("Name", p.getName());
+ nbt.setBoolean("Satisfy", p.get());
+ nbttaglist.appendTag(nbt);
+ }
+ par1NBTTagCompound.setTag("Materials", nbttaglist);
+
+ //キャッシュたち
+ if(lastMaterialItemStack!=null){
+ NBTTagCompound nbt=new NBTTagCompound();
+ lastMaterialItemStack.writeToNBT(nbt);
+ par1NBTTagCompound.setTag("LastMaterial", nbt);
+ }
+ if(lastProductItemStack!=null){
+ NBTTagCompound nbt=new NBTTagCompound();
+ lastProductItemStack.writeToNBT(nbt);
+ par1NBTTagCompound.setTag("LastProduct", nbt);
+ }
+ if(lastRecipeItemStack!=null){
+ NBTTagCompound nbt=new NBTTagCompound();
+ lastRecipeItemStack.writeToNBT(nbt);
+ par1NBTTagCompound.setTag("LastRecipe", nbt);
+ }
+ if(cachedRecipe!=null){
+ NBTTagCompound nbt=new NBTTagCompound();
+ cachedRecipe.getKey().writeToNBT(nbt);
+ par1NBTTagCompound.setTag("CachedRecipe", nbt);
+ }
+ }
+
+ @Override
+ public void updateEntity(){
+ boolean recipeChanged=false;
+ boolean materialsChanged=false;
+ boolean productChanged=false;
+
+ //-----------------------------------------------------------------------
+ // 完成品スロットの更新
+ //-----------------------------------------------------------------------
+ if(itemStacks[PRODUCT]!=lastProductItemStack){
+ productChanged=true;
+ lastProductItemStack=itemStacks[PRODUCT];
+ }
+
+ //-----------------------------------------------------------------------
+ // レシピの更新
+ //-----------------------------------------------------------------------
+ if(itemStacks[RECIPE]!=lastRecipeItemStack){
+ AlchemyRegistry.Recipe last=cachedRecipe;
+
+ if(itemStacks[RECIPE]!=null) cachedRecipe=AlchemyRegistry.GetRecipe(itemStacks[RECIPE]);
+ else cachedRecipe=null;
+
+ if(last!=cachedRecipe){
+ recipeChanged=true;
+ //アイテムのドロップ
+ if(!worldObj.isRemote){
+ for(ItemStack it : inputMaterial){
+ dropItemStack(it);
+ }
+ }
+ inputMaterial.clear();
+
+ //素材リストの更新
+ materials.clear();
+ if(cachedRecipe!=null){
+ for(String str : cachedRecipe.getMaterialList()){
+ materials.add(new MaterialPair(str));
+ }
+ }
+ }
+ }
+ lastRecipeItemStack=itemStacks[RECIPE];
+
+ //-----------------------------------------------------------------------
+ // 投入素材の更新
+ //-----------------------------------------------------------------------
+ if(itemStacks[RECIPE]!=null && cachedRecipe!=null && (recipeChanged || productChanged || itemStacks[MATERIAL]!=lastMaterialItemStack)){
+ //素材スロットの更新
+ while(itemStacks[MATERIAL]!=null && AlchemyRegistry.IsMaterial(cachedRecipe, itemStacks[MATERIAL], inputMaterial)){
+ materialsChanged=true;
+
+ //素材リストの更新
+ for(MaterialPair it : materials){
+ if(!it.get() && AlchemyRegistry.IsMatching(it.getName(), itemStacks[MATERIAL])){
+ it.set(true);
+ break;
+ }
+ }
+ ItemStack itc=itemStacks[MATERIAL].copy();
+ itc.stackSize=1;
+ inputMaterial.add(itc);
+
+ //素材スロットの更新
+ itemStacks[MATERIAL].stackSize--;
+ if(itemStacks[MATERIAL].stackSize<=0) setInventorySlotContents(MATERIAL, null);
+
+ }
+ }
+ lastMaterialItemStack=itemStacks[MATERIAL];
+
+ //-----------------------------------------------------------------------
+ // 完成品の生成
+ //-----------------------------------------------------------------------
+ /*
+ if((productChanged || materialsChanged) && itemStacks[PRODUCT]==null && AlchemyRegistry.IsSatisfied(cachedRecipe, inputMaterial)){
+ if(!worldObj.isRemote) setInventorySlotContents(PRODUCT, AlchemyRegistry.GetAlchemyProduct(cachedRecipe, inputMaterial));
+ inputMaterial.clear();
+
+ //素材リストの更新
+ materials.clear();
+ if(cachedRecipe!=null){
+ for(String str : cachedRecipe.getMaterialList()){
+ materials.add(new MaterialPair(str));
+ }
+ }
+ productChanged=true;
+ }
+ */
+
+ if(materialsChanged || productChanged || recipeChanged) markDirty();
+ }
+
+ /**
+ * 周囲にアイテムスタックを落とす
+ * @param itemStack
+ */
+ protected void dropItemStack(ItemStack itemStack){
+ if (itemStack != null){
+ float f = AlchemyRegistry.getRandom().nextFloat() * 0.8F + 0.1F;
+ float f1 = AlchemyRegistry.getRandom().nextFloat() * 0.8F + 0.1F;
+ float f2 = AlchemyRegistry.getRandom().nextFloat() * 0.8F + 0.1F;
+
+ while (itemStack.stackSize > 0){
+ int k1 = AlchemyRegistry.getRandom().nextInt(21) + 10;
+
+ if (k1 > itemStack.stackSize){
+ k1 = itemStack.stackSize;
+ }
+
+ itemStack.stackSize -= k1;
+ EntityItem entityitem = new EntityItem(worldObj, (double)((float)xCoord + f), (double)((float)yCoord + f1), (double)((float)zCoord + 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)AlchemyRegistry.getRandom().nextGaussian() * f3);
+ entityitem.motionY = (double)((float)AlchemyRegistry.getRandom().nextGaussian() * f3 + 0.2F);
+ entityitem.motionZ = (double)((float)AlchemyRegistry.getRandom().nextGaussian() * f3);
+ worldObj.spawnEntityInWorld(entityitem);
+ }
+ }
+ }
+
+ public float getCompoundingProbability(EntityPlayer ep){
+ int mLv=FBSEntityPropertiesAPI.GetMagicLevel(ep);
+ int lv=cachedRecipe.getLevel();
+
+ float p=cachedRecipe.getProb()+0.02f*Math.max(mLv-lv, 0);
+ if(p<0) p=0;
+ if(p>5.f) p=5.f;
+
+ return p;
+ }
+
+ public boolean canCompounding(){
+ return itemStacks[PRODUCT]==null && AlchemyRegistry.IsSatisfied(cachedRecipe, inputMaterial);
+ }
+
+ /**
+ * 調合をする
+ * @param ep
+ */
+ public void tryCompounding(EntityPlayer ep){
+ if(this.cachedRecipe==null) return;
+
+ //成功判定
+ float pr=getCompoundingProbability(ep);
+ if(worldObj.rand.nextFloat()<pr){
+ setInventorySlotContents(PRODUCT, AlchemyRegistry.GetAlchemyProduct(cachedRecipe, inputMaterial));
+
+ //品質の向上
+ if(pr>1.f){
+ ItemStack product=getStackInSlot(PRODUCT);
+ if(product!=null){
+ ArrayList<CharacteristicBase> cbs=AlchemyRegistry.ReadCharacteristicFromNBT(product.getTagCompound());
+
+ while(pr>1.f){
+ float pp=pr-1.f;
+ if(worldObj.rand.nextFloat()<pp){
+ //品質は2,(null),0,1の順で変化する
+ CharacteristicQuality cq=null;
+ for(CharacteristicBase cb : cbs){
+ if(cb instanceof CharacteristicQuality){
+ cq=(CharacteristicQuality)cb;
+ break;
+ }
+ }
+ if(cq==null){
+ cq=new CharacteristicQuality();
+ cq.setValue(0);
+ cbs.add(cq);
+ }
+
+ if(cq.getValue()==0) cq.setValue(1);
+ else if(cq.getValue()==2) cbs.remove(cq);
+ }
+
+ pr-=1.f;
+ }
+ NBTTagCompound nbt=new NBTTagCompound();
+ AlchemyRegistry.WriteCharacteristicToNBT(nbt, cbs);
+ product.setTagCompound(nbt);
+ }
+ }
+ }
+
+ //素材の消費
+ inputMaterial.clear();
+
+ //素材リストの更新
+ materials.clear();
+ if(cachedRecipe!=null){
+ for(String str : cachedRecipe.getMaterialList()){
+ materials.add(new MaterialPair(str));
+ }
+ }
+
+ markDirty();
+ }
+
+ @SideOnly(Side.CLIENT)
+ public AxisAlignedBB getRenderBoundingBox() {
+ return AxisAlignedBB.getBoundingBox(xCoord-1,yCoord,zCoord-1,xCoord+2,yCoord+1,zCoord+2);
+ }
+
+ //--------------------------------------------------------------------------------------------
+
+ @Override
+ public int getSizeInventory() {
+ return itemStacks.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int p_70301_1_) {
+ if(p_70301_1_<0 || p_70301_1_>=itemStacks.length) return null;
+ return itemStacks[p_70301_1_];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ if (itemStacks[i] != null){
+ ItemStack itemstack;
+
+ if (itemStacks[i].stackSize <= j){
+ itemstack = itemStacks[i];
+ itemStacks[i] = null;
+ markDirty();
+ return itemstack;
+ }
+ else{
+ itemstack = itemStacks[i].splitStack(j);
+
+ if (itemStacks[i].stackSize == 0){
+ itemStacks[i] = null;
+ }
+ markDirty();
+ return itemstack;
+ }
+ }
+ else{
+ return null;
+ }
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ if (itemStacks[i] != null){
+ ItemStack itemstack = itemStacks[i];
+ itemStacks[i] = null;
+ markDirty();
+ return itemstack;
+ }
+ else{
+ return null;
+ }
+ }
+
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemStack) {
+ itemStacks[i] = itemStack;
+ if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()){
+ itemStack.stackSize = getInventoryStackLimit();
+ }
+ markDirty();
+ }
+
+ @Override
+ public String getInventoryName() {
+ return getBlockType().getLocalizedName();
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityPlayer) {
+ return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : entityPlayer.getDistanceSq((double)xCoord+0.5D, (double)yCoord+0.5D, (double)zCoord+0.5D) <= 64.0D;
+ }
+
+ @Override
+ public void openInventory() {
+
+ }
+
+ @Override
+ public void closeInventory() {
+
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
+ return false;
+ }
+
+ public class MaterialPair{
+ public String name;
+ public boolean satisfy;
+
+ public MaterialPair(String name){
+ this.name=name;
+ }
+ public void set(boolean flag){ satisfy=flag; }
+ public boolean get(){ return satisfy; }
+ public String getName(){ return name; }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityExtractingFurnace.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityExtractingFurnace.class Binary files differnew file mode 100644 index 0000000..5858a7e --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityExtractingFurnace.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityExtractingFurnace.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityExtractingFurnace.java new file mode 100644 index 0000000..28e55d2 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityExtractingFurnace.java @@ -0,0 +1,351 @@ +package jp.plusplus.fbs.tileentity;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.block.BlockExtractingFurnace;
+import jp.plusplus.fbs.item.ItemBookSorcery;
+import jp.plusplus.fbs.item.ItemCore;
+import jp.plusplus.fbs.item.ItemOldBook;
+import net.minecraft.client.resources.I18n;
+import net.minecraft.entity.player.EntityPlayer;
+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.util.IIcon;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.*;
+
+/**
+ * Createdby pluslus_Fon 2015/06/08.
+ */
+public class TileEntityExtractingFurnace extends TileEntity implements ISidedInventory,IFluidHandler {
+ public static final int TANK_CAPACITY=8000;
+ public TankFBS tank=new TankFBS(TANK_CAPACITY);
+
+ private static final int[] slots=new int[]{0,1}, slotsBook=new int[]{2};
+ public ItemStack[] itemStacks=new ItemStack[3];
+
+ public static final short MAX_PROGRESS=20*10;
+ public short progress;
+ public boolean state;
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound){
+ super.readFromNBT(par1NBTTagCompound);
+
+ state=par1NBTTagCompound.getBoolean("FurnaceState");
+ progress= par1NBTTagCompound.getShort("Progress");
+
+ NBTTagList nbttaglist = (NBTTagList)par1NBTTagCompound.getTag("Items");
+ itemStacks = new ItemStack[getSizeInventory()];
+ for (int i=0;i<nbttaglist.tagCount();i++){
+ NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
+ byte b0 = nbt.getByte("Slot");
+
+ if (b0>=0 && b0<itemStacks.length){
+ itemStacks[b0] = ItemStack.loadItemStackFromNBT(nbt);
+ }
+ }
+
+ tank = new TankFBS(TANK_CAPACITY);
+ if (par1NBTTagCompound.hasKey("Tank")) {
+ tank.readFromNBT(par1NBTTagCompound.getCompoundTag("Tank"));
+ }
+ }
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+
+ par1NBTTagCompound.setBoolean("FurnaceState", state);
+ par1NBTTagCompound.setShort("Progress", progress);
+
+ NBTTagList nbttaglist = new NBTTagList();
+ for (int i=0;i<itemStacks.length;i++){
+ if (itemStacks[i] != null){
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("Slot", (byte) i);
+ itemStacks[i].writeToNBT(nbt);
+ nbttaglist.appendTag(nbt);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", nbttaglist);
+
+ NBTTagCompound nbt = new NBTTagCompound();
+ tank.writeToNBT(nbt);
+ par1NBTTagCompound.setTag("Tank", nbt);
+ }
+
+ @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 updateEntity() {
+ if (worldObj.isRemote) return;
+
+ //------------ extracting -----------
+ if (itemStacks[2] != null) {
+ int amount=0;
+
+ if(itemStacks[2].getItem() == ItemCore.bookOld || itemStacks[2].getItem() == ItemCore.bookSorcery){
+ //本の場合、魔力量を計算する
+ Registry.BookData bd = Registry.GetBookDataFromItemStack(itemStacks[2]);
+ if (bd.isMagic) {
+ Registry.MagicData md=Registry.GetMagic(bd.title);
+ amount = 200 + 50 * bd.lv;
+ amount=(int)(amount*(1+(float)ItemBookSorcery.getMagicMaxUse(itemStacks[2])/md.maxUse));
+ } else{
+ amount = 300 + 80 * bd.lv;
+ }
+ }
+ else{
+ //それ以外の場合、Registryに問い合わせる
+ amount=Registry.GetContainsMana(itemStacks[2]);
+ }
+
+ if (amount>0) {
+ if (tank.getFluidAmount() + amount <= tank.getCapacity()) {
+ if(!state){
+ state=true;
+ BlockExtractingFurnace.updateFurnaceBlockState(true, worldObj, xCoord, yCoord, zCoord);
+ }
+
+ if (progress >= MAX_PROGRESS) {
+ itemStacks[2].stackSize--;
+ if (itemStacks[2].stackSize == 0) {
+ setInventorySlotContents(2, null);
+ }
+
+ tank.fill(new FluidStack(BlockCore.mana, amount), true);
+ markDirty();
+ progress = 0;
+ }
+
+ progress++;
+ }
+ }
+ } else {
+ if(state){
+ state=false;
+ BlockExtractingFurnace.updateFurnaceBlockState(false, worldObj, xCoord, yCoord, zCoord);
+ }
+ progress = 0;
+ }
+
+ //------------ bucket ---------------
+
+ //checking inventory
+ if (itemStacks[0] == null) return;
+ if (itemStacks[0].stackSize <= 0) {
+ itemStacks[0] = null;
+ return;
+ }
+
+ FluidStack fluid = tank.getFluid();
+ if (fluid != null && fluid.getFluid() != null) {
+
+ ItemStack get = FluidContainerRegistry.fillFluidContainer(fluid.copy(), itemStacks[0]);
+ if (get != null) {
+ int cap = FluidContainerRegistry.getContainerCapacity(get);
+ if (fluid.amount < cap) return;
+
+ if (itemStacks[1] != null) {
+ if (!itemStacks[1].isItemEqual(get)) return;
+ if (itemStacks[1].stackSize + get.stackSize > itemStacks[1].getMaxStackSize()) return;
+ }
+
+ if (itemStacks[1] == null || itemStacks[1].stackSize <= 0) {
+ setInventorySlotContents(1, get);
+ } else {
+ itemStacks[1].stackSize += get.stackSize;
+ }
+
+ itemStacks[0].stackSize--;
+ if (itemStacks[0].stackSize <= 0) {
+ setInventorySlotContents(0, null);
+ }
+
+ drain(ForgeDirection.UNKNOWN, cap, true);
+ markDirty();
+ }
+
+ }
+ }
+
+
+ public int getProgressScaled(int par1){
+ return par1*this.progress/MAX_PROGRESS;
+ }
+ @SideOnly(Side.CLIENT)
+ public IIcon getFluidIcon(){
+ Fluid fluid = tank.getFluidType();
+ return fluid != null ? fluid.getIcon() : null;
+ }
+
+ //-------------------------------------------------------------------------------------
+
+ @Override
+ public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
+ if (resource == null || resource.getFluid() == null){
+ return 0;
+ }
+
+ FluidStack current = tank.getFluid();
+ FluidStack resourceCopy = resource.copy();
+ if (current != null && current.amount > 0 && !current.isFluidEqual(resourceCopy)){
+ return 0;
+ }
+
+ int i = 0;
+ int used = tank.fill(resourceCopy, doFill);
+ resourceCopy.amount -= used;
+ i += used;
+
+ return i;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection forgeDirection, FluidStack resource, boolean doDrain) {
+ if (resource == null) {
+ return null;
+ }
+ if (tank.getFluidType() == resource.getFluid()) {
+ return tank.drain(resource.amount, doDrain);
+ }
+ return null;
+ }
+ @Override
+ public FluidStack drain(ForgeDirection forgeDirection, int max, boolean b) {
+ return tank.drain(max, b);
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection from, Fluid fluid) {
+ return fluid == BlockCore.mana;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection from, Fluid fluid) {
+ return !tank.isEmpty();
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection from) {
+ return new FluidTankInfo[0];
+ }
+
+ //------------------------------------------------------------------
+ @Override
+ public int getSizeInventory() {
+ return itemStacks.length;
+ }
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ return itemStacks[i];
+ }
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ if (itemStacks[i] != null){
+ ItemStack itemstack;
+
+ if (itemStacks[i].stackSize <= j){
+ itemstack = itemStacks[i];
+ itemStacks[i] = null;
+ markDirty();
+ return itemstack;
+ }
+ else{
+ itemstack = itemStacks[i].splitStack(j);
+
+ if (itemStacks[i].stackSize == 0){
+ itemStacks[i] = null;
+ }
+ markDirty();
+ return itemstack;
+ }
+ }
+ else{
+ return null;
+ }
+ }
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ if (itemStacks[i] != null){
+ ItemStack itemstack = itemStacks[i];
+ itemStacks[i] = null;
+ markDirty();
+ return itemstack;
+ }
+ else{
+ return null;
+ }
+ }
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemStack) {
+ itemStacks[i] = itemStack;
+ if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()){
+ itemStack.stackSize = getInventoryStackLimit();
+ }
+ markDirty();
+ }
+ @Override
+ public String getInventoryName() {
+ return BlockCore.extractingFurnace.getLocalizedName();
+ }
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityPlayer) {
+ return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : entityPlayer.getDistanceSq((double)xCoord+0.5D, (double)yCoord+0.5D, (double)zCoord+0.5D) <= 64.0D;
+ }
+ @Override
+ public void openInventory() {
+ }
+ @Override
+ public void closeInventory() {
+ }
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ if(i==0) {
+ if(itemstack.getItem()== ItemCore.bookSorcery || itemstack.getItem()== ItemCore.bookOld) return false;
+ return FluidContainerRegistry.fillFluidContainer(tank.getFluid(), itemstack) != null;
+ }
+ else if(i==2){
+ return itemstack.getItem()== ItemCore.bookSorcery || itemstack.getItem()== ItemCore.bookOld;
+ }
+ return false;
+ }
+ @Override
+ public int[] getAccessibleSlotsFromSide(int var1) {
+ return (var1<2)?slots:slotsBook;
+ }
+ @Override
+ public boolean canInsertItem(int i, ItemStack itemstack, int j) {
+ return i!=1 && isItemValidForSlot(i, itemstack);
+ }
+ @Override
+ public boolean canExtractItem(int i, ItemStack itemstack, int j) {
+ return i==1;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFBSWorkbench.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFBSWorkbench.class Binary files differnew file mode 100644 index 0000000..aaacffb --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFBSWorkbench.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFBSWorkbench.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFBSWorkbench.java new file mode 100644 index 0000000..f31230f --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFBSWorkbench.java @@ -0,0 +1,341 @@ +package jp.plusplus.fbs.tileentity;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.container.ContainerDummy;
+import jp.plusplus.fbs.item.ItemCore;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.inventory.InventoryCrafting;
+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.IIcon;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.*;
+
+/**
+ * Created by pluslus_F on 2015/06/14.
+ */
+public class TileEntityFBSWorkbench extends TileEntity implements ISidedInventory,IFluidHandler {
+ public static final int TANK_CAPACITY=4000;
+ public TankFBS tank=new TankFBS(TANK_CAPACITY);
+
+ private static final int[] slotsMaterial=new int[]{0,1,2,3,4,5,6,7,8}, slotsProduct=new int[]{9}, slotsMana=new int[]{10,11};
+ public ItemStack[] itemStacks=new ItemStack[12];
+ public Container dummy=new ContainerDummy();
+ public InventoryCrafting dummyInv=new InventoryCrafting(dummy,3,3);
+ public Registry.RecipePair product;
+
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound){
+ super.readFromNBT(par1NBTTagCompound);
+
+ NBTTagList nbttaglist = (NBTTagList)par1NBTTagCompound.getTag("Items");
+ itemStacks = new ItemStack[getSizeInventory()];
+ for (int i=0;i<nbttaglist.tagCount();i++){
+ NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
+ byte b0 = nbt.getByte("Slot");
+
+ if (b0>=0 && b0<itemStacks.length){
+ itemStacks[b0] = ItemStack.loadItemStackFromNBT(nbt);
+ }
+ }
+
+ tank = new TankFBS(TANK_CAPACITY);
+ if (par1NBTTagCompound.hasKey("Tank")) {
+ tank.readFromNBT(par1NBTTagCompound.getCompoundTag("Tank"));
+ }
+
+ onInventoryChange();
+ }
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+
+ NBTTagList nbttaglist = new NBTTagList();
+ for (int i=0;i<itemStacks.length;i++){
+ if (itemStacks[i] != null){
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("Slot", (byte) i);
+ itemStacks[i].writeToNBT(nbt);
+ nbttaglist.appendTag(nbt);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", nbttaglist);
+
+ NBTTagCompound nbt = new NBTTagCompound();
+ tank.writeToNBT(nbt);
+ par1NBTTagCompound.setTag("Tank", nbt);
+ }
+
+ @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());
+ }
+
+ public void updateEntity(){
+ //checking inventory
+ ItemStack fc=itemStacks[slotsMana[0]];
+ ItemStack ec=itemStacks[slotsMana[1]];
+ if (fc == null) return;
+ if (fc.stackSize <= 0) {
+ fc = null;
+ return;
+ }
+
+ FluidStack fluid2 = FluidContainerRegistry.getFluidForFilledItem(fc);
+ if(fluid2 != null && fluid2.getFluid()!=null && fluid2.getFluid()==BlockCore.mana) {
+ int put = fill(ForgeDirection.UNKNOWN, fluid2, false);
+
+ if (put == fluid2.amount) {
+ ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(fc);
+ if (emptyContainer != null) {
+ if (ec != null) {
+ if (!ec.isItemEqual(emptyContainer)) return;
+ if (ec.stackSize + emptyContainer.stackSize > ec.getMaxStackSize()) return;
+ ec.stackSize+=emptyContainer.stackSize;
+ }
+ else {
+ setInventorySlotContents(slotsMana[1], emptyContainer);
+ }
+ }
+
+ fc.stackSize--;
+ if(fc.stackSize<=1){
+ setInventorySlotContents(slotsMana[0], null);
+ }
+
+ fill(ForgeDirection.UNKNOWN, fluid2, true);
+ markDirty();
+ }
+ }
+ else{
+ FluidStack fluid = tank.getFluid();
+ if (fluid != null && fluid.getFluid() != null) {
+
+ ItemStack get = FluidContainerRegistry.fillFluidContainer(fluid.copy(), fc);
+ if (get != null) {
+ int cap = FluidContainerRegistry.getContainerCapacity(get);
+ if (fluid.amount < cap) return;
+
+ if (ec != null) {
+ if (!ec.isItemEqual(get)) return;
+ if (ec.stackSize + get.stackSize > fc.getMaxStackSize()) return;
+ }
+
+ if (ec == null || ec.stackSize <= 0) {
+ setInventorySlotContents(slotsMana[1], get);
+ } else {
+ ec.stackSize += get.stackSize;
+ }
+
+ fc.stackSize--;
+ if (fc.stackSize <= 1) {
+ setInventorySlotContents(slotsMana[0], null);
+ }
+
+ drain(ForgeDirection.UNKNOWN, cap, true);
+ markDirty();
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------------------------------
+ @Override
+ public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
+ if (resource == null || resource.getFluid() == null){
+ return 0;
+ }
+
+ FluidStack current = tank.getFluid();
+ FluidStack resourceCopy = resource.copy();
+ if (current != null && current.amount > 0 && !current.isFluidEqual(resourceCopy)){
+ return 0;
+ }
+
+ int i = 0;
+ int used = tank.fill(resourceCopy, doFill);
+ resourceCopy.amount -= used;
+ i += used;
+
+ return i;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection forgeDirection, FluidStack resource, boolean doDrain) {
+ if (resource == null) {
+ return null;
+ }
+ if (tank.getFluidType() == resource.getFluid()) {
+ return tank.drain(resource.amount, doDrain);
+ }
+ return null;
+ }
+ @Override
+ public FluidStack drain(ForgeDirection forgeDirection, int max, boolean b) {
+ return tank.drain(max, b);
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection from, Fluid fluid) {
+ return fluid == BlockCore.mana;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection from, Fluid fluid) {
+ return !tank.isEmpty();
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection from) {
+ return new FluidTankInfo[0];
+ }
+
+ @SideOnly(Side.CLIENT)
+ public IIcon getFluidIcon(){
+ Fluid fluid = tank.getFluidType();
+ return fluid != null ? fluid.getIcon() : null;
+ }
+
+ public void onInventoryChange() {
+ for (int i = 0; i < slotsMaterial.length; i++) {
+ dummyInv.setInventorySlotContents(i, itemStacks[slotsMaterial[i]]);
+ }
+ product = Registry.FindMatchingRecipe(dummyInv, worldObj);
+ if (product != null && tank.getFluidAmount()>=product.mana) setInventorySlotContents(slotsProduct[0], product.recipe.getCraftingResult(dummyInv));
+ else setInventorySlotContents(slotsProduct[0], null);
+ }
+
+ //------------------------------------------------------------------
+ @Override
+ public int getSizeInventory() {
+ return itemStacks.length;
+ }
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ return itemStacks[i];
+ }
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ if (itemStacks[i] != null){
+ ItemStack itemstack;
+
+ if (itemStacks[i].stackSize <= j){
+ itemstack = itemStacks[i];
+ itemStacks[i] = null;
+
+ if(i==slotsProduct[0] && product!=null){
+ tank.drain(product.mana*itemstack.stackSize, true);
+ }
+ onInventoryChange();
+
+ markDirty();
+ return itemstack;
+ }
+ else{
+ itemstack = itemStacks[i].splitStack(j);
+
+ if (itemStacks[i].stackSize == 0){
+ itemStacks[i] = null;
+ }
+
+ if(i==slotsProduct[0] && product!=null){
+ tank.drain(product.mana*itemstack.stackSize, true);
+ }
+ onInventoryChange();
+
+ markDirty();
+ return itemstack;
+ }
+ }
+ else{
+ return null;
+ }
+ }
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ if (itemStacks[i] != null){
+ ItemStack itemstack = itemStacks[i];
+ itemStacks[i] = null;
+ markDirty();
+ return itemstack;
+ }
+ else{
+ return null;
+ }
+ }
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemStack) {
+ itemStacks[i] = itemStack;
+ if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()){
+ itemStack.stackSize = getInventoryStackLimit();
+ }
+ if(i!=slotsProduct[0]) onInventoryChange();
+ markDirty();
+ }
+ @Override
+ public String getInventoryName() {
+ return BlockCore.workbench.getLocalizedName();
+ }
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityPlayer) {
+ return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : entityPlayer.getDistanceSq((double)xCoord+0.5D, (double)yCoord+0.5D, (double)zCoord+0.5D) <= 64.0D;
+ }
+ @Override
+ public void openInventory() {
+ }
+ @Override
+ public void closeInventory() {
+ }
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ if(i==10){
+ FluidStack f=FluidContainerRegistry.getFluidForFilledItem(itemstack);
+ return f!=null && f.getFluid()==BlockCore.mana;
+ }
+ return false;
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
+ return slotsMana;
+ }
+
+ @Override
+ public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) {
+ if(p_102007_1_!=slotsMana[0]) return false;
+ FluidStack fc=FluidContainerRegistry.getFluidForFilledItem(p_102007_2_);
+ return fc!=null && fc.getFluid()==BlockCore.mana;
+ }
+
+ @Override
+ public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
+ return p_102008_1_==slotsMana[1];
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFillingTable.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFillingTable.class Binary files differnew file mode 100644 index 0000000..4fcaf68 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFillingTable.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFillingTable.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFillingTable.java new file mode 100644 index 0000000..ebd9628 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityFillingTable.java @@ -0,0 +1,357 @@ +package jp.plusplus.fbs.tileentity;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.item.ItemBookSorcery;
+import jp.plusplus.fbs.item.ItemCore;
+import net.minecraft.entity.player.EntityPlayer;
+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.util.IIcon;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.*;
+
+/**
+ * Createdby pluslus_Fon 2015/06/14.
+ */
+public class TileEntityFillingTable extends TileEntity implements ISidedInventory,IFluidHandler {
+ public static final int TANK_CAPACITY=4000;
+ public TankFBS tank=new TankFBS(TANK_CAPACITY);
+
+ private static final int[] slotsBook=new int[]{0}, slotsFluid=new int[]{1,2};
+ public ItemStack[] itemStacks=new ItemStack[3];
+
+ public static final short MAX_PROGRESS=20*10;
+ public short progress;
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound){
+ super.readFromNBT(par1NBTTagCompound);
+
+ progress= par1NBTTagCompound.getShort("Progress");
+
+ NBTTagList nbttaglist = (NBTTagList)par1NBTTagCompound.getTag("Items");
+ itemStacks = new ItemStack[getSizeInventory()];
+ for (int i=0;i<nbttaglist.tagCount();i++){
+ NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
+ byte b0 = nbt.getByte("Slot");
+
+ if (b0>=0 && b0<itemStacks.length){
+ itemStacks[b0] = ItemStack.loadItemStackFromNBT(nbt);
+ }
+ }
+
+ tank = new TankFBS(TANK_CAPACITY);
+ if (par1NBTTagCompound.hasKey("Tank")) {
+ tank.readFromNBT(par1NBTTagCompound.getCompoundTag("Tank"));
+ }
+ }
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+
+ par1NBTTagCompound.setShort("Progress", progress);
+
+ NBTTagList nbttaglist = new NBTTagList();
+ for (int i=0;i<itemStacks.length;i++){
+ if (itemStacks[i] != null){
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("Slot", (byte) i);
+ itemStacks[i].writeToNBT(nbt);
+ nbttaglist.appendTag(nbt);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", nbttaglist);
+
+ NBTTagCompound nbt = new NBTTagCompound();
+ tank.writeToNBT(nbt);
+ par1NBTTagCompound.setTag("Tank", nbt);
+ }
+
+ @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 updateEntity() {
+ if(worldObj.isRemote) return;
+
+ //------------ filling --------------
+ if(itemStacks[0]!=null && itemStacks[0].getItem()==ItemCore.bookSorcery){
+ Registry.BookData bd=Registry.GetBookDataFromItemStack(itemStacks[0]);
+ if(bd!=null && bd.isMagic){
+ int amount=40*bd.lv;
+ if(tank.getFluidAmount()>=amount){
+ if (progress >= MAX_PROGRESS) {
+ tank.drain(amount, true);
+
+ //一定確率で失敗する
+ float pr;
+ if(bd.lv<=5) pr=1.0f;
+ else if(bd.lv<40) pr=1.0f-0.02f*(bd.lv-5);
+ else pr=0.3f;
+ if(worldObj.rand.nextFloat()<pr){
+ ItemBookSorcery.setMagicMaxUse(itemStacks[0], ItemBookSorcery.getMagicMaxUse(itemStacks[0])+1);
+ }
+ else{
+ setInventorySlotContents(0, new ItemStack(ItemCore.bookBroken, 1, itemStacks[0].getItemDamage()));
+ }
+
+ markDirty();
+ progress=0;
+ }
+
+ progress++;
+ }
+ }
+ }
+ else{
+ progress=0;
+ }
+
+ //------------ bucket ---------------
+
+ //checking inventory
+ if (itemStacks[1] == null) return;
+ if (itemStacks[1].stackSize <= 0) {
+ itemStacks[1] = null;
+ return;
+ }
+
+ FluidStack fluid2 = FluidContainerRegistry.getFluidForFilledItem(itemStacks[1]);
+ if(fluid2 != null && fluid2.getFluid()!=null && fluid2.getFluid()==BlockCore.mana) {
+ int put = fill(ForgeDirection.UNKNOWN, fluid2, false);
+
+ if (put == fluid2.amount) {
+ ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(itemStacks[1]);
+ if (emptyContainer != null) {
+ if (itemStacks[2] != null) {
+ if (!itemStacks[2].isItemEqual(emptyContainer)) return;
+ if (itemStacks[2].stackSize + emptyContainer.stackSize > itemStacks[2].getMaxStackSize()) return;
+ itemStacks[2].stackSize+=emptyContainer.stackSize;
+ }
+ else {
+ setInventorySlotContents(2, emptyContainer);
+ }
+ }
+
+ itemStacks[1].stackSize--;
+ if(itemStacks[1].stackSize<=1){
+ setInventorySlotContents(1, null);
+ }
+
+ fill(ForgeDirection.UNKNOWN, fluid2, true);
+ markDirty();
+ }
+ }
+ else{
+ FluidStack fluid = tank.getFluid();
+ if (fluid != null && fluid.getFluid() != null) {
+
+ ItemStack get = FluidContainerRegistry.fillFluidContainer(fluid.copy(), itemStacks[1]);
+ if (get != null) {
+ int cap = FluidContainerRegistry.getContainerCapacity(get);
+ if (fluid.amount < cap) return;
+
+ if (itemStacks[2] != null) {
+ if (!itemStacks[2].isItemEqual(get)) return;
+ if (itemStacks[2].stackSize + get.stackSize > itemStacks[1].getMaxStackSize()) return;
+ }
+
+ if (itemStacks[2] == null || itemStacks[2].stackSize <= 0) {
+ setInventorySlotContents(2, get);
+ } else {
+ itemStacks[2].stackSize += get.stackSize;
+ }
+
+ itemStacks[1].stackSize--;
+ if (itemStacks[1].stackSize <= 1) {
+ setInventorySlotContents(1, null);
+ }
+
+ drain(ForgeDirection.UNKNOWN, cap, true);
+ markDirty();
+ }
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------------------------
+
+ @Override
+ public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
+ if (resource == null || resource.getFluid() == null){
+ return 0;
+ }
+
+ FluidStack current = tank.getFluid();
+ FluidStack resourceCopy = resource.copy();
+ if (current != null && current.amount > 0 && !current.isFluidEqual(resourceCopy)){
+ return 0;
+ }
+
+ int i = 0;
+ int used = tank.fill(resourceCopy, doFill);
+ resourceCopy.amount -= used;
+ i += used;
+
+ return i;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection forgeDirection, FluidStack resource, boolean doDrain) {
+ if (resource == null) {
+ return null;
+ }
+ if (tank.getFluidType() == resource.getFluid()) {
+ return tank.drain(resource.amount, doDrain);
+ }
+ return null;
+ }
+ @Override
+ public FluidStack drain(ForgeDirection forgeDirection, int max, boolean b) {
+ return tank.drain(max, b);
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection from, Fluid fluid) {
+ return fluid == BlockCore.mana;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection from, Fluid fluid) {
+ return !tank.isEmpty();
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection from) {
+ return new FluidTankInfo[0];
+ }
+
+ public int getProgressScaled(int par1){
+ return par1*this.progress/MAX_PROGRESS;
+ }
+ @SideOnly(Side.CLIENT)
+ public IIcon getFluidIcon(){
+ Fluid fluid = tank.getFluidType();
+ return fluid != null ? fluid.getIcon() : null;
+ }
+
+ //------------------------------------------------------------------
+ @Override
+ public int getSizeInventory() {
+ return itemStacks.length;
+ }
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ return itemStacks[i];
+ }
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ if (itemStacks[i] != null){
+ ItemStack itemstack;
+
+ if (itemStacks[i].stackSize <= j){
+ itemstack = itemStacks[i];
+ itemStacks[i] = null;
+ markDirty();
+ return itemstack;
+ }
+ else{
+ itemstack = itemStacks[i].splitStack(j);
+
+ if (itemStacks[i].stackSize == 0){
+ itemStacks[i] = null;
+ }
+ markDirty();
+ return itemstack;
+ }
+ }
+ else{
+ return null;
+ }
+ }
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ if (itemStacks[i] != null){
+ ItemStack itemstack = itemStacks[i];
+ itemStacks[i] = null;
+ markDirty();
+ return itemstack;
+ }
+ else{
+ return null;
+ }
+ }
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemStack) {
+ itemStacks[i] = itemStack;
+ if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()){
+ itemStack.stackSize = getInventoryStackLimit();
+ }
+ markDirty();
+ }
+ @Override
+ public String getInventoryName() {
+ return BlockCore.fillingTable.getLocalizedName();
+ }
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityPlayer) {
+ return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : entityPlayer.getDistanceSq((double)xCoord+0.5D, (double)yCoord+0.5D, (double)zCoord+0.5D) <= 64.0D;
+ }
+ @Override
+ public void openInventory() {
+ }
+ @Override
+ public void closeInventory() {
+ }
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ if(i==0) {
+ return itemstack.getItem()==ItemCore.bookSorcery;
+ }
+ else if(i==1){
+ if(itemstack.getItem()==ItemCore.bookSorcery) return false;
+ FluidStack f=FluidContainerRegistry.getFluidForFilledItem(itemstack);
+ return f!=null && f.getFluid()==BlockCore.mana;
+ }
+ return false;
+ }
+ @Override
+ public int[] getAccessibleSlotsFromSide(int var1) {
+ if(var1==0 || var1==1) return slotsBook;
+ return slotsFluid;
+ }
+ @Override
+ public boolean canInsertItem(int i, ItemStack itemstack, int j) {
+ return i!=2 && isItemValidForSlot(i, itemstack);
+ }
+ @Override
+ public boolean canExtractItem(int i, ItemStack itemstack, int j) {
+ return i==0 || i==2;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityForRender.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityForRender.class Binary files differnew file mode 100644 index 0000000..2485bb5 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityForRender.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityForRender.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityForRender.java new file mode 100644 index 0000000..e4571fa --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityForRender.java @@ -0,0 +1,19 @@ +package jp.plusplus.fbs.tileentity;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.block.BlockCore;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+
+/**
+ * Created by plusplus_F on 2015/09/25.
+ * 毎度おなじみレンダーのためだけのTE
+ */
+public class TileEntityForRender extends TileEntity {
+ @SideOnly(Side.CLIENT)
+ public AxisAlignedBB getRenderBoundingBox() {
+ if(getBlockType()== BlockCore.tableAlchemist) return AxisAlignedBB.getBoundingBox(xCoord-1,yCoord,zCoord-1,xCoord+2,yCoord+1,zCoord+2);
+ else return super.getRenderBoundingBox();
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestable.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestable.class Binary files differnew file mode 100644 index 0000000..bc5bef5 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestable.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestable.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestable.java new file mode 100644 index 0000000..622a75e --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestable.java @@ -0,0 +1,165 @@ +package jp.plusplus.fbs.tileentity;
+
+import jp.plusplus.fbs.Registry;
+import net.minecraft.block.BlockEndPortal;
+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.world.biome.BiomeGenBase;
+import net.minecraftforge.common.BiomeManager;
+
+import java.util.Random;
+
+/**
+ * Created by plusplus_F on 2015/11/09.
+ * 10秒ごとに1つ成長する
+ */
+public class TileEntityHavestable extends TileEntity {
+ public int glowingTicks;
+ public int age;
+ public int ageMax;
+ public int meta;
+
+ public TileEntityHavestable(){
+ ageMax=60;
+ }
+ public TileEntityHavestable(int ageMax, int meta){
+ this();
+ this.ageMax=ageMax;
+ this.meta=meta;
+ }
+ //---------------------------------------------------------------------------------------------------------
+ public boolean canGlow(){
+ if(age>=ageMax) return false;
+ BiomeGenBase bgb=worldObj.getBiomeGenForCoords(xCoord, zCoord);
+
+ boolean flag=false;
+ if(meta==0){
+ //ベースハーブはどこでも育つ
+ flag=true;
+ }
+ else if(meta==4){
+ //ソウルハーブは狭間なら育つ
+ flag=bgb==Registry.biomeCrack;
+ }
+ else if(meta==5){
+ //マンドレイクはy=32未満で育つ
+ flag=yCoord<32 && yCoord!=worldObj.getHeightValue(xCoord, zCoord);
+ }
+ else if(meta==6){
+ //ゴールドハーブはy=20未満で育つ
+ flag=yCoord<20 && yCoord!=worldObj.getHeightValue(xCoord, zCoord);
+ }
+ else if(meta==7){
+ //エンダーハーブはエンドなら育つ
+ flag=worldObj.provider.dimensionId==1;
+ }
+ else if(meta==8){
+ //エクスプローシブハーブはネザーなら育つ
+ flag=worldObj.provider.dimensionId==-1;
+ }
+ else{
+ //直射日光があたらなければ育つ
+ flag=yCoord!=worldObj.getHeightValue(xCoord, zCoord);
+
+ if(!flag){
+ switch (meta){
+ case 1:
+ //ブラッディハーブは温暖なら育つ
+ for(BiomeManager.BiomeEntry be : BiomeManager.getBiomes(BiomeManager.BiomeType.WARM)){
+ if(bgb==be.biome){
+ flag=true;
+ break;
+ }
+ }
+ break;
+
+ case 2:
+ //マナハーブは秋なら育つ
+ flag=bgb==Registry.biomeAutumn;
+ break;
+
+ case 3:
+ //スタミナハーブは砂漠なら育つ
+ flag=(bgb==BiomeGenBase.desert || bgb==BiomeGenBase.desertHills || bgb==BiomeGenBase.savanna || bgb==BiomeGenBase.savannaPlateau || bgb==BiomeGenBase.mesa || bgb==BiomeGenBase.mesaPlateau|| bgb==BiomeGenBase.mesaPlateau_F);
+ if(!flag){
+ for(BiomeManager.BiomeEntry be : BiomeManager.getBiomes(BiomeManager.BiomeType.DESERT)){
+ if(bgb==be.biome){
+ flag=true;
+ break;
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ }
+
+ return flag;
+ }
+ public boolean canHarvest(){
+ return age>=ageMax;
+ }
+ public void glow(Random rand){
+ age+=1+rand.nextInt(3);
+ }
+ public void onHarvest(){
+ age=0;
+ markDirty();
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ }
+ //---------------------------------------------------------------------------------------------------------
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound){
+ super.readFromNBT(par1NBTTagCompound);
+
+ age=par1NBTTagCompound.getInteger("Age");
+ ageMax=par1NBTTagCompound.getInteger("AgeMax");
+ glowingTicks=par1NBTTagCompound.getInteger("GlowingTicks");
+ meta=par1NBTTagCompound.getInteger("Meta");
+ }
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+
+ par1NBTTagCompound.setInteger("Age", age);
+ par1NBTTagCompound.setInteger("AgeMax", ageMax);
+ par1NBTTagCompound.setInteger("GlowingTicks", glowingTicks);
+ par1NBTTagCompound.setInteger("Meta", meta);
+ }
+
+ @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 updateEntity(){
+ if(!worldObj.isRemote) {
+ glowingTicks++;
+ if (glowingTicks >= 200) {
+ glowingTicks = 0;
+ if (canGlow()) {
+ age++;
+ if (age > ageMax) {
+ age = ageMax;
+ }
+ markDirty();
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableGrass.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableGrass.class Binary files differnew file mode 100644 index 0000000..0522a42 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableGrass.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableGrass.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableGrass.java new file mode 100644 index 0000000..ebb62fa --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableGrass.java @@ -0,0 +1,21 @@ +package jp.plusplus.fbs.tileentity;
+
+import net.minecraft.block.BlockSapling;
+
+/**
+ * Created by plusplus_F on 2016/02/23.
+ */
+public class TileEntityHavestableGrass extends TileEntityHavestable {
+ public TileEntityHavestableGrass(){
+
+ }
+ public TileEntityHavestableGrass(int ageMax, int meta) {
+ super(ageMax, meta);
+ }
+
+ @Override
+ public boolean canGlow(){
+ return worldObj.getBlockLightValue(xCoord, yCoord+1, zCoord)>=9;
+ //return worldObj.is;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableMushroom.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableMushroom.class Binary files differnew file mode 100644 index 0000000..2745afe --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableMushroom.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableMushroom.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableMushroom.java new file mode 100644 index 0000000..2b2c617 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityHavestableMushroom.java @@ -0,0 +1,18 @@ +package jp.plusplus.fbs.tileentity;
+
+/**
+ * Created by plusplus_F on 2016/02/23.
+ */
+public class TileEntityHavestableMushroom extends TileEntityHavestable {
+ public TileEntityHavestableMushroom(){
+
+ }
+ public TileEntityHavestableMushroom(int ageMax, int meta) {
+ super(ageMax, meta);
+ }
+
+ @Override
+ public boolean canGlow(){
+ return getBlockMetadata()==0 || worldObj.getBlockLightValue(xCoord, yCoord, zCoord)<=8;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMagicCore.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMagicCore.class Binary files differnew file mode 100644 index 0000000..3fd42e5 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMagicCore.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMagicCore.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMagicCore.java new file mode 100644 index 0000000..2b3b267 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMagicCore.java @@ -0,0 +1,134 @@ +package jp.plusplus.fbs.tileentity;
+
+import jp.plusplus.fbs.container.inventory.InventoryMagic;
+import jp.plusplus.fbs.entity.EntityButterfly;
+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 pluslus_F on 2015/06/17.
+ */
+public class TileEntityMagicCore extends TileEntity {
+ public int ticks;
+ protected String circleName="null";
+ protected int circleRadius;
+
+ public InventoryMagic inv;
+ public int progressMax;
+ public int progress;
+
+ public void setInventory(InventoryMagic inv){
+ this.inv=inv;
+ }
+ public void removeInventory(){
+ inv=null;
+ }
+
+ public void setProgressMax(int p){
+ progressMax=p;
+ markDirty();
+ }
+ public void resetProgress(){
+ progress=0;
+ progressMax=0;
+ markDirty();
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound){
+ super.readFromNBT(par1NBTTagCompound);
+
+ circleName=par1NBTTagCompound.getString("CircleName");
+ circleRadius= par1NBTTagCompound.getInteger("CircleRadius");
+
+ progress=par1NBTTagCompound.getInteger("Progress");
+ progressMax=par1NBTTagCompound.getInteger("ProgressMax");
+ }
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+
+ par1NBTTagCompound.setString("CircleName", circleName);
+ par1NBTTagCompound.setInteger("CircleRadius", circleRadius);
+
+ par1NBTTagCompound.setInteger("Progress", progress);
+ par1NBTTagCompound.setInteger("ProgressMax", progressMax);
+ }
+
+ @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 updateEntity() {
+ ticks++;
+
+ if(worldObj.isRemote) return;
+ if(inv!=null && progressMax>0){
+ progress++;
+ if(progress>=progressMax){
+ inv.work();
+ progress=0;
+ }
+ }
+
+ if (ticks % 60 != 0) return;
+
+ //checking magic
+ if (circleName.equals("null")) return;
+ int bx = xCoord - circleRadius, bz = zCoord - circleRadius;
+ int size = 2 * circleRadius + 1;
+ for (int i = 0; i < size; i++) {
+ for (int k = 0; k < size; k++) {
+ if (i == size / 2 && i == k) continue;
+ if (!worldObj.isAirBlock(bx + k, yCoord, bz + i) && worldObj.isBlockNormalCubeDefault(bx+k, yCoord, bz+i, false)) {
+ setMagicCircle("null", 1);
+ markDirty();
+ return;
+ }
+ }
+ }
+
+ /*
+ if(ticks%180!=0 || worldObj.rand.nextFloat()<=0.8f) return;
+ EntityButterfly eb=new EntityButterfly(worldObj, xCoord, yCoord+1, zCoord);
+ worldObj.spawnEntityInWorld(eb);
+ */
+ }
+
+ public void setMagicCircle(String name, int radius){
+ circleName=(name==null?"null":name);
+ circleRadius=radius;
+ markDirty();
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ }
+ public void clearCharms() {
+ if (circleName.equals("null")) return;
+ int bx = xCoord - circleRadius, bz = zCoord - circleRadius;
+ int size = 2 * circleRadius + 1;
+ for (int i = 0; i < size; i++) {
+ for (int k = 0; k < size; k++) {
+ if (i == size / 2 && i == k) continue;
+ worldObj.setBlockToAir(bx + k, yCoord, bz + i);
+ }
+ }
+ }
+
+ public String getCircleName(){
+ return circleName;
+ }
+ public int getCircleRadius(){
+ return circleRadius;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMirror.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMirror.class Binary files differnew file mode 100644 index 0000000..529e716 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMirror.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMirror.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMirror.java new file mode 100644 index 0000000..41e580a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityMirror.java @@ -0,0 +1,11 @@ +package jp.plusplus.fbs.tileentity;
+
+import net.minecraft.tileentity.TileEntity;
+
+/**
+ * Created by pluslus_F on 2015/06/24.
+ * MCE2ショップ、魔女の鏡
+ */
+public class TileEntityMirror extends TileEntity {
+
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityPortalWarp.class b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityPortalWarp.class Binary files differnew file mode 100644 index 0000000..beb4c2a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityPortalWarp.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/TileEntityPortalWarp.java b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityPortalWarp.java new file mode 100644 index 0000000..ba0852b --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/TileEntityPortalWarp.java @@ -0,0 +1,42 @@ +package jp.plusplus.fbs.tileentity;
+
+import jp.plusplus.fbs.exprop.FBSEntityProperties;
+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;
+
+/**
+ * Created by plusplus_F on 2015/10/28.
+ */
+public class TileEntityPortalWarp extends TileEntity {
+ public FBSEntityProperties.WarpPosition destination=new FBSEntityProperties.WarpPosition(1,0,0,0);
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound){
+ super.readFromNBT(par1NBTTagCompound);
+ destination=new FBSEntityProperties.WarpPosition(par1NBTTagCompound.getCompoundTag("Dest"));
+ }
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound){
+ super.writeToNBT(par1NBTTagCompound);
+ NBTTagCompound nbt=new NBTTagCompound();
+ destination.writeToNBT(nbt);
+ par1NBTTagCompound.setTag("Dest", nbt);
+ }
+
+ @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());
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/render/RenderExtractingFurnace.class b/src/main/java/jp/plusplus/fbs/tileentity/render/RenderExtractingFurnace.class Binary files differnew file mode 100644 index 0000000..15616b0 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/render/RenderExtractingFurnace.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/render/RenderExtractingFurnace.java b/src/main/java/jp/plusplus/fbs/tileentity/render/RenderExtractingFurnace.java new file mode 100644 index 0000000..e0057f4 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/render/RenderExtractingFurnace.java @@ -0,0 +1,15 @@ +package jp.plusplus.fbs.tileentity.render;
+
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+
+/**
+ * Createdby pluslus_Fon 2015/06/09.
+ */
+public class RenderExtractingFurnace extends TileEntitySpecialRenderer {
+ @Override
+ public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float p_147500_8_) {
+
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/tileentity/render/RenderMagicCircle.class b/src/main/java/jp/plusplus/fbs/tileentity/render/RenderMagicCircle.class Binary files differnew file mode 100644 index 0000000..880e317 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/render/RenderMagicCircle.class diff --git a/src/main/java/jp/plusplus/fbs/tileentity/render/RenderMagicCircle.java b/src/main/java/jp/plusplus/fbs/tileentity/render/RenderMagicCircle.java new file mode 100644 index 0000000..1f662d4 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/tileentity/render/RenderMagicCircle.java @@ -0,0 +1,92 @@ +package jp.plusplus.fbs.tileentity.render;
+
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.ProxyClient;
+import jp.plusplus.fbs.tileentity.TileEntityMagicCore;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+
+import java.util.HashMap;
+
+/**
+ * Created by pluslus_F on 2015/06/18.
+ */
+public class RenderMagicCircle extends TileEntitySpecialRenderer {
+ private static HashMap<String, IIcon> icons=new HashMap<String, IIcon>();
+ public static RenderMagicCircle renderer;
+
+ public void renderTileEntityCupAt(TileEntityMagicCore par1Tile, double par2, double par4, double par6, float par8) {
+ this.setRotation(par1Tile, (float) par2, (float) par4, (float) par6);
+ }
+
+ public void setTileEntityRenderer(TileEntityRendererDispatcher par1TileEntityRenderer) {
+ super.func_147497_a(par1TileEntityRenderer);
+ renderer = this;
+ }
+
+ public void setRotation(TileEntityMagicCore par0Tile, float par1, float par2, float par3) {
+ //テセレータを使って、一枚の平面テクスチャとして表示させる。
+
+ Tessellator tessellator = Tessellator.instance;
+ String name = par0Tile.getCircleName();
+ float tick = FBS.proxy.getRenderPartialTicks();
+
+ if (!name.equals("null")) {
+ float r = par0Tile.getCircleRadius();
+
+ //コメントアウト部分を復帰させると、水面の描写が半透明になる。
+ GL11.glPushMatrix();
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glColor4f(2.0F, 2.0F, 2.0F, 0.75F);
+ GL11.glTranslatef((float) par1 + 0.5f, (float) par2, (float) par3 + 0.5f);
+ GL11.glRotatef(360.0f / 120.0f * ((par0Tile.ticks % 120) + tick), 0f, 1f, 0f);
+
+
+ IIcon iicon = GetMagicCircleIcon(name);
+ float f14 = iicon.getMinU();
+ float f15 = iicon.getMaxU();
+ float f4 = iicon.getMinV();
+ float f5 = iicon.getMaxV();
+
+ this.bindTexture(TextureMap.locationBlocksTexture);
+
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 1.0F, 0.0F);
+ tessellator.addVertexWithUV(-0.5f - r, 0.0625D, 0.5f + r, (double) f15, (double) f4);
+ tessellator.addVertexWithUV(0.5f + r, 0.0625D, 0.5f + r, (double) f14, (double) f4);
+ tessellator.addVertexWithUV(0.5f + r, 0.0625D, -0.5f - r, (double) f14, (double) f5);
+ tessellator.addVertexWithUV(-0.5f - r, 0.0625D, -0.5f - r, (double) f15, (double) f5);
+ tessellator.draw();
+
+
+ GL11.glDisable(GL12.GL_RESCALE_NORMAL);
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glPopMatrix();
+ }
+ }
+
+ public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) {
+ this.renderTileEntityCupAt((TileEntityMagicCore) par1TileEntity, par2, par4, par6, par8);
+ }
+
+ public static void ClearMagicCircleIcons(){
+ icons.clear();
+ }
+ public static void RegisterMagicCircleIcon(String name, TextureMap ir, String iconName){
+ if(icons.containsKey(name)) icons.remove(name);
+ icons.put(name, ir.registerIcon(iconName));
+ }
+ public static IIcon GetMagicCircleIcon(String name){
+ return icons.get(name);
+ }
+
+}
|
