Cleaned up some more, fixed infinite loop with cancelable annotation, Client now compiles and enters world just fine.

This commit is contained in:
LexManos 2012-08-09 16:47:35 -07:00
parent ba9e3a251c
commit f31b8a98a9
23 changed files with 230 additions and 189 deletions

View File

@ -0,0 +1,15 @@
package net.minecraftforge.client.event.sound;
import net.minecraft.src.SoundManager;
import net.minecraft.src.SoundPoolEntry;
/**
* Raised when the SoundManager tries to play a Background Music file,
* If you return null from this function it will prevent the sound from being played,
* you can return a different entry if you want to change the sound being played.
*/
public class PlayBackgroundMusicEvent extends SoundResultEvent
{
public PlayBackgroundMusicEvent(SoundManager manager, SoundPoolEntry entry)
{ super(manager, entry, null, 0.0f, 0.0f); }
}

View File

@ -0,0 +1,21 @@
package net.minecraftforge.client.event.sound;
import net.minecraft.src.Entity;
import net.minecraftforge.event.Cancelable;
@Cancelable
public class PlaySoundAtEntityEvent extends SoundEvent
{
public final Entity entity;
public String name;
public final float volume;
public final float pitch;
public PlaySoundAtEntityEvent(Entity entity, String name, float volume, float pitch)
{
this.entity = entity;
this.name = name;
this.volume = volume;
this.pitch = pitch;
}
}

View File

@ -0,0 +1,10 @@
package net.minecraftforge.client.event.sound;
import net.minecraft.src.SoundManager;
import net.minecraft.src.SoundPoolEntry;
public class PlaySoundEffectEvent extends SoundResultEvent
{
public PlaySoundEffectEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch)
{ super(manager, source, name, volume, pitch); }
}

View File

@ -0,0 +1,25 @@
package net.minecraftforge.client.event.sound;
import net.minecraft.src.SoundManager;
import net.minecraft.src.SoundPoolEntry;
/***
* Raised when the SoundManager tries to play a normal sound,
* dogs barking, footsteps, etc. THe majority of all sounds during normal game play.
*
* If you return null from this function it will prevent the sound from being played,
* you can return a different entry if you want to change the sound being played.
*/
public class PlaySoundEvent extends SoundResultEvent
{
public final float x;
public final float y;
public final float z;
public PlaySoundEvent(SoundManager manager, SoundPoolEntry source, String name, float x, float y, float z, float volume, float pitch)
{
super(manager, source, name, volume, pitch);
this.x = x;
this.y = y;
this.z = z;
}
}

View File

@ -0,0 +1,26 @@
package net.minecraftforge.client.event.sound;
import net.minecraft.src.SoundManager;
import net.minecraft.src.SoundPoolEntry;
/**
* Raised when the SoundManager tries to play a 'Streaming' file,
* in vanilla it is only the Jukebox that uses this function.
*
* If you return null from this function it will prevent the sound from being played,
* you can return a different entry if you want to change the sound being played.
*
*/
public class PlayStreamingEvent extends SoundResultEvent
{
public final float x;
public final float y;
public final float z;
public PlayStreamingEvent(SoundManager manager, SoundPoolEntry source, String name, float x, float y, float z)
{
super(manager, source, name, 0.0f, 0.0f);
this.x = x;
this.y = y;
this.z = z;
}
}

View File

@ -16,127 +16,4 @@ public class SoundEvent extends Event
MinecraftForge.EVENT_BUS.post(event);
return event.result;
}
public static abstract class SoundResultEvent extends SoundEvent
{
public final SoundManager manager;
public final SoundPoolEntry source;
public final String name;
public final float volume;
public final float pitch;
public SoundPoolEntry result;
public SoundResultEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch)
{
this.manager = manager;
this.source = source;
this.name = name;
this.volume = volume;
this.pitch = pitch;
this.result = source;
}
}
/**
* Raised by the SoundManager.loadSoundSettings, this would be a good place for
* adding your custom sounds to the SoundPool.
*/
public static class SoundLoadEvent extends SoundEvent
{
public final SoundManager manager;
public SoundLoadEvent(SoundManager manager)
{
this.manager = manager;
}
}
/**
* This event is raised by the SoundManager when it does its first setup of the
* SoundSystemConfig's codecs, use this function to add your own codecs.
*/
public static class SoundSetupEvent extends SoundEvent
{
public final SoundManager manager;
public SoundSetupEvent(SoundManager manager)
{
this.manager = manager;
}
}
/**
* Raised when the SoundManager tries to play a Background Music file,
* If you return null from this function it will prevent the sound from being played,
* you can return a different entry if you want to change the sound being played.
*/
public static class PlayBackgroundMusicEvent extends SoundResultEvent
{
public PlayBackgroundMusicEvent(SoundManager manager, SoundPoolEntry entry)
{ super(manager, entry, null, 0.0f, 0.0f); }
}
/**
* Raised when the SoundManager tries to play a 'Streaming' file,
* in vanilla it is only the Jukebox that uses this function.
*
* If you return null from this function it will prevent the sound from being played,
* you can return a different entry if you want to change the sound being played.
*
*/
public static class PlayStreamingEvent extends SoundResultEvent
{
public final float x;
public final float y;
public final float z;
public PlayStreamingEvent(SoundManager manager, SoundPoolEntry source, String name, float x, float y, float z)
{
super(manager, source, name, 0.0f, 0.0f);
this.x = x;
this.y = y;
this.z = z;
}
}
/***
* Raised when the SoundManager tries to play a normal sound,
* dogs barking, footsteps, etc. THe majority of all sounds during normal game play.
*
* If you return null from this function it will prevent the sound from being played,
* you can return a different entry if you want to change the sound being played.
*/
public static class PlaySoundEvent extends SoundResultEvent
{
public final float x;
public final float y;
public final float z;
public PlaySoundEvent(SoundManager manager, SoundPoolEntry source, String name, float x, float y, float z, float volume, float pitch)
{
super(manager, source, name, volume, pitch);
this.x = x;
this.y = y;
this.z = z;
}
}
public static class PlaySoundEffectEvent extends SoundResultEvent
{
public PlaySoundEffectEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch)
{ super(manager, source, name, volume, pitch); }
}
@Cancelable
public static class PlaySoundAtEntityEvent extends SoundEvent
{
public final Entity entity;
public String name;
public final float volume;
public final float pitch;
public PlaySoundAtEntityEvent(Entity entity, String name, float volume, float pitch)
{
this.entity = entity;
this.name = name;
this.volume = volume;
this.pitch = pitch;
}
}
}

View File

@ -0,0 +1,16 @@
package net.minecraftforge.client.event.sound;
import net.minecraft.src.SoundManager;
/**
* Raised by the SoundManager.loadSoundSettings, this would be a good place for
* adding your custom sounds to the SoundPool.
*/
public class SoundLoadEvent extends SoundEvent
{
public final SoundManager manager;
public SoundLoadEvent(SoundManager manager)
{
this.manager = manager;
}
}

View File

@ -0,0 +1,24 @@
package net.minecraftforge.client.event.sound;
import net.minecraft.src.SoundManager;
import net.minecraft.src.SoundPoolEntry;
public abstract class SoundResultEvent extends SoundEvent
{
public final SoundManager manager;
public final SoundPoolEntry source;
public final String name;
public final float volume;
public final float pitch;
public SoundPoolEntry result;
public SoundResultEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch)
{
this.manager = manager;
this.source = source;
this.name = name;
this.volume = volume;
this.pitch = pitch;
this.result = source;
}
}

View File

@ -0,0 +1,16 @@
package net.minecraftforge.client.event.sound;
import net.minecraft.src.SoundManager;
/**
* This event is raised by the SoundManager when it does its first setup of the
* SoundSystemConfig's codecs, use this function to add your own codecs.
*/
public class SoundSetupEvent extends SoundEvent
{
public final SoundManager manager;
public SoundSetupEvent(SoundManager manager)
{
this.manager = manager;
}
}

View File

@ -1,4 +1,4 @@
package net.minecraft.src.forge;
package net.minecraftforge.common;
import java.util.Hashtable;
import java.util.logging.Level;

View File

@ -22,6 +22,7 @@ public class Event
found = true;
break;
}
cls = cls.getSuperclass();
}
isCancelable = found;
}

View File

@ -21,33 +21,40 @@ public class EventTransformer implements IClassTransformer
@Override
public byte[] transform(String name, byte[] bytes)
{
{
if (name.equals("net.minecraftforge.event.Event") || name.startsWith("net.minecraft.src.") || name.indexOf('.') == -1)
{
return bytes;
}
ClassReader cr = new ClassReader(bytes);
ClassNode classNode = new ClassNode();
cr.accept(classNode, 0);
try
{
buildEvents(classNode);
if (buildEvents(classNode))
{
ClassWriter cw = new ClassWriter(COMPUTE_MAXS | COMPUTE_FRAMES);
classNode.accept(cw);
return cw.toByteArray();
}
return bytes;
}
catch (Exception e)
{
e.printStackTrace();
}
ClassWriter cw = new ClassWriter(COMPUTE_MAXS | COMPUTE_FRAMES);
classNode.accept(cw);
return cw.toByteArray();
return bytes;
}
@SuppressWarnings("unchecked")
private void buildEvents(ClassNode classNode) throws Exception
private boolean buildEvents(ClassNode classNode) throws Exception
{
Class<?> parent = Class.forName(classNode.superName.replace('/', '.'));
Class<?> parent = this.getClass().getClassLoader().loadClass(classNode.superName.replace('/', '.'));
if (!Event.class.isAssignableFrom(parent))
{
return;
return false;
}
boolean hasSetup = false;
@ -79,7 +86,7 @@ public class EventTransformer implements IClassTransformer
}
else
{
return;
return false;
}
}
@ -127,6 +134,7 @@ public class EventTransformer implements IClassTransformer
method.instructions.add(new FieldInsnNode(GETSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor()));
method.instructions.add(new InsnNode(ARETURN));
classNode.methods.add(method);
return true;
}
}

View File

@ -0,0 +1 @@
/*.launch

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Forge-Client/src/Start.java"/>
<listEntry value="/Forge-Client/src-client/Start.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
@ -20,7 +20,6 @@
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="Start"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Forge-Client"/>
<booleanAttribute key="org.eclipse.jdt.launching.STOP_IN_MAIN" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xincgc -Xmx1024M -Xms1024M"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:Forge-Client/jars}"/>
<booleanAttribute key="org.eclipse.tptp.platform.jvmti.client.ATTR_EXEC_AUTO_POLLING" value="true"/>

1
eclipse/Forge-Client/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/*.log

View File

@ -1,6 +1,6 @@
--- ../src_base/common/net/minecraft/src/Block.java
+++ ../src_work/common/net/minecraft/src/Block.java
@@ -2,8 +2,15 @@
@@ -2,11 +2,23 @@
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
@ -8,15 +8,23 @@
+import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+
+import net.minecraftforge.common.ForgeHooks;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.Orientation;
+import static net.minecraftforge.common.Orientation.*;
+
public class Block
{
@@ -279,6 +286,7 @@
+ protected static int[] blockFireSpreadSpeed = new int[4096];
+ protected static int[] blockFlammability = new int[4096];
+ protected String currentTexture = "/terrain.png";
+ public boolean isDefaultTexture = true;
+
/**
* used as foreach item, if item.tab = current tab, display it on the screen
*/
@@ -279,6 +291,7 @@
lightOpacity[par1] = this.isOpaqueCube() ? 255 : 0;
canBlockGrass[par1] = !par2Material.getCanBlockGrass();
}
@ -24,7 +32,7 @@
}
/**
@@ -417,9 +425,10 @@
@@ -417,9 +430,10 @@
return this.needsRandomTick;
}
@ -36,7 +44,7 @@
}
/**
@@ -442,7 +451,7 @@
@@ -442,7 +456,7 @@
*/
public float getBlockBrightness(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
@ -45,7 +53,7 @@
}
@SideOnly(Side.CLIENT)
@@ -452,7 +461,7 @@
@@ -452,7 +466,7 @@
*/
public int getMixedBrightnessForBlock(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
@ -54,7 +62,7 @@
}
@SideOnly(Side.CLIENT)
@@ -621,8 +630,7 @@
@@ -621,8 +635,7 @@
*/
public float getPlayerRelativeBlockHardness(EntityPlayer par1EntityPlayer, World par2World, int par3, int par4, int par5)
{
@ -64,7 +72,7 @@
}
/**
@@ -640,18 +648,13 @@
@@ -640,18 +653,13 @@
{
if (!par1World.isRemote)
{
@ -87,7 +95,7 @@
}
}
}
@@ -985,7 +988,7 @@
@@ -985,7 +993,7 @@
par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1);
par2EntityPlayer.addExhaustion(0.025F);
@ -96,17 +104,12 @@
{
ItemStack var8 = this.createStackedBlock(par6);
@@ -1249,4 +1252,650 @@
@@ -1249,4 +1257,645 @@
canBlockGrass[0] = true;
StatList.initBreakableStats();
}
+
+ /* =================================================== FORGE START =====================================*/
+ protected static int blockFireSpreadSpeed[] = new int[blocksList.length];
+ protected static int blockFlammability[] = new int[blocksList.length];
+ protected String currentTexture = "/terrain.png";
+ public boolean isDefaultTexture = true;
+
+ /* =================================================== FORGE START =====================================*/
+ /**
+ * Get a light value for this block, normal ranges are between 0 and 15
+ *

View File

@ -25,7 +25,7 @@
{
- int var13 = par1World.getBlockMetadata(par2 + var9, par3 + var10, par4 + var11);
- par1World.setBlockMetadata(par2 + var9, par3 + var10, par4 + var11, var13 | 8);
+ Block.blocksList[var10].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11);
+ Block.blocksList[var12].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11);
}
}
}

View File

@ -13,7 +13,7 @@
- {
- par1World.setBlockMetadata(par2 + var9, par3 + var10, par4 + var11, var13 | 8);
- }
+ Block.blocksList[var10].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11);
+ Block.blocksList[var12].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11);
}
}
}

View File

@ -15,20 +15,17 @@
public final class SpawnerAnimals
{
@@ -79,6 +84,12 @@
@@ -79,6 +84,9 @@
if ((!var34.getPeacefulCreature() || par2) && (var34.getPeacefulCreature() || par1) && par0WorldServer.countEntities(var34.getCreatureClass()) <= var34.getMaxNumberOfCreature() * eligibleChunksForSpawning.size() / 256)
{
Iterator var35 = eligibleChunksForSpawning.keySet().iterator();
+ if (mod_MinecraftForge.SPAWNER_MAKE_MORE_RANDOM)
+ {
+ ArrayList<ChunkCoordIntPair> tmp = new ArrayList(eligibleChunksForSpawning.keySet());
+ Collections.shuffle(tmp);
+ var35 = tmp.iterator();
+ }
+ ArrayList<ChunkCoordIntPair> tmp = new ArrayList(eligibleChunksForSpawning.keySet());
+ Collections.shuffle(tmp);
+ var35 = tmp.iterator();
label108:
while (var35.hasNext())
@@ -207,7 +218,8 @@
@@ -207,7 +215,8 @@
else
{
int var5 = par1World.getBlockId(par2, par3 - 1, par4);
@ -38,7 +35,7 @@
}
}
@@ -216,6 +228,13 @@
@@ -216,6 +225,13 @@
*/
private static void creatureSpecificInit(EntityLiving par0EntityLiving, World par1World, float par2, float par3, float par4)
{

View File

@ -4,7 +4,7 @@
import java.util.Random;
import java.util.Set;
+import net.minecraftforge.client.event.sound.SoundEvent.PlaySoundAtEntityEvent;
+import net.minecraftforge.client.event.sound.PlaySoundAtEntityEvent;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.Orientation;
+import net.minecraftforge.event.entity.EntityEvent;

View File

@ -1,6 +1,13 @@
--- ../src_base/common/net/minecraft/src/WorldProvider.java
+++ ../src_work/common/net/minecraft/src/WorldProvider.java
@@ -185,7 +185,7 @@
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraftforge.common.DimensionManager;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
@@ -185,7 +186,7 @@
public static WorldProvider getProviderForDimension(int par0)
{
@ -9,7 +16,7 @@
}
@SideOnly(Side.CLIENT)
@@ -249,4 +249,73 @@
@@ -249,4 +250,73 @@
{
return false;
}

View File

@ -54,14 +54,3 @@
}
}
@@ -1144,6 +1166,10 @@
if (par1Packet131MapData.itemID == Item.map.shiftedIndex)
{
ItemMap.getMPMapData(par1Packet131MapData.uniqueID, this.mc.theWorld).updateMPMapData(par1Packet131MapData.itemData);
+ }
+ else if (ForgeHooks.onItemDataPacket(netManager, par1Packet131MapData))
+ {
+ ;
}
else
{

View File

@ -1,20 +1,25 @@
--- ../src_base/minecraft/net/minecraft/src/SoundManager.java
+++ ../src_work/minecraft/net/minecraft/src/SoundManager.java
@@ -2,6 +2,13 @@
@@ -2,6 +2,18 @@
import java.io.File;
import java.util.Random;
+
+import net.minecraftforge.client.ForgeHooksClient;
+import net.minecraftforge.client.ModCompatibilityClient;
+import net.minecraftforge.client.event.sound.PlaySoundEffectEvent;
+import net.minecraftforge.client.event.sound.PlaySoundEvent;
+import net.minecraftforge.client.event.sound.PlayStreamingEvent;
+import net.minecraftforge.client.event.sound.SoundEvent;
+import net.minecraftforge.client.event.sound.SoundEvent.PlayBackgroundMusicEvent;
+import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent;
+import net.minecraftforge.client.event.sound.SoundLoadEvent;
+import net.minecraftforge.client.event.sound.SoundSetupEvent;
+import net.minecraftforge.common.MinecraftForge;
+import static net.minecraftforge.client.event.sound.SoundEvent.*;
import paulscode.sound.SoundSystem;
import paulscode.sound.SoundSystemConfig;
import paulscode.sound.codecs.CodecJOrbis;
@@ -37,9 +44,11 @@
@@ -37,9 +49,11 @@
private Random rand = new Random();
private int ticksBeforeMusic;
@ -27,7 +32,7 @@
}
/**
@@ -54,6 +63,8 @@
@@ -54,6 +68,8 @@
{
this.tryToSetLibraryAndCodecs();
}
@ -36,7 +41,7 @@
}
/**
@@ -73,6 +84,8 @@
@@ -73,6 +89,8 @@
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
SoundSystemConfig.setCodec("mus", CodecMus.class);
SoundSystemConfig.setCodec("wav", CodecWav.class);
@ -45,7 +50,7 @@
sndSystem = new SoundSystem();
this.options.soundVolume = var1;
this.options.musicVolume = var2;
@@ -161,10 +174,12 @@
@@ -161,10 +179,12 @@
}
SoundPoolEntry var1 = this.soundPoolMusic.getRandomSound();
@ -59,7 +64,7 @@
sndSystem.backgroundMusic("BgMusic", var1.soundUrl, var1.soundName, false);
sndSystem.setVolume("BgMusic", this.options.musicVolume);
sndSystem.play("BgMusic");
@@ -214,6 +229,7 @@
@@ -214,6 +234,7 @@
if (par1Str != null)
{
SoundPoolEntry var8 = this.soundPoolStreaming.getRandomSoundFromSoundPool(par1Str);
@ -67,7 +72,7 @@
if (var8 != null && par5 > 0.0F)
{
@@ -239,6 +255,7 @@
@@ -239,6 +260,7 @@
if (loaded && this.options.soundVolume != 0.0F)
{
SoundPoolEntry var7 = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str);
@ -75,7 +80,7 @@
if (var7 != null && par5 > 0.0F)
{
@@ -274,6 +291,7 @@
@@ -274,6 +296,7 @@
if (loaded && this.options.soundVolume != 0.0F)
{
SoundPoolEntry var4 = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str);