Revisión | ad066e3e28b95c1173af6cd31fc9ab0db1655d2c (tree) |
---|---|
Tiempo | 2013-03-07 19:40:19 |
Autor | mozipi <mozipi@user...> |
Commiter | mozipi |
くるったのでtc
@@ -5,6 +5,7 @@ import net.minecraft.block.material.Material; | ||
5 | 5 | import net.minecraft.creativetab.CreativeTabs; |
6 | 6 | import net.minecraft.item.Item; |
7 | 7 | import net.minecraft.item.ItemStack; |
8 | +import net.minecraft.src.ModLoader; | |
8 | 9 | import net.minecraftforge.common.Configuration; |
9 | 10 | import net.minecraftforge.common.Property; |
10 | 11 | import net.minecraftforge.oredict.OreDictionary; |
@@ -20,10 +21,12 @@ import pcc.chemicraft.creativetab.CreativeTabChemiCraft; | ||
20 | 21 | import pcc.chemicraft.debug.CommandDeleteItem; |
21 | 22 | import pcc.chemicraft.debug.CommandGenDebugRoom; |
22 | 23 | import pcc.chemicraft.debug.CommandSetTile; |
24 | +import pcc.chemicraft.entity.EntityDust; | |
23 | 25 | import pcc.chemicraft.item.ItemAtoms; |
24 | 26 | import pcc.chemicraft.item.ItemAtomsGrenade; |
25 | 27 | import pcc.chemicraft.item.ItemChemiCell; |
26 | 28 | import pcc.chemicraft.item.ItemCompounds; |
29 | +import pcc.chemicraft.item.ItemDust; | |
27 | 30 | import pcc.chemicraft.item.ItemGasCollectingBottle; |
28 | 31 | import pcc.chemicraft.ore.BlockAtomOres; |
29 | 32 | import pcc.chemicraft.ore.ItemAtomOres; |
@@ -45,7 +48,9 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; | ||
45 | 48 | import cpw.mods.fml.common.event.FMLServerStartingEvent; |
46 | 49 | import cpw.mods.fml.common.network.NetworkMod; |
47 | 50 | import cpw.mods.fml.common.network.NetworkRegistry; |
51 | +import cpw.mods.fml.common.registry.EntityRegistry; | |
48 | 52 | import cpw.mods.fml.common.registry.GameRegistry; |
53 | +import cpw.mods.fml.common.registry.LanguageRegistry; | |
49 | 54 | /** |
50 | 55 | * ChemiCraft本体 |
51 | 56 | * @author P.C.C. |
@@ -139,6 +144,7 @@ public class ChemiCraft implements Runnable { | ||
139 | 144 | public Item itemGasCollectingBottle; |
140 | 145 | public Item itemAtomGrenade; |
141 | 146 | public Item itemChemicalCells; |
147 | + public Item itemDust; | |
142 | 148 | |
143 | 149 | /** |
144 | 150 | * このmodで使用するTextureのパス. |
@@ -155,6 +161,7 @@ public class ChemiCraft implements Runnable { | ||
155 | 161 | public final String GUI_CHEMICALCOMBINATION_TEXTURE = "/pcc/chemicraft/guis/ChemicalCombination.png"; |
156 | 162 | public final String GUI_TOOLANDWEAPONCRAFTING_TEXTURE = "/pcc/chemicraft/guis/ToolAndWeaponCrafting.png"; |
157 | 163 | public final String GUI_CHEMICALCRAFTING_TEXTURE = "/pcc/chemicraft/guis/MaterialCrafting.png"; |
164 | + public final String ENTITY_PARTICLE_TEXRURE = "/pcc/chemicraft/entityParticles/dust.png"; | |
158 | 165 | |
159 | 166 | /** |
160 | 167 | * このmodに必要な補助クラスのインスタンス. |
@@ -312,6 +319,7 @@ public class ChemiCraft implements Runnable { | ||
312 | 319 | this.itemGasCollectingBottle = new ItemGasCollectingBottle(this.gasCollectingBottleID).setItemName("gasCollectingBottle").setIconIndex(0); |
313 | 320 | this.itemAtomGrenade = new ItemAtomsGrenade(this.atomGrenadeID).setItemName("grenade").setIconIndex(1); |
314 | 321 | this.itemChemicalCells = new ItemChemiCell(this.chemicalCellsID).setItemName("chemiCell").setIconIndex(3); |
322 | + this.itemDust = new ItemDust(15000).setItemName("dust").setIconIndex(12); | |
315 | 323 | |
316 | 324 | // BlockをMinecraftに登録します |
317 | 325 | GameRegistry.registerBlock(this.blockPyrolysisTable, "BlockPyrolysisTable"); |
@@ -339,6 +347,8 @@ public class ChemiCraft implements Runnable { | ||
339 | 347 | this.nameAuxiliary.addName(this.itemGasCollectingBottle, "ja_JP", "集気瓶"); |
340 | 348 | this.nameAuxiliary.addName(this.itemAtomGrenade, "AtomGrenade"); |
341 | 349 | this.nameAuxiliary.addName(this.itemAtomGrenade, "ja_JP", "元素手榴弾"); |
350 | + this.nameAuxiliary.addName(this.itemDust, "dust"); | |
351 | + this.nameAuxiliary.addName(this.itemDust, "ja_JP", "粉塵"); | |
342 | 352 | |
343 | 353 | // TileEntityを追加します |
344 | 354 | GameRegistry.registerTileEntity(TileEntityPyrolysisTable.class, "TileEntityPyrolysisTable"); |
@@ -514,6 +524,21 @@ public class ChemiCraft implements Runnable { | ||
514 | 524 | api.getAtomOresAmounts().get(api.getAtomOresName().getKeyList(i))); |
515 | 525 | } |
516 | 526 | |
527 | + //Entityを追加 | |
528 | + LanguageRegistry.instance().addStringLocalization("entity.Dust.name", "en_US", "Dust"); | |
529 | + EntityRegistry.registerModEntity(EntityDust.class, | |
530 | + "Dust", | |
531 | + ModLoader.getUniqueEntityId(), | |
532 | + this, | |
533 | + 250, | |
534 | + 5, | |
535 | + true); | |
536 | + /* | |
537 | + EntityRegistry.registerGlobalEntityID(EntityDust.class, | |
538 | + "Dust", | |
539 | + ModLoader.getUniqueEntityId()); | |
540 | + */ | |
541 | + | |
517 | 542 | this.api.addPyrolysisDecompositionFuel(new ItemStack(Item.coal), 2000*8); |
518 | 543 | } |
519 | 544 |
@@ -1,5 +1,7 @@ | ||
1 | 1 | package pcc.chemicraft.client; |
2 | 2 | |
3 | +import net.minecraft.client.particle.EffectRenderer; | |
4 | +import net.minecraft.client.particle.EntityFX; | |
3 | 5 | import net.minecraft.entity.player.EntityPlayer; |
4 | 6 | import net.minecraft.tileentity.TileEntity; |
5 | 7 | import net.minecraft.world.World; |
@@ -8,12 +10,14 @@ import pcc.chemicraft.ChemiCraft; | ||
8 | 10 | import pcc.chemicraft.container.ContainerElectrolysisTable; |
9 | 11 | import pcc.chemicraft.debug.DebugTick; |
10 | 12 | import pcc.chemicraft.entity.EntityAtomsGrenade; |
13 | +import pcc.chemicraft.entity.EntityDust; | |
11 | 14 | import pcc.chemicraft.gui.GuiChemicalCombinationTable; |
12 | 15 | import pcc.chemicraft.gui.GuiChemicalCraftingTable; |
13 | 16 | import pcc.chemicraft.gui.GuiElectrolysisTable; |
14 | 17 | import pcc.chemicraft.gui.GuiPyrolysisTable; |
15 | 18 | import pcc.chemicraft.gui.GuiToolAndWeaponCraftingTable; |
16 | 19 | import pcc.chemicraft.render.RenderAtomsGrenade; |
20 | +import pcc.chemicraft.render.RenderDust; | |
17 | 21 | import pcc.chemicraft.system.CommonProxy; |
18 | 22 | import pcc.chemicraft.tileentity.TileEntityChemicalCombinationTable; |
19 | 23 | import pcc.chemicraft.tileentity.TileEntityChemicalCraftingTable; |
@@ -22,6 +26,8 @@ import pcc.chemicraft.tileentity.TileEntityPyrolysisTable; | ||
22 | 26 | import pcc.chemicraft.tileentity.TileEntityToolAndWeaponCraftingTable; |
23 | 27 | import cpw.mods.fml.client.FMLClientHandler; |
24 | 28 | import cpw.mods.fml.client.registry.RenderingRegistry; |
29 | +import cpw.mods.fml.common.registry.EntityRegistry; | |
30 | +import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; | |
25 | 31 | import cpw.mods.fml.common.registry.TickRegistry; |
26 | 32 | import cpw.mods.fml.relauncher.Side; |
27 | 33 |
@@ -39,7 +45,9 @@ public class ClientProxy extends CommonProxy { | ||
39 | 45 | MinecraftForgeClient.preloadTexture(ChemiCraft.instance.GUI_CHEMICALCOMBINATION_TEXTURE); |
40 | 46 | MinecraftForgeClient.preloadTexture(ChemiCraft.instance.GUI_CHEMICALCRAFTING_TEXTURE); |
41 | 47 | MinecraftForgeClient.preloadTexture(ChemiCraft.instance.GUI_TOOLANDWEAPONCRAFTING_TEXTURE); |
48 | + MinecraftForgeClient.preloadTexture(ChemiCraft.instance.ENTITY_PARTICLE_TEXRURE); | |
42 | 49 | RenderingRegistry.registerEntityRenderingHandler(EntityAtomsGrenade.class, new RenderAtomsGrenade(0.5F)); |
50 | + RenderingRegistry.registerEntityRenderingHandler(EntityDust.class, new RenderDust()); | |
43 | 51 | } |
44 | 52 | |
45 | 53 |
@@ -0,0 +1,108 @@ | ||
1 | +package pcc.chemicraft.entity; | |
2 | + | |
3 | +import net.minecraft.entity.Entity; | |
4 | +import net.minecraft.entity.projectile.EntityThrowable; | |
5 | +import net.minecraft.nbt.NBTTagCompound; | |
6 | +import net.minecraft.util.MathHelper; | |
7 | +import net.minecraft.util.MovingObjectPosition; | |
8 | +import net.minecraft.world.World; | |
9 | + | |
10 | +public class EntityDust extends Entity { | |
11 | + | |
12 | + private final float explodeSize = 2.0F; | |
13 | + private final short explodeRad = 5; | |
14 | + private int delay = 0; | |
15 | + private int deadDelay = 20; | |
16 | + private float rad = 0; | |
17 | + | |
18 | + public EntityDust(World par1World) { | |
19 | + super(par1World); | |
20 | + } | |
21 | + | |
22 | + public EntityDust(World par1World, double par2, double par3, double par4) { | |
23 | + super(par1World); | |
24 | + this.posX = par2; | |
25 | + this.posY = par3; | |
26 | + this.posZ = par4; | |
27 | + } | |
28 | + | |
29 | + @Override | |
30 | + public void onUpdate() { | |
31 | + super.onUpdate(); | |
32 | + this.delay++; | |
33 | + if (this.delay > 100) { | |
34 | + if (this.deadDelay > 0) { | |
35 | + this.deadDelay--; | |
36 | + this.rad += 0.5; | |
37 | + if (this.deadDelay % 4 == 0) { | |
38 | + this.explode(this.rad); | |
39 | + } | |
40 | + } else { | |
41 | + this.setDead(); | |
42 | + } | |
43 | + } | |
44 | + | |
45 | + float var17 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); | |
46 | + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); | |
47 | + | |
48 | + for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)var17) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) | |
49 | + { | |
50 | + ; | |
51 | + } | |
52 | + | |
53 | + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) | |
54 | + { | |
55 | + this.prevRotationPitch += 360.0F; | |
56 | + } | |
57 | + | |
58 | + while (this.rotationYaw - this.prevRotationYaw < -180.0F) | |
59 | + { | |
60 | + this.prevRotationYaw -= 360.0F; | |
61 | + } | |
62 | + | |
63 | + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) | |
64 | + { | |
65 | + this.prevRotationYaw += 360.0F; | |
66 | + } | |
67 | + | |
68 | + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; | |
69 | + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; | |
70 | + | |
71 | + } | |
72 | + | |
73 | + @Override | |
74 | + protected void entityInit() { | |
75 | + | |
76 | + } | |
77 | + | |
78 | + @Override | |
79 | + public void readEntityFromNBT(NBTTagCompound var1) { | |
80 | + | |
81 | + } | |
82 | + | |
83 | + @Override | |
84 | + public void writeEntityToNBT(NBTTagCompound var1) { | |
85 | + | |
86 | + } | |
87 | + | |
88 | + private void explode(double r) { | |
89 | + double angle = 0; | |
90 | + double angleY = 0; | |
91 | + for (int i = 0; i < r; i++) { | |
92 | + double y = this.posY - (r/2) + (i * 1F); | |
93 | + double ry = 0; | |
94 | + for (int j = 1; j < r; j++) { | |
95 | + ry = Math.sin((double) i / r * Math.PI) * 8; | |
96 | + angle += 360/j; | |
97 | + double x = this.posX - Math.sin(Math.toRadians(angle)) * ry; | |
98 | + double z = this.posZ + Math.cos(Math.toRadians(angle)) * ry; | |
99 | + this.worldObj.createExplosion(this, x - 6 + Math.random() * 12, y + 3, z - 6 + Math.random() * 12, this.explodeSize, false); | |
100 | + } | |
101 | + } | |
102 | + } | |
103 | + | |
104 | + public int getDelay() { | |
105 | + return this.delay; | |
106 | + } | |
107 | + | |
108 | +} |
@@ -0,0 +1,29 @@ | ||
1 | +package pcc.chemicraft.item; | |
2 | + | |
3 | +import pcc.chemicraft.ChemiCraft; | |
4 | +import pcc.chemicraft.entity.EntityDust; | |
5 | +import net.minecraft.creativetab.CreativeTabs; | |
6 | +import net.minecraft.entity.player.EntityPlayer; | |
7 | +import net.minecraft.item.Item; | |
8 | +import net.minecraft.item.ItemStack; | |
9 | +import net.minecraft.world.World; | |
10 | + | |
11 | +public class ItemDust extends Item { | |
12 | + | |
13 | + public ItemDust(int par1) { | |
14 | + super(par1); | |
15 | + this.setCreativeTab(ChemiCraft.instance.creativeTabChemiCraft); | |
16 | + } | |
17 | + | |
18 | + @Override | |
19 | + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, | |
20 | + EntityPlayer par3EntityPlayer) { | |
21 | + par2World.spawnEntityInWorld(new EntityDust(par2World, | |
22 | + par3EntityPlayer.posX, | |
23 | + par3EntityPlayer.posY, | |
24 | + par3EntityPlayer.posZ)); | |
25 | + return par1ItemStack; | |
26 | + } | |
27 | + | |
28 | + | |
29 | +} |
@@ -0,0 +1,46 @@ | ||
1 | +package pcc.chemicraft.render; | |
2 | + | |
3 | +import org.lwjgl.opengl.GL11; | |
4 | +import org.lwjgl.opengl.GL12; | |
5 | + | |
6 | +import pcc.chemicraft.ChemiCraft; | |
7 | +import pcc.chemicraft.entity.EntityDust; | |
8 | +import net.minecraft.client.renderer.Tessellator; | |
9 | +import net.minecraft.client.renderer.entity.RenderEntity; | |
10 | +import net.minecraft.entity.Entity; | |
11 | + | |
12 | +public class RenderDust extends RenderEntity { | |
13 | + | |
14 | + @Override | |
15 | + public void doRender(Entity var1, double var2, double var4, double var6, | |
16 | + float var8, float var9) { | |
17 | + EntityDust entity = (EntityDust) var1; | |
18 | + GL11.glPushMatrix(); | |
19 | + GL11.glTranslatef((float)var2, (float)var4, (float)var6); | |
20 | + GL11.glEnable(GL12.GL_RESCALE_NORMAL); | |
21 | + float var10 = entity.getDelay() / 8.0F; | |
22 | + GL11.glScalef(var10 / 1.0F, var10 / 1.0F, var10 / 1.0F); | |
23 | + byte var11 = 0; | |
24 | + this.loadTexture(ChemiCraft.instance.ENTITY_PARTICLE_TEXRURE); | |
25 | + Tessellator var12 = Tessellator.instance; | |
26 | + float var13 = (float)(var11 % 256 * 256 + 0) / 256F; | |
27 | + float var14 = (float)(var11 % 256 * 256 + 256) / 256F; | |
28 | + float var15 = (float)(var11 / 256 * 256 + 0) / 256F; | |
29 | + float var16 = (float)(var11 / 256 * 256 + 256) / 256F; | |
30 | + float var17 = 1.0F; | |
31 | + float var18 = 0.5F; | |
32 | + float var19 = 0.25F; | |
33 | + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); | |
34 | + GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); | |
35 | + var12.startDrawingQuads(); | |
36 | + var12.setNormal(0.0F, 1.0F, 0.0F); | |
37 | + var12.addVertexWithUV((double)(0.0F - var18), (double)(0.0F - var19), 0.0D, (double)var13, (double)var16); | |
38 | + var12.addVertexWithUV((double)(var17 - var18), (double)(0.0F - var19), 0.0D, (double)var14, (double)var16); | |
39 | + var12.addVertexWithUV((double)(var17 - var18), (double)(1.0F - var19), 0.0D, (double)var14, (double)var15); | |
40 | + var12.addVertexWithUV((double)(0.0F - var18), (double)(1.0F - var19), 0.0D, (double)var13, (double)var15); | |
41 | + var12.draw(); | |
42 | + GL11.glDisable(GL12.GL_RESCALE_NORMAL); | |
43 | + GL11.glPopMatrix(); | |
44 | + } | |
45 | + | |
46 | +} |