OSDN Git Service

粉塵実装。デバッグよろしくお願いします
authormozipi <mozipi@users.sourceforge.jp>
Thu, 7 Mar 2013 10:29:59 +0000 (19:29 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Thu, 7 Mar 2013 10:29:59 +0000 (19:29 +0900)
common/pcc/chemicraft/ChemiCraft.java
common/pcc/chemicraft/client/ClientProxy.java
common/pcc/chemicraft/entity/EntityDust.java [new file with mode: 0644]
common/pcc/chemicraft/item/ItemDust.java [new file with mode: 0644]
common/pcc/chemicraft/render/RenderDust.java [new file with mode: 0644]
resources/pcc/chemicraft/entityParticles/dust.png [new file with mode: 0644]

index 130dd63..9a997ca 100644 (file)
@@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
 import net.minecraft.creativetab.CreativeTabs;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
+import net.minecraft.src.ModLoader;
 import net.minecraftforge.common.Configuration;
 import net.minecraftforge.common.Property;
 import net.minecraftforge.oredict.OreDictionary;
@@ -20,10 +21,12 @@ import pcc.chemicraft.creativetab.CreativeTabChemiCraft;
 import pcc.chemicraft.debug.CommandDeleteItem;
 import pcc.chemicraft.debug.CommandGenDebugRoom;
 import pcc.chemicraft.debug.CommandSetTile;
+import pcc.chemicraft.entity.EntityDust;
 import pcc.chemicraft.item.ItemAtoms;
 import pcc.chemicraft.item.ItemAtomsGrenade;
 import pcc.chemicraft.item.ItemChemiCell;
 import pcc.chemicraft.item.ItemCompounds;
+import pcc.chemicraft.item.ItemDust;
 import pcc.chemicraft.item.ItemGasCollectingBottle;
 import pcc.chemicraft.ore.BlockAtomOres;
 import pcc.chemicraft.ore.ItemAtomOres;
@@ -45,7 +48,9 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
 import cpw.mods.fml.common.event.FMLServerStartingEvent;
 import cpw.mods.fml.common.network.NetworkMod;
 import cpw.mods.fml.common.network.NetworkRegistry;
+import cpw.mods.fml.common.registry.EntityRegistry;
 import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.registry.LanguageRegistry;
 /**
  * ChemiCraft本体
  * @author P.C.C.
@@ -139,6 +144,7 @@ public class ChemiCraft implements Runnable {
        public Item itemGasCollectingBottle;
        public Item itemAtomGrenade;
        public Item itemChemicalCells;
+       public Item itemDust;
 
        /**
         * このmodで使用するTextureのパス.
@@ -155,6 +161,7 @@ public class ChemiCraft implements Runnable {
        public final String GUI_CHEMICALCOMBINATION_TEXTURE = "/pcc/chemicraft/guis/ChemicalCombination.png";
        public final String GUI_TOOLANDWEAPONCRAFTING_TEXTURE = "/pcc/chemicraft/guis/ToolAndWeaponCrafting.png";
        public final String GUI_CHEMICALCRAFTING_TEXTURE = "/pcc/chemicraft/guis/MaterialCrafting.png";
+       public final String ENTITY_PARTICLE_TEXRURE = "/pcc/chemicraft/entityParticles/dust.png";
 
        /**
         * このmodに必要な補助クラスのインスタンス.
@@ -312,6 +319,7 @@ public class ChemiCraft implements Runnable {
                this.itemGasCollectingBottle = new ItemGasCollectingBottle(this.gasCollectingBottleID).setItemName("gasCollectingBottle").setIconIndex(0);
                this.itemAtomGrenade = new ItemAtomsGrenade(this.atomGrenadeID).setItemName("grenade").setIconIndex(1);
                this.itemChemicalCells = new ItemChemiCell(this.chemicalCellsID).setItemName("chemiCell").setIconIndex(3);
+               this.itemDust = new ItemDust(15000).setItemName("dust").setIconIndex(12);
 
                // BlockをMinecraftに登録します
                GameRegistry.registerBlock(this.blockPyrolysisTable, "BlockPyrolysisTable");
@@ -339,6 +347,8 @@ public class ChemiCraft implements Runnable {
                this.nameAuxiliary.addName(this.itemGasCollectingBottle, "ja_JP", "集気瓶");
                this.nameAuxiliary.addName(this.itemAtomGrenade, "AtomGrenade");
                this.nameAuxiliary.addName(this.itemAtomGrenade, "ja_JP", "元素手榴弾");
+               this.nameAuxiliary.addName(this.itemDust, "dust");
+               this.nameAuxiliary.addName(this.itemDust, "ja_JP", "粉塵");
 
                // TileEntityを追加します
                GameRegistry.registerTileEntity(TileEntityPyrolysisTable.class, "TileEntityPyrolysisTable");
@@ -514,6 +524,21 @@ public class ChemiCraft implements Runnable {
                                        api.getAtomOresAmounts().get(api.getAtomOresName().getKeyList(i)));
                }
 
+               //Entityを追加
+               LanguageRegistry.instance().addStringLocalization("entity.Dust.name", "en_US", "Dust");
+               EntityRegistry.registerModEntity(EntityDust.class,
+                               "Dust",
+                               ModLoader.getUniqueEntityId(),
+                               this,
+                               250,
+                               5,
+                               true);
+               /*
+               EntityRegistry.registerGlobalEntityID(EntityDust.class,
+                               "Dust",
+                               ModLoader.getUniqueEntityId());
+                               */
+
                this.api.addPyrolysisDecompositionFuel(new ItemStack(Item.coal), 2000*8);
        }
 
index f2f2748..33f04d1 100644 (file)
@@ -1,5 +1,7 @@
 package pcc.chemicraft.client;
 
+import net.minecraft.client.particle.EffectRenderer;
+import net.minecraft.client.particle.EntityFX;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.tileentity.TileEntity;
 import net.minecraft.world.World;
@@ -8,12 +10,14 @@ import pcc.chemicraft.ChemiCraft;
 import pcc.chemicraft.container.ContainerElectrolysisTable;
 import pcc.chemicraft.debug.DebugTick;
 import pcc.chemicraft.entity.EntityAtomsGrenade;
+import pcc.chemicraft.entity.EntityDust;
 import pcc.chemicraft.gui.GuiChemicalCombinationTable;
 import pcc.chemicraft.gui.GuiChemicalCraftingTable;
 import pcc.chemicraft.gui.GuiElectrolysisTable;
 import pcc.chemicraft.gui.GuiPyrolysisTable;
 import pcc.chemicraft.gui.GuiToolAndWeaponCraftingTable;
 import pcc.chemicraft.render.RenderAtomsGrenade;
+import pcc.chemicraft.render.RenderDust;
 import pcc.chemicraft.system.CommonProxy;
 import pcc.chemicraft.tileentity.TileEntityChemicalCombinationTable;
 import pcc.chemicraft.tileentity.TileEntityChemicalCraftingTable;
@@ -22,6 +26,8 @@ import pcc.chemicraft.tileentity.TileEntityPyrolysisTable;
 import pcc.chemicraft.tileentity.TileEntityToolAndWeaponCraftingTable;
 import cpw.mods.fml.client.FMLClientHandler;
 import cpw.mods.fml.client.registry.RenderingRegistry;
+import cpw.mods.fml.common.registry.EntityRegistry;
+import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
 import cpw.mods.fml.common.registry.TickRegistry;
 import cpw.mods.fml.relauncher.Side;
 
@@ -39,7 +45,9 @@ public class ClientProxy extends CommonProxy {
                MinecraftForgeClient.preloadTexture(ChemiCraft.instance.GUI_CHEMICALCOMBINATION_TEXTURE);
                MinecraftForgeClient.preloadTexture(ChemiCraft.instance.GUI_CHEMICALCRAFTING_TEXTURE);
                MinecraftForgeClient.preloadTexture(ChemiCraft.instance.GUI_TOOLANDWEAPONCRAFTING_TEXTURE);
+               MinecraftForgeClient.preloadTexture(ChemiCraft.instance.ENTITY_PARTICLE_TEXRURE);
                RenderingRegistry.registerEntityRenderingHandler(EntityAtomsGrenade.class, new RenderAtomsGrenade(0.5F));
+               RenderingRegistry.registerEntityRenderingHandler(EntityDust.class, new RenderDust());
        }
 
 
diff --git a/common/pcc/chemicraft/entity/EntityDust.java b/common/pcc/chemicraft/entity/EntityDust.java
new file mode 100644 (file)
index 0000000..b92c7c5
--- /dev/null
@@ -0,0 +1,108 @@
+package pcc.chemicraft.entity;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.projectile.EntityThrowable;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+
+public class EntityDust extends Entity {
+
+       private final float explodeSize = 2.0F;
+       private final short explodeRad = 5;
+       private int delay = 0;
+       private int deadDelay = 20;
+       private float rad = 0;
+
+       public EntityDust(World par1World) {
+               super(par1World);
+       }
+
+       public EntityDust(World par1World, double par2, double par3, double par4) {
+               super(par1World);
+               this.posX = par2;
+               this.posY = par3;
+               this.posZ = par4;
+       }
+
+       @Override
+       public void onUpdate() {
+               super.onUpdate();
+               this.delay++;
+               if (this.delay > 100) {
+                       if (this.deadDelay > 0) {
+                               this.deadDelay--;
+                               this.rad += 0.5;
+                               if (this.deadDelay % 4 == 0) {
+                                       this.explode(this.rad);
+                               }
+                       } else {
+                               this.setDead();
+                       }
+               }
+
+        float var17 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
+        this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
+
+        for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)var17) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
+        {
+            ;
+        }
+
+        while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
+        {
+            this.prevRotationPitch += 360.0F;
+        }
+
+        while (this.rotationYaw - this.prevRotationYaw < -180.0F)
+        {
+            this.prevRotationYaw -= 360.0F;
+        }
+
+        while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
+        {
+            this.prevRotationYaw += 360.0F;
+        }
+
+        this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
+        this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
+
+       }
+
+       @Override
+       protected void entityInit() {
+
+       }
+
+       @Override
+       public void readEntityFromNBT(NBTTagCompound var1) {
+
+       }
+
+       @Override
+       public void writeEntityToNBT(NBTTagCompound var1) {
+
+       }
+
+       private void explode(double r) {
+               double angle = 0;
+               double angleY = 0;
+               for (int i = 0; i < r; i++) {
+                       double y = this.posY - (r/2) + (i * 1F);
+                       double ry = 0;
+                       for (int j = 1; j < r; j++) {
+                               ry = Math.sin((double) i / r * Math.PI) * 8;
+                               angle += 360/j;
+                               double x = this.posX - Math.sin(Math.toRadians(angle)) * ry;
+                               double z = this.posZ + Math.cos(Math.toRadians(angle)) * ry;
+                               this.worldObj.createExplosion(this, x - 6 + Math.random() * 12, y + 3, z - 6 + Math.random() * 12, this.explodeSize, false);
+                       }
+               }
+       }
+
+       public int getDelay() {
+               return this.delay;
+       }
+
+}
diff --git a/common/pcc/chemicraft/item/ItemDust.java b/common/pcc/chemicraft/item/ItemDust.java
new file mode 100644 (file)
index 0000000..6a0cd3b
--- /dev/null
@@ -0,0 +1,29 @@
+package pcc.chemicraft.item;
+
+import pcc.chemicraft.ChemiCraft;
+import pcc.chemicraft.entity.EntityDust;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+public class ItemDust extends Item {
+
+       public ItemDust(int par1) {
+               super(par1);
+               this.setCreativeTab(ChemiCraft.instance.creativeTabChemiCraft);
+       }
+
+       @Override
+       public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
+                       EntityPlayer par3EntityPlayer) {
+               par2World.spawnEntityInWorld(new EntityDust(par2World,
+                               par3EntityPlayer.posX,
+                               par3EntityPlayer.posY,
+                               par3EntityPlayer.posZ));
+               return par1ItemStack;
+       }
+
+       
+}
diff --git a/common/pcc/chemicraft/render/RenderDust.java b/common/pcc/chemicraft/render/RenderDust.java
new file mode 100644 (file)
index 0000000..7f62a9d
--- /dev/null
@@ -0,0 +1,46 @@
+package pcc.chemicraft.render;
+
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+
+import pcc.chemicraft.ChemiCraft;
+import pcc.chemicraft.entity.EntityDust;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.RenderEntity;
+import net.minecraft.entity.Entity;
+
+public class RenderDust extends RenderEntity {
+
+       @Override
+       public void doRender(Entity var1, double var2, double var4, double var6,
+                       float var8, float var9) {
+               EntityDust entity = (EntityDust) var1;
+               GL11.glPushMatrix();
+               GL11.glTranslatef((float)var2, (float)var4, (float)var6);
+               GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+               float var10 = entity.getDelay() / 8.0F;
+               GL11.glScalef(var10 / 1.0F, var10 / 1.0F, var10 / 1.0F);
+               byte var11 = 0;
+               this.loadTexture(ChemiCraft.instance.ENTITY_PARTICLE_TEXRURE);
+               Tessellator var12 = Tessellator.instance;
+               float var13 = (float)(var11 % 256 * 256 + 0) / 256F;
+               float var14 = (float)(var11 % 256 * 256 + 256) / 256F;
+               float var15 = (float)(var11 / 256 * 256 + 0) / 256F;
+               float var16 = (float)(var11 / 256 * 256 + 256) / 256F;
+               float var17 = 1.0F;
+               float var18 = 0.5F;
+               float var19 = 0.25F;
+               GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
+               GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
+               var12.startDrawingQuads();
+               var12.setNormal(0.0F, 1.0F, 0.0F);
+               var12.addVertexWithUV((double)(0.0F - var18), (double)(0.0F - var19), 0.0D, (double)var13, (double)var16);
+               var12.addVertexWithUV((double)(var17 - var18), (double)(0.0F - var19), 0.0D, (double)var14, (double)var16);
+               var12.addVertexWithUV((double)(var17 - var18), (double)(1.0F - var19), 0.0D, (double)var14, (double)var15);
+               var12.addVertexWithUV((double)(0.0F - var18), (double)(1.0F - var19), 0.0D, (double)var13, (double)var15);
+               var12.draw();
+               GL11.glDisable(GL12.GL_RESCALE_NORMAL);
+               GL11.glPopMatrix();
+       }
+
+}
diff --git a/resources/pcc/chemicraft/entityParticles/dust.png b/resources/pcc/chemicraft/entityParticles/dust.png
new file mode 100644 (file)
index 0000000..58404a8
Binary files /dev/null and b/resources/pcc/chemicraft/entityParticles/dust.png differ