Plusieurs problèmes de mise à jour
-
Salut
J’ai commencer à mettre à jour mon mod pour la 1.9 et il y a beaucoup beaucoup d’erreur (j’ai peur pour la 1.10 :s , déjà qu’à la 1.8, beaucoup de trucs en changé)Y’en a tellement que je vais les numéroter et même faire des sous-parties pour certaines. (Je précise que j’ai réussi à en corriger pas mal, mais bon …). J’ai aussi 2-3 questions
- commandes
a) Dans la classe de commande, si on metjava @Override public boolean checkPermission(MinecraftServer server, ICommandSender sender) { // TODO Auto-generated method stub return false; }
à true, où met-on le degré de permission ? (comme par exemple en 1.8, ```java
public int getRequiredPermissionLevel()
{
return 2;
}
b) A quoi sert cette fonction ? : ```java @Override public List <string>getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) { // TODO Auto-generated method stub return null; } ```On est obligé de la mettre mais je ne la comprend pas, même en regardant dans les commandes de base 2) Création de mob a) registerGlobalEntityID et findGlobalUniqueEntityId sont barrées. D'après ce que j'ai compris, ils marchent toujours mais c'est déconseillé. Que utiliser à la place ? b) Dans ```java @SubscribeEvent public static int GetUniqueID() { int EntityID=300; do { EntityID++; } while(EntityList.getStringFromID(EntityID) != null); return EntityID; } ``` getStringFromID n'existe pas dans EntityList c) ```java public static void registerEntityEgg(Class entity, int primaryColour, int secondaryColour) { int id = GetUniqueID(); EntityList.idToClassMapping.put(id, entity); EntityList.entityEggs.put(id, new EntityEggInfo(id, primaryColour, secondaryColour)); } ``` Pour put, ça me propose de changer id en String, au lieu de int. Mais si je change, erreur sur GetUniqueID : ça me propose de changer la méthode en String, au lieu de int. Mais si je change, erreur sur le return. d) Dans la classe entity de mon boss, IBossDisplayData n'existe pas. 3) Dimension et teleporter/blockPortal a) ```java public BiomeGenEvilland(int i) { super(i); ... }
Le super me demande de changer le int en BiomeProperties. Mais si je fait ça, dans la classe principale (où je créer le biome), il me dise que le constructeur int n’est pas défini (ce qui est normal, je l’ai changer).
b) Dans la création du biome, setBiomeName n’existe pas.
c) ```java
DimensionManager.registerProviderType(this.DIMENSIONID, WorldProviderFrightful.class, false);
DimensionManager.registerDimension(DIMENSIONID, DIMENSIONID);Pour le provider, j'ai changé par : ```java DimensionManager.createProviderFor(DIMENSIONID); ``` C'est ça ? Pour la dimension, registerDimension demande en argument un int et un DimensionType (auparavent 2 int). d) dans le BlockPortal, ```java mcServer.getConfigurationManager().transferPlayerToDimension(player, ThisisHalloween.DIMENSIONID, new TeleporterFrightful(mcServer.worldServerForDimension(ThisisHalloween.DIMENSIONID))); ``` getConfigurationManager n'existe pas. e) Toujours dans le BlockPortal, ```java if (entity1 != null) { entity1.copyDataFromOld(entity); ``` copyDataFromOld est en private. f) Le WorldChunkManager de base n'existe plus (besoin pour être extend du WorldChunkManager custom) g) A quoi sert cette fonction ? : ```java @Override public DimensionType getDimensionType() { // TODO Auto-generated method stub return null; }
h) Dans ChunkProvider custom, ```java
package thisishalloween.world.frightful;import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS;
import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE;
import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE;
import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA;import java.util.List;
import java.util.Random;import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Blocks;
import net.minecraft.util.IProgressUpdate;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderSettings;
import net.minecraft.world.gen.NoiseGenerator;
import net.minecraft.world.gen.NoiseGeneratorOctaves;
import net.minecraft.world.gen.NoiseGeneratorPerlin;
import net.minecraft.world.gen.feature.WorldGenLakes;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.event.terraingen.TerrainGen;
import net.minecraftforge.fml.common.eventhandler.Event.Result;public class ChunkProviderFrightful implements IChunkProvider
{
/** RNG. */
private Random rand;
private NoiseGeneratorOctaves field_147431_j;
private NoiseGeneratorOctaves field_147432_k;
private NoiseGeneratorOctaves field_147429_l;
private NoiseGeneratorPerlin field_147430_m;
public NoiseGeneratorOctaves noiseGen5;
public NoiseGeneratorOctaves noiseGen6;
public NoiseGeneratorOctaves mobSpawnerNoise;
private World worldObj;
private final boolean mapFeaturesEnabled;
private WorldType field_177475_o;
private final double[] field_147434_q;
private final float[] parabolicField;
private ChunkProviderSettings settings;
private Block field_177476_s;
private double[] stoneNoise;
private BiomeGenBase[] biomesForGeneration;
double[] field_147427_d;
double[] field_147428_e;
double[] field_147425_f;
double[] field_147426_g;public ChunkProviderFrightful(World worldIn, long p_i45636_2_, boolean p_i45636_4_, String p_i45636_5_)
{
this.field_177476_s = Blocks.water;
this.stoneNoise = new double[256];
this.worldObj = worldIn;
this.mapFeaturesEnabled = p_i45636_4_;
this.field_177475_o = worldIn.getWorldInfo().getTerrainType();
this.rand = new Random(p_i45636_2_);
this.field_147431_j = new NoiseGeneratorOctaves(this.rand, 16);
this.field_147432_k = new NoiseGeneratorOctaves(this.rand, 16);
this.field_147429_l = new NoiseGeneratorOctaves(this.rand, 8);
this.field_147430_m = new NoiseGeneratorPerlin(this.rand, 4);
this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10);
this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16);
this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8);
this.field_147434_q = new double[825];
this.parabolicField = new float[25];for (int j = -2; j <= 2; ++j)
{
for (int k = -2; k <= 2; ++k)
{
float f = 10.0F / MathHelper.sqrt_float((float)(j * j + k * k) + 0.2F);
this.parabolicField[j + 2 + (k + 2) * 5] = f;
}
}if (p_i45636_5_ != null)
{
this.settings = ChunkProviderSettings.Factory.func_177865_a(p_i45636_5_).func_177864_b();
this.field_177476_s = this.settings.useLavaOceans ? Blocks.lava : Blocks.water;
}NoiseGenerator[] noiseGens = {field_147431_j, field_147432_k, field_147429_l, field_147430_m, noiseGen5, noiseGen6, mobSpawnerNoise};
noiseGens = TerrainGen.getModdedNoiseGenerators(worldIn, this.rand, noiseGens);
this.field_147431_j = (NoiseGeneratorOctaves)noiseGens[0];
this.field_147432_k = (NoiseGeneratorOctaves)noiseGens[1];
this.field_147429_l = (NoiseGeneratorOctaves)noiseGens[2];
this.field_147430_m = (NoiseGeneratorPerlin)noiseGens[3];
this.noiseGen5 = (NoiseGeneratorOctaves)noiseGens[4];
this.noiseGen6 = (NoiseGeneratorOctaves)noiseGens[5];
this.mobSpawnerNoise = (NoiseGeneratorOctaves)noiseGens[6];
}public void setBlocksInChunk(int p_180518_1_, int p_180518_2_, ChunkPrimer p_180518_3_)
{
this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, p_180518_1_ * 4 - 2, p_180518_2_ * 4 - 2, 10, 10);
this.func_147423_a(p_180518_1_ * 4, 0, p_180518_2_ * 4);for (int k = 0; k < 4; ++k)
{
int l = k * 5;
int i1 = (k + 1) * 5;for (int j1 = 0; j1 < 4; ++j1)
{
int k1 = (l + j1) * 33;
int l1 = (l + j1 + 1) * 33;
int i2 = (i1 + j1) * 33;
int j2 = (i1 + j1 + 1) * 33;for (int k2 = 0; k2 < 32; ++k2)
{
double d0 = 0.125D;
double d1 = this.field_147434_q[k1 + k2];
double d2 = this.field_147434_q[l1 + k2];
double d3 = this.field_147434_q[i2 + k2];
double d4 = this.field_147434_q[j2 + k2];
double d5 = (this.field_147434_q[k1 + k2 + 1] - d1) * d0;
double d6 = (this.field_147434_q[l1 + k2 + 1] - d2) * d0;
double d7 = (this.field_147434_q[i2 + k2 + 1] - d3) * d0;
double d8 = (this.field_147434_q[j2 + k2 + 1] - d4) * d0;for (int l2 = 0; l2 < 8; ++l2)
{
double d9 = 0.25D;
double d10 = d1;
double d11 = d2;
double d12 = (d3 - d1) * d9;
double d13 = (d4 - d2) * d9;for (int i3 = 0; i3 < 4; ++i3)
{
double d14 = 0.25D;
double d16 = (d11 - d10) * d14;
double d15 = d10 - d16;for (int j3 = 0; j3 < 4; ++j3)
{
if ((d15 += d16) > 0.0D)
{
p_180518_3_.setBlockState(k * 4 + i3, k2 * 8 + l2, j1 * 4 + j3, Blocks.stone.getDefaultState());
}
else if (k2 * 8 + l2 < this.settings.seaLevel)
{
p_180518_3_.setBlockState(k * 4 + i3, k2 * 8 + l2, j1 * 4 + j3, this.field_177476_s.getDefaultState());
}
}d10 += d12;
d11 += d13;
}d1 += d5;
d2 += d6;
d3 += d7;
d4 += d8;
}
}
}
}
}public void func_180517_a(int p_180517_1_, int p_180517_2_, ChunkPrimer p_180517_3_, BiomeGenBase[] p_180517_4_)
{
ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_180517_1_, p_180517_2_, p_180517_3_, this.worldObj);
MinecraftForge.EVENT_BUS.post(event);
if (event.getResult() == Result.DENY) return;double d0 = 0.03125D;
this.stoneNoise = this.field_147430_m.func_151599_a(this.stoneNoise, (double)(p_180517_1_ * 16), (double)(p_180517_2_ * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D);for (int k = 0; k < 16; ++k)
{
for (int l = 0; l < 16; ++l)
{
BiomeGenBase biomegenbase = p_180517_4_[l + k * 16];
biomegenbase.genTerrainBlocks(this.worldObj, this.rand, p_180517_3_, p_180517_1_ * 16 + k, p_180517_2_ * 16 + l, this.stoneNoise[l + k * 16]);
}
}
}/**
* Will return back a chunk, if it doesn’t exist and its not a MP client it will generates all the blocks for the
* specified chunk from the map seed and chunk seed
*/
public Chunk provideChunk(int x, int z)
{
this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
ChunkPrimer chunkprimer = new ChunkPrimer();
this.setBlocksInChunk(x, z, chunkprimer);
this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16);
this.func_180517_a(x, z, chunkprimer, this.biomesForGeneration);Chunk chunk = new Chunk(this.worldObj, chunkprimer, x, z);
byte[] abyte = chunk.getBiomeArray();for (int k = 0; k < abyte.length; ++k)
{
abyte[k] = (byte)this.biomesForGeneration[k].biomeID;
}chunk.generateSkylightMap();
return chunk;
}private void func_147423_a(int p_147423_1_, int p_147423_2_, int p_147423_3_)
{
this.field_147426_g = this.noiseGen6.generateNoiseOctaves(this.field_147426_g, p_147423_1_, p_147423_3_, 5, 5, (double)this.settings.depthNoiseScaleX, (double)this.settings.depthNoiseScaleZ, (double)this.settings.depthNoiseScaleExponent);
float f = this.settings.coordinateScale;
float f1 = this.settings.heightScale;
this.field_147427_d = this.field_147429_l.generateNoiseOctaves(this.field_147427_d, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, (double)(f / this.settings.mainNoiseScaleX), (double)(f1 / this.settings.mainNoiseScaleY), (double)(f / this.settings.mainNoiseScaleZ));
this.field_147428_e = this.field_147431_j.generateNoiseOctaves(this.field_147428_e, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, (double)f, (double)f1, (double)f);
this.field_147425_f = this.field_147432_k.generateNoiseOctaves(this.field_147425_f, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, (double)f, (double)f1, (double)f);
boolean flag1 = false;
boolean flag = false;
int l = 0;
int i1 = 0;for (int j1 = 0; j1 < 5; ++j1)
{
for (int k1 = 0; k1 < 5; ++k1)
{
float f2 = 0.0F;
float f3 = 0.0F;
float f4 = 0.0F;
byte b0 = 2;
BiomeGenBase biomegenbase = this.biomesForGeneration[j1 + 2 + (k1 + 2) * 10];for (int l1 = -b0; l1 <= b0; ++l1)
{
for (int i2 = -b0; i2 <= b0; ++i2)
{
BiomeGenBase biomegenbase1 = this.biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10];
float f5 = this.settings.biomeDepthOffSet + biomegenbase1.minHeight * this.settings.biomeDepthWeight;
float f6 = this.settings.biomeScaleOffset + biomegenbase1.maxHeight * this.settings.biomeScaleWeight;float f7 = this.parabolicField[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F);
if (biomegenbase1.minHeight > biomegenbase.minHeight)
{
f7 /= 2.0F;
}f2 += f6 * f7;
f3 += f5 * f7;
f4 += f7;
}
}f2 /= f4;
f3 /= f4;
f2 = f2 * 0.9F + 0.1F;
f3 = (f3 * 4.0F - 1.0F) / 8.0F;
double d7 = this.field_147426_g[i1] / 8000.0D;if (d7 < 0.0D)
{
d7 = -d7 * 0.3D;
}d7 = d7 * 3.0D - 2.0D;
if (d7 < 0.0D)
{
d7 /= 2.0D;if (d7 < -1.0D)
{
d7 = -1.0D;
}d7 /= 1.4D;
d7 /= 2.0D;
}
else
{
if (d7 > 1.0D)
{
d7 = 1.0D;
}d7 /= 8.0D;
}++i1;
double d8 = (double)f3;
double d9 = (double)f2;
d8 += d7 * 0.2D;
d8 = d8 * (double)this.settings.baseSize / 8.0D;
double d0 = (double)this.settings.baseSize + d8 * 4.0D;for (int j2 = 0; j2 < 33; ++j2)
{
double d1 = ((double)j2 - d0) * (double)this.settings.stretchY * 128.0D / 256.0D / d9;if (d1 < 0.0D)
{
d1 *= 4.0D;
}double d2 = this.field_147428_e[l] / (double)this.settings.lowerLimitScale;
double d3 = this.field_147425_f[l] / (double)this.settings.upperLimitScale;
double d4 = (this.field_147427_d[l] / 10.0D + 1.0D) / 2.0D;
double d5 = MathHelper.denormalizeClamp(d2, d3, d4) - d1;if (j2 > 29)
{
double d6 = (double)((float)(j2 - 29) / 3.0F);
d5 = d5 * (1.0D - d6) + -10.0D * d6;
}this.field_147434_q[l] = d5;
++l;
}
}
}
}/**
* Checks to see if a chunk exists at x, z
*/
public boolean chunkExists(int x, int z)
{
return true;
}/**
* Populates chunk with ores etc etc
*/
public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_)
{
BlockFalling.fallInstantly = true;
int k = p_73153_2_ * 16;
int l = p_73153_3_ * 16;
BlockPos blockpos = new BlockPos(k, 0, l);
BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(blockpos.add(16, 0, 16));
this.rand.setSeed(this.worldObj.getSeed());
long i1 = this.rand.nextLong() / 2L * 2L + 1L;
long j1 = this.rand.nextLong() / 2L * 2L + 1L;
this.rand.setSeed((long)p_73153_2_ * i1 + (long)p_73153_3_ * j1 ^ this.worldObj.getSeed());
boolean flag = false;
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(p_73153_2_, p_73153_3_);MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag));
int k1;
int l1;
int i2;if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && this.settings.useWaterLakes && !flag && this.rand.nextInt(this.settings.waterLakeChance) == 0
&& TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, LAKE))
{
k1 = this.rand.nextInt(16) + 8;
l1 = this.rand.nextInt(256);
i2 = this.rand.nextInt(16) + 8;
(new WorldGenLakes(Blocks.lava)).generate(this.worldObj, this.rand, blockpos.add(k1, l1, i2));
}if (TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, LAVA) && !flag && this.rand.nextInt(this.settings.lavaLakeChance / 10) == 0 && this.settings.useLavaLakes)
{
k1 = this.rand.nextInt(16) + 8;
l1 = this.rand.nextInt(this.rand.nextInt(248) + 8);
i2 = this.rand.nextInt(16) + 8;if (l1 < 63 || this.rand.nextInt(this.settings.lavaLakeChance / == 0)
{
(new WorldGenLakes(Blocks.lava)).generate(this.worldObj, this.rand, blockpos.add(k1, l1, i2));
}
}biomegenbase.decorate(this.worldObj, this.rand, new BlockPos(k, 0, l));
if (TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, ANIMALS))
{
SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, k + 8, l + 8, 16, 16, this.rand);
}
blockpos = blockpos.add(8, 0, 8);boolean doGen = TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, ICE);
for (k1 = 0; doGen && k1 < 16; ++k1)
{
for (l1 = 0; l1 < 16; ++l1)
{
BlockPos blockpos1 = this.worldObj.getPrecipitationHeight(blockpos.add(k1, 0, l1));
BlockPos blockpos2 = blockpos1.down();if (this.worldObj.func_175675_v(blockpos2))
{
this.worldObj.setBlockState(blockpos2, Blocks.ice.getDefaultState(), 2);
}
}
}MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag));
BlockFalling.fallInstantly = false;
}public boolean func_177460_a(IChunkProvider p_177460_1_, Chunk p_177460_2_, int p_177460_3_, int p_177460_4_)
{
return false;
}/**
* Two modes of operation: if passed true, save all Chunks in one go. If passed false, save up to two chunks.
* Return true if all chunks have been saved.
*/
public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_)
{
return true;
}/**
* Save extra data not associated with any Chunk. Not saved during autosave, only during world unload. Currently
* unimplemented.
*/
public void saveExtraData() {}/**
* Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk.
*/
public boolean unloadQueuedChunks()
{
return false;
}/**
* Returns if the IChunkProvider supports saving.
*/
public boolean canSave()
{
return true;
}/**
* Converts the instance data to a readable string.
*/
public String makeString()
{
return “RandomLevelSource”;
}public List func_177458_a(EnumCreatureType p_177458_1_, BlockPos p_177458_2_)
{
BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(p_177458_2_);return biomegenbase.getSpawnableList(p_177458_1_);
}public BlockPos getStrongholdGen(World worldIn, String p_180513_2_, BlockPos p_180513_3_)
{
return null;
}public int getLoadedChunkCount()
{
return 0;
}public void recreateStructures(Chunk p_180514_1_, int p_180514_2_, int p_180514_3_)
{}
public Chunk provideChunk(BlockPos blockPosIn)
{
return this.provideChunk(blockPosIn.getX() >> 4, blockPosIn.getZ() >> 4);
}public BlockPos findBiomePosition(int x, int z, int range, List biomes, Random random)
{
return biomes.contains(this.biomesForGeneration) ? new BlockPos(x - range + random.nextInt(range * 2 + 1), 0, z - range + random.nextInt(range * 2 + 1)) : null;
}
}_Dans la méthode ChunkProvider, func_177865 n'existe pas. Sur getModdedNoiseGenerators, l'erreur est Bound mismatch: The generic method getModdedNoiseGenerators(World, Random, T) of type TerrainGen is not applicable for the arguments (World, Random, NoiseGenerator[]). The inferred type NoiseGenerator[] is not a valid substitute for the bounded parameter <t extends="" initnoisegensevent.context="">(je ne comprend pas) _Dans les méthodes setBlocksInChunk et provideChunk, getWorldChunkManager n'existe pas. _Dans la méthode func_180517_a, ChunkProviderEvent n'existe pas. _Dans la méthode func_1474123_a : minHeight et maxHeight n'existe pas. _Dans la méthode populate, SpawnerAnimals et func_175675 n'existent pas. i) Dans le teleporter ```java package thisishalloween.world.frightful; import com.google.common.collect.Lists; import java.util.Iterator; import java.util.List; import java.util.Random; import net.minecraft.block.BlockPortal; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; import net.minecraft.util.LongHashMap; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.Teleporter; import net.minecraft.world.WorldServer; import thisishalloween.CreateBlocks; public class TeleporterFrightful extends Teleporter { private final WorldServer worldServerInstance; private final Random random; private final LongHashMap destinationCoordinateCache = new LongHashMap(); private final List destinationCoordinateKeys = Lists.newArrayList(); public TeleporterFrightful(WorldServer worldIn) { super(worldIn); this.worldServerInstance = worldIn; this.random = new Random(worldIn.getSeed()); } public void placeInPortal(Entity entityIn, float rotationYaw) { if (this.worldServerInstance.provider.getDimension() != 1) { if (!this.placeInExistingPortal(entityIn, rotationYaw)) { this.makePortal(entityIn); this.placeInExistingPortal(entityIn, rotationYaw); } } else { int i = MathHelper.floor_double(entityIn.posX); int j = MathHelper.floor_double(entityIn.posY) - 1; int k = MathHelper.floor_double(entityIn.posZ); byte b0 = 1; byte b1 = 0; for (int l = -2; l <= 2; ++l) { for (int i1 = -2; i1 <= 2; ++i1) { for (int j1 = -1; j1 < 3; ++j1) { int k1 = i + i1 * b0 + l * b1; int l1 = j + j1; int i2 = k + i1 * b1 - l * b0; boolean flag = j1 < 0; this.worldServerInstance.setBlockState(new BlockPos(k1, l1, i2), flag ? Blocks.nether_brick.getDefaultState() : Blocks.air.getDefaultState()); } } } entityIn.setLocationAndAngles((double)i, (double)j, (double)k, entityIn.rotationYaw, 0.0F); entityIn.motionX = entityIn.motionY = entityIn.motionZ = 0.0D; } } public boolean placeInExistingPortal(Entity entityIn, float p_180620_2_) { boolean flag = true; double d0 = -1.0D; int i = MathHelper.floor_double(entityIn.posX); int j = MathHelper.floor_double(entityIn.posZ); boolean flag1 = true; Object object = BlockPos.ORIGIN; long k = ChunkCoordIntPair.chunkXZ2Int(i, j); if (this.destinationCoordinateCache.containsItem(k)) { TeleporterFrightful.PortalPosition portalposition = (TeleporterFrightful.PortalPosition)this.destinationCoordinateCache.getValueByKey(k); d0 = 0.0D; object = portalposition; portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime(); flag1 = false; } else { BlockPos blockpos4 = new BlockPos(entityIn); for (int l = -128; l <= 128; ++l) { BlockPos blockpos1; for (int i1 = -128; i1 <= 128; ++i1) { for (BlockPos blockpos = blockpos4.add(l, this.worldServerInstance.getActualHeight() - 1 - blockpos4.getY(), i1); blockpos.getY() >= 0; blockpos = blockpos1) { blockpos1 = blockpos.down(); if (this.worldServerInstance.getBlockState(blockpos).getBlock() == CreateBlocks.portalFrightful) { while (this.worldServerInstance.getBlockState(blockpos1 = blockpos.down()).getBlock() == CreateBlocks.portalFrightful) { blockpos = blockpos1; } double d1 = blockpos.distanceSq(blockpos4); if (d0 < 0.0D || d1 < d0) { d0 = d1; object = blockpos; } } } } } } if (d0 >= 0.0D) { if (flag1) { this.destinationCoordinateCache.add(k, new TeleporterFrightful.PortalPosition((BlockPos)object, this.worldServerInstance.getTotalWorldTime())); this.destinationCoordinateKeys.add(Long.valueOf(k)); } double d4 = (double)((BlockPos)object).getX() + 0.5D; double d5 = (double)((BlockPos)object).getY() + 0.5D; double d6 = (double)((BlockPos)object).getZ() + 0.5D; EnumFacing enumfacing = null; if (this.worldServerInstance.getBlockState(((BlockPos)object).west()).getBlock() == CreateBlocks.portalFrightful) { enumfacing = EnumFacing.NORTH; } if (this.worldServerInstance.getBlockState(((BlockPos)object).east()).getBlock() == CreateBlocks.portalFrightful) { enumfacing = EnumFacing.SOUTH; } if (this.worldServerInstance.getBlockState(((BlockPos)object).north()).getBlock() == CreateBlocks.portalFrightful) { enumfacing = EnumFacing.EAST; } if (this.worldServerInstance.getBlockState(((BlockPos)object).south()).getBlock() == CreateBlocks.portalFrightful) { enumfacing = EnumFacing.WEST; } EnumFacing enumfacing1 = EnumFacing.getHorizontal(entityIn.getTeleportDirection()); if (enumfacing != null) { EnumFacing enumfacing2 = enumfacing.rotateYCCW(); BlockPos blockpos2 = ((BlockPos)object).offset(enumfacing); boolean flag2 = this.func_180265_a(blockpos2); boolean flag3 = this.func_180265_a(blockpos2.offset(enumfacing2)); if (flag3 && flag2) { object = ((BlockPos)object).offset(enumfacing2); enumfacing = enumfacing.getOpposite(); enumfacing2 = enumfacing2.getOpposite(); BlockPos blockpos3 = ((BlockPos)object).offset(enumfacing); flag2 = this.func_180265_a(blockpos3); flag3 = this.func_180265_a(blockpos3.offset(enumfacing2)); } float f6 = 0.5F; float f1 = 0.5F; if (!flag3 && flag2) { f6 = 1.0F; } else if (flag3 && !flag2) { f6 = 0.0F; } else if (flag3) { f1 = 0.0F; } d4 = (double)((BlockPos)object).getX() + 0.5D; d5 = (double)((BlockPos)object).getY() + 0.5D; d6 = (double)((BlockPos)object).getZ() + 0.5D; d4 += (double)((float)enumfacing2.getFrontOffsetX() * f6 + (float)enumfacing.getFrontOffsetX() * f1); d6 += (double)((float)enumfacing2.getFrontOffsetZ() * f6 + (float)enumfacing.getFrontOffsetZ() * f1); float f2 = 0.0F; float f3 = 0.0F; float f4 = 0.0F; float f5 = 0.0F; if (enumfacing == enumfacing1) { f2 = 1.0F; f3 = 1.0F; } else if (enumfacing == enumfacing1.getOpposite()) { f2 = -1.0F; f3 = -1.0F; } else if (enumfacing == enumfacing1.rotateY()) { f4 = 1.0F; f5 = -1.0F; } else { f4 = -1.0F; f5 = 1.0F; } double d2 = entityIn.motionX; double d3 = entityIn.motionZ; entityIn.motionX = d2 * (double)f2 + d3 * (double)f5; entityIn.motionZ = d2 * (double)f4 + d3 * (double)f3; entityIn.rotationYaw = p_180620_2_ - (float)(enumfacing1.getHorizontalIndex() * 90) + (float)(enumfacing.getHorizontalIndex() * 90); } else { entityIn.motionX = entityIn.motionY = entityIn.motionZ = 0.0D; } entityIn.setLocationAndAngles(d4, d5, d6, entityIn.rotationYaw, entityIn.rotationPitch); //TODO return true; } else { return false; } } private boolean func_180265_a(BlockPos p_180265_1_) { return !this.worldServerInstance.isAirBlock(p_180265_1_) || !this.worldServerInstance.isAirBlock(p_180265_1_.up()); } public boolean makePortal(Entity p_85188_1_) { byte b0 = 16; double d0 = -1.0D; int i = MathHelper.floor_double(p_85188_1_.posX); int j = MathHelper.floor_double(p_85188_1_.posY); int k = MathHelper.floor_double(p_85188_1_.posZ); int l = i; int i1 = j; int j1 = k; int k1 = 0; int l1 = this.random.nextInt(4); int i2; double d1; int k2; double d2; int i3; int j3; int k3; int l3; int i4; int j4; int k4; int l4; int i5; double d3; double d4; for (i2 = i - b0; i2 <= i + b0; ++i2) { d1 = (double)i2 + 0.5D - p_85188_1_.posX; for (k2 = k - b0; k2 <= k + b0; ++k2) { d2 = (double)k2 + 0.5D - p_85188_1_.posZ; label271: for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; –i3) { if (this.worldServerInstance.isAirBlock(new BlockPos(i2, i3, k2))) { while (i3 > 0 && this.worldServerInstance.isAirBlock(new BlockPos(i2, i3 - 1, k2))) { --i3; } for (j3 = l1; j3 < l1 + 4; ++j3) { k3 = j3 % 2; l3 = 1 - k3; if (j3 % 4 >= 2) { k3 = -k3; l3 = -l3; } for (i4 = 0; i4 < 3; ++i4) { for (j4 = 0; j4 < 4; ++j4) { for (k4 = -1; k4 < 4; ++k4) { l4 = i2 + (j4 - 1) * k3 + i4 * l3; i5 = i3 + k4; int j5 = k2 + (j4 - 1) * l3 - i4 * k3; if (k4 < 0 && !this.worldServerInstance.getBlockState(new BlockPos(l4, i5, j5)).getBlock().getMaterial().isSolid() || k4 >= 0 && !this.worldServerInstance.isAirBlock(new BlockPos(l4, i5, j5))) { continue label271; } } } } d3 = (double)i3 + 0.5D - p_85188_1_.posY; d4 = d1 * d1 + d3 * d3 + d2 * d2; if (d0 < 0.0D || d4 < d0) { d0 = d4; l = i2; i1 = i3; j1 = k2; k1 = j3 % 4; } } } } } } if (d0 < 0.0D) { for (i2 = i - b0; i2 <= i + b0; ++i2) { d1 = (double)i2 + 0.5D - p_85188_1_.posX; for (k2 = k - b0; k2 <= k + b0; ++k2) { d2 = (double)k2 + 0.5D - p_85188_1_.posZ; label219: for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3) { if (this.worldServerInstance.isAirBlock(new BlockPos(i2, i3, k2))) { while (i3 > 0 && this.worldServerInstance.isAirBlock(new BlockPos(i2, i3 - 1, k2))) { --i3; } for (j3 = l1; j3 < l1 + 2; ++j3) { k3 = j3 % 2; l3 = 1 - k3; for (i4 = 0; i4 < 4; ++i4) { for (j4 = -1; j4 < 4; ++j4) { k4 = i2 + (i4 - 1) * k3; l4 = i3 + j4; i5 = k2 + (i4 - 1) * l3; if (j4 < 0 && !this.worldServerInstance.getBlockState(new BlockPos(k4, l4, i5)).getBlock().getMaterial().isSolid() || j4 >= 0 && !this.worldServerInstance.isAirBlock(new BlockPos(k4, l4, i5))) { continue label219; } } } d3 = (double)i3 + 0.5D - p_85188_1_.posY; d4 = d1 * d1 + d3 * d3 + d2 * d2; if (d0 < 0.0D || d4 < d0) { d0 = d4; l = i2; i1 = i3; j1 = k2; k1 = j3 % 2; } } } } } } } int k5 = l; int j2 = i1; k2 = j1; int l5 = k1 % 2; int l2 = 1 - l5; if (k1 % 4 >= 2) { l5 = -l5; l2 = -l2; } if (d0 < 0.0D) { i1 = MathHelper.clamp_int(i1, 70, this.worldServerInstance.getActualHeight() - 10); j2 = i1; for (i3 = -1; i3 <= 1; ++i3) { for (j3 = 1; j3 < 3; ++j3) { for (k3 = -1; k3 < 3; ++k3) { l3 = k5 + (j3 - 1) * l5 + i3 * l2; i4 = j2 + k3; j4 = k2 + (j3 - 1) * l2 - i3 * l5; boolean flag = k3 < 0; this.worldServerInstance.setBlockState(new BlockPos(l3, i4, j4), flag ? Blocks.nether_brick.getDefaultState() : Blocks.air.getDefaultState()); } } } } IBlockState iblockstate = CreateBlocks.portalFrightful.getDefaultState().withProperty(BlockPortal.AXIS, l5 != 0 ? EnumFacing.Axis.X : EnumFacing.Axis.Z); for (j3 = 0; j3 < 4; ++j3) { for (k3 = 0; k3 < 4; ++k3) { for (l3 = -1; l3 < 4; ++l3) { i4 = k5 + (k3 - 1) * l5; j4 = j2 + l3; k4 = k2 + (k3 - 1) * l2; boolean flag1 = k3 == 0 || k3 == 3 || l3 == -1 || l3 == 3; this.worldServerInstance.setBlockState(new BlockPos(i4, j4, k4), flag1 ? Blocks.nether_brick.getDefaultState() : iblockstate, 2); } } for (k3 = 0; k3 < 4; ++k3) { for (l3 = -1; l3 < 4; ++l3) { i4 = k5 + (k3 - 1) * l5; j4 = j2 + l3; k4 = k2 + (k3 - 1) * l2; this.worldServerInstance.notifyNeighborsOfStateChange(new BlockPos(i4, j4, k4), this.worldServerInstance.getBlockState(new BlockPos(i4, j4, k4)).getBlock()); } } } return true; } /** * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a * WorldServer.getTotalWorldTime() value. */ public void removeStalePortalLocations(long p_85189_1_) { if (p_85189_1_ % 100L == 0L) { Iterator iterator = this.destinationCoordinateKeys.iterator(); long j = p_85189_1_ - 600L; while (iterator.hasNext()) { Long olong = (Long)iterator.next(); TeleporterFrightful.PortalPosition portalposition = (TeleporterFrightful.PortalPosition)this.destinationCoordinateCache.getValueByKey(olong.longValue()); if (portalposition == null || portalposition.lastUpdateTime < j) { iterator.remove(); this.destinationCoordinateCache.remove(olong.longValue()); } } } } public class PortalPosition extends BlockPos { /** The worldtime at which this PortalPosition was last verified */ public long lastUpdateTime; public PortalPosition(BlockPos pos, long p_i45747_3_) { super(pos.getX(), pos.getY(), pos.getZ()); this.lastUpdateTime = p_i45747_3_; } } }
_Dans la méthode placeInExistingPortal, à la ligne ```java
EnumFacing enumfacing1 = EnumFacing.getHorizontal(entityIn.getTeleportDirection());_Dans la méthode makePortal, à la condition ```java if (j4 < 0 && !this.worldServerInstance.getBlockState(new BlockPos(k4, l4, i5)).getBlock().getMaterial().isSolid() || j4 >= 0 && !this.worldServerInstance.isAirBlock(new BlockPos(k4, l4, i5))) ``` getMaterial doit avoir en argument IBlockState. Il faut mettre quoi ? 4) Client (render, son, ...) a) Dans mon clientTickHandler, ```java mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, thisishalloween.ThisisHalloween.MODID + ":ambient.nightSound", 0.2F, 1.0F, false); ``` playSound doit avoir comme argument BlockPos, SoundEvent, SoundCategory, float, float, boolean. Ici, c'est double, double, double, String, float, float, boolean. b) Comment enregistrer un son custom ? Ca a changé. c) Dans le render de mon boss, à la ligne ```java BossStatus.setBossStatus(mob, true); ``` BossStatus n'existe pas. J'ai regardé dans le render du dragon et du wither mais ça ne m'a rien apporté. Comme vous voyer, j'ai encore beaucoup d'erreur que je n'arrive pas à régler. Je continue de chercher, mais si vous pouvez m'aider, ... Merci d'avance</t></string>
- commandes
-
@‘Axaurus’:
J’ai commencer à mettre à jour mon mod pour la 1.9 et il y a beaucoup beaucoup d’erreur (j’ai peur pour la 1.10 :s , déjà qu’à la 1.8, beaucoup de trucs en changé)
0 différentes entre la 1.9 et la 1.10. Tu peux même commencer à dev directement en 1.10.2.
-
a) aucune idée
b) pour remplir automatiquement quand on appuies sur tab à mon avis. -
a + b + c) plus besoin. Même en 1.8.9 tu n’aura pas dû les utiliser, les sont notés comme obsolète depuis cette version.
Il faut uniquement utiliser registerModEntity. Il y a une fonction pour enregistrer les œufs.
d) surement changé de nom. -
a) adaptes ta déclaration dans la classe principale avec un objet BiomeProperties
b à i) : je ne sais pas -
a) + b)
public static SoundEvent nomDuSon = new SoundEvent(new ResourceLocation(MODID, "nomDuSon ")); […] canon.setRegistryName("nomDuSon "); GameRegistry.<soundevent>register(nomDuSon);
c) aucune idée.</soundevent>
-
-
Pour la 1) a) , c’est peut-être, dans la fonction checkPermission, à partir de l’ICommandSender, tu get son niveau de permission et si elle est supérieure ou égale à la valeur minimal que tu met d’habitude dans la fonction getRequiredPermissionLevel (simple supposition, je n’ai jamais codé en 1.9).
-
Salut
Pour la question 3b (setBiomeName qui n’existe plus), il est remplacé par le BiomeProperties qu’on doit mettre entre parenthèse.
exemple : en 1.8, mon biome était comme ça :Evilland = new BiomeGenEvilland(200).setBiomeName("Evilland").setDisableRain().setTemperatureRainfall(2.0F, 0.0F);
maintenant, c’est comme ça : ```java
Evilland = new BiomeGenEvilland((new BiomeGenBase.BiomeProperties(“Evilland”)).setRainDisabled().setTemperature(2.0F).setRainfall(0.0F));Je n'ai plus que 27 erreurs en tout (100+ auparavant). La plupart des erreurs sont surtout par rapport à la dimension (donc, en reprenant le 1er post, de la question d à i), mais j'ai aussi encore une erreur à l'entity de mon boss (plus de IBossDisplayData) et au render (plus de BossStatus). Pour la question 3c, je n'ai pas réussi à résoudre mais j'ai trouver comment faire : il faut créer un WorldType, mais comment faire ? Merci d'avance EDIT : je viens de voir que le système de loot a changé. Je suppose que getDropItem() ne marche plus. Du coup, on fait comment ?
-
Pour ton IBossPlayerData : https://www.minecraftforgefrance.fr/showthread.php?tid=3660
-
Pour le passage de la 1.9 à la 1.10 : la seul erreur que j’ai pus avoir était un changement sur certaine constance (désormais toute écrite en majuscule)
g) Il faut savoir que dans cette maj, beaucoup de “liaison” on changé. Des objets ont été rajouté/modifié pour servir de liaison plus propre.
Je ne connais pas trop le principe de Dimension, je m’y suis jamais vraiment penché, mais de ce que j’ai vue du code source, cette fonctionne donner un objet de type DimensionType.
Cette objet est une valeur contenus dans un enum et apporte plusieurs information sur la dimension.
Il faut en créer un avec “DimensionType.register(String name, String suffix, int id, Class provider, boolean keepLoaded)” et c’est celui que tu dois retourner.Les fonctions servent ensuite un peu partout dans le code pour gérer : les villages (suffix), le displays (name) lors de l’enregistrement, et tous ce qui attrait au dimension (id) (rendu du ciel, portail, placement de block, update d’entité). C’est aussi lui qui permet de créer la dimension (apparemment, une fonction gère la création grâce a la class WorldProvider fournis en paramètre)
Astuce : si tu code sur Eclipse, quand tu ne sais pas à quoi sert une fonction, sélectionne le nom, clic droit, et 'open call hierarchy". Tu aura une liste de toute les fonctions qui appelle cette méthode. De fils en aiguille tu peu généralement comprendre plus ou moins à quoi ça sert
-
Salut
Désolé du temps de la réponse, j’étais partis en vacances.
J’ai d’autres problèmes (que ça soit pour la barre de vie du boss ou pour le dimension type).
Pour la barre de vie, ```java
super.addTrackingPlayer(player);
super.removeTrackingPlayer(player);Pour le dimensionType, quand je met ```java DimensionType.register("Frightful", "Frightful", this.DIMENSIONID, new WorldProviderFrightful(), false); ``` il y a une erreur sur register en me précisant que ces arguments ne sont pas bon. Le voilà (l'erreur):
The method register(String, String, int, Class, boolean) in the type DimensionType is not applicable for the arguments (String, String, int, WorldProviderFrightful, boolean)
. Mais voilà l'erreur : ma classe WorldProviderFrightful est extends de WorldProvider. Il demande une classe extends de WorldProvider mais quand je lui en donne une, ça ne lui convient pas :@. Du coup, j'ai aussi testé avec le WorldProviderHell (qui est lui aussi extends de WorldProvider) mais pareil ça ne marche pas. J'ai continuer de faire d'autres recherches (disons rapides) mais je n'ai rien trouvé. Je continuerai de chercher plus en profondeur Merci d'avance
-
DimensionType.register(“Frightful”, “Frightful”, this.DIMENSIONID, WorldProviderFrightful.class, false);
il demande un objet de type classe, pas une instance de la class
-
Salut
J’ai compris mon erreur, je l’ai corrigé.
J’ai aussi corrigé d’autres erreurs mais je ne suis pas sûr de ce que j’ai mis.
Par exemple, dans le teleporter, j’ai remplacé ma fonction placeInExistingPortal par celle de base. Pour les .getMaterial où il fallait un argument (voir 1er post), il suffisait d’enlever le .getBlock qui étais juste avant.
En gros, je me suis inspiré des classes de base.
Pour mon WorldChunkManager, il étais extends de WorldChunkManager. Je croyais qu’il n’existait plus en 1.9, mais si, il a juste changé de nom. Il s’appelle dorénavant BiomeProvider.Je n’ai plus que quelques erreurs : Dans mon teleporter :
private void travelToDimension(Entity entity, int id) { if (!entity.worldObj.isRemote && !entity.isDead) { entity.worldObj.theProfiler.startSection("changeDimension"); MinecraftServer minecraftserver = entity.getServer(); int j = entity.dimension; WorldServer worldserver = minecraftserver.worldServerForDimension(j); WorldServer worldserver1 = minecraftserver.worldServerForDimension(id); entity.dimension = id; if (j == 1 && id == 1) { worldserver1 = minecraftserver.worldServerForDimension(0); entity.dimension = 0; } entity.worldObj.removeEntity(entity); entity.isDead = false; entity.worldObj.theProfiler.startSection("reposition"); minecraftserver.getConfigurationManager().transferEntityToWorld(entity, j, worldserver, worldserver1, new Teleporter(worldserver1)); entity.worldObj.theProfiler.endStartSection("reloading"); Entity entity1 = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1); if (entity1 != null) { entity1.copyDataFromOld(entity); if (j == 1 && id == 1) { BlockPos spawnPoint = worldserver1.getSpawnPoint(); spawnPoint = entity.worldObj.getTopSolidOrLiquidBlock(spawnPoint); entity1.setLocationAndAngles(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), entity1.rotationYaw, entity1.rotationPitch); } worldserver1.spawnEntityInWorld(entity1); } entity.isDead = true; entity.worldObj.theProfiler.endSection(); worldserver.resetUpdateEntityTick(); worldserver1.resetUpdateEntityTick(); entity.worldObj.theProfiler.endSection(); } } ``` getConfigurationManager n'existe plus dans MinecraftServer. Dans Entity, copyDateFromOld est devenu privée. Du coup, quelle alternative prendre ? Dans mon ChunkProvider, à cette ligne : ```java noiseGens = TerrainGen.getModdedNoiseGenerators(worldIn, this.rand, noiseGens); ```il a une erreur sur getModdedNoiseGenerators :
Bound mismatch: The generic method getModdedNoiseGenerators(World, Random, T) of type TerrainGen is not applicable for the arguments (World, Random, NoiseGenerator[]). The inferred type NoiseGenerator[] is not a valid substitute for the bounded parameter <t extends=“” initnoisegensevent.context=“”>```
Je comprend la 1ère partie, c’est un problème de paramètres (qu’est ce que T ?), mais après je ne comprend pas.
minHeight et maxHeight n’existe plus dans BiomeGenBase. Je suis allé dedans, et j’ai vu qu’il y a deux variables : une qui s’appelle baseHeight ( = minHeight) et une heightVariation. J’ai trouvé comment faire pour maxHeight : la variation - la base. Pour le minHeight, elle a juste changé de nom. Mais voilà le problème : elles sont toutes les deux privées. Comment faire ?
Dans la fonction populate, la classe SpawnerAnimals n’existe plus.Et j’ai aussi une question : j’ai dû ajouté cette fonction : ```java
@Override
public boolean generateStructures(Chunk chunkIn, int x, int z) {
// TODO Auto-generated method stub
return false;
}Après ça, je n'aurais plus d'erreur. J'espère juste que tout marchera correctement Merci d'avance EDIT : Salut. J'ai pu corriger les erreurs dans le ChunkProvider. Il me reste plus que deux erreurs (en réalité 4 mais 3 erreurs sont les mêmes). Dans le blockPortal, getConfigurationManager n'existe pas dans MinecraftServer. Je suis allé dedans, mais je ne vois rien de similaire. Et copyDataFromOld est privée dans Entity.</t>
-
Re (ou salut à ceux qui n’aurait pas vu l’édit du post au-dessus)
(comme dit dans l’édit du post ci-dessus) Il ne me reste plus que quelques erreurs dans le teleporter. Malheureusement, je ne peux pas utiliser les classes vanilla pour les corriger vu que ce n’est pas utilisé (en tout cas, pas à ma connaissance). J’ai quand même lancé le jeu et j’ai remarquer un bug assez illogique. Je ne peux aller dans un monde qu’une seule fois. Si j’y retourne une deuxième fois, ça me fait crash en me mettant comme erreur :
[18:21:18] [Server thread/INFO]: Player942 joined the game [18:21:18] [Server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.fml.common.gameevent.TickEvent$PlayerTickEvent@784676da: java.lang.NullPointerException at thisishalloween.client.ClientTickHandler.NightSound(ClientTickHandler.java:33) ~[ClientTickHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_16_ClientTickHandler_NightSound_PlayerTickEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPostTick(FMLCommonHandler.java:357) [FMLCommonHandler.class:?] at net.minecraft.entity.player.EntityPlayer.updateSize(EntityPlayer.java:395) [EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:311) [EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:339) [EntityPlayerMP.class:?] at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174) [NetHandlerPlayServer.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:196) [NetworkDispatcher$1.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:802) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_92] [18:21:18] [Server thread/ERROR] [FML]: Index: 1 Listeners: [18:21:18] [Server thread/ERROR] [FML]: 0: NORMAL [18:21:18] [Server thread/ERROR] [FML]: 1: ASM: thisishalloween.client.ClientTickHandler@54b7bfbe NightSound(Lnet/minecraftforge/fml/common/gameevent/TickEvent$PlayerTickEvent;)V [18:21:18] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking player at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:210) ~[NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:802) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) ~[IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_92] Caused by: java.lang.NullPointerException at thisishalloween.client.ClientTickHandler.NightSound(ClientTickHandler.java:33) ~[ClientTickHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_16_ClientTickHandler_NightSound_PlayerTickEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) ~[EventBus.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPostTick(FMLCommonHandler.java:357) ~[FMLCommonHandler.class:?] at net.minecraft.entity.player.EntityPlayer.updateSize(EntityPlayer.java:395) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:311) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:339) ~[EntityPlayerMP.class:?] at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174) ~[NetHandlerPlayServer.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:196) ~[NetworkDispatcher$1.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) ~[NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) ~[NetworkSystem.class:?] … 5 more [18:21:18] [Server thread/ERROR]: This crash report has been saved to: G:\Codage\Minecraft\This_is_Halloween\v1.3\MC 1.9\run\.\crash-reports\crash-2016-08-10_18.21.18-server.txt [18:21:18] [Server thread/INFO]: Stopping server [18:21:18] [Server thread/INFO]: Saving players [18:21:18] [Server thread/INFO]: Saving worlds [18:21:18] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld [18:21:18] [Server thread/INFO]: Saving chunks for level 'New World'/Nether [18:21:18] [Server thread/INFO]: Saving chunks for level 'New World'/The End [18:21:18] [Server thread/INFO] [FML]: Unloading dimension 0 [18:21:18] [Server thread/INFO] [FML]: Unloading dimension -1 [18:21:18] [Server thread/INFO] [FML]: Unloading dimension 1 [18:21:18] [Server thread/INFO] [FML]: Applying holder lookups [18:21:18] [Server thread/INFO] [FML]: Holder lookups applied [18:21:18] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded. [18:21:18] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:646]: –-- Minecraft Crash Report ---- // Uh... Did I do that? Time: 10/08/16 18:21 Description: Ticking player java.lang.NullPointerException: Ticking player at thisishalloween.client.ClientTickHandler.NightSound(ClientTickHandler.java:33) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_16_ClientTickHandler_NightSound_PlayerTickEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPostTick(FMLCommonHandler.java:357) at net.minecraft.entity.player.EntityPlayer.updateSize(EntityPlayer.java:395) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:311) at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:339) at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:196) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:802) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) at java.lang.Thread.run(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at thisishalloween.client.ClientTickHandler.NightSound(ClientTickHandler.java:33) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_16_ClientTickHandler_NightSound_PlayerTickEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPostTick(FMLCommonHandler.java:357) at net.minecraft.entity.player.EntityPlayer.updateSize(EntityPlayer.java:395) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:311) -- Player being ticked -- Details: Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) Entity ID: 11290 Entity Name: Player942 Entity's Exact location: -236,50, 4,00, 902,50 Entity's Block location: World: (-237,4,902), Chunk: (at 3,0,6 in -15,56; contains blocks -240,0,896 to -225,255,911), Region: (-1,1; contains chunks -32,32 to -1,63, blocks -512,0,512 to -1,255,1023) Entity's Momentum: 0,00, -0,08, 0,00 Entity's Passengers: [] Entity's Vehicle: ~~ERROR~~ NullPointerException: null Stacktrace: at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:339) at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:196) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@685bb755 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:802) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) at java.lang.Thread.run(Unknown Source) -- System Details -- Details: Minecraft Version: 1.9 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_92, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 617548424 bytes (588 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.23 Powered by Forge 12.16.1.1887 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAAAAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAAAAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.9-12.16.1.1887.jar) UCHIJAAAAAAAAA Forge{12.16.1.1887} [Minecraft Forge] (forgeSrc-1.9-12.16.1.1887.jar) UCHIJAAAAAAAAA This_is_Halloween{1.3} [This_is_Halloween] (bin) Loaded coremods (and transformers): GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 1 / 8; [EntityPlayerMP['Player942'/11290, l='New World', x=-236,50, y=4,00, z=902,50]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' [18:21:18] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:646]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2016-08-10_18.21.18-server.txt [18:21:18] [Client Shutdown Thread/INFO]: Stopping server [18:21:18] [Client Shutdown Thread/INFO]: Saving players AL lib: (EE) alc_cleanup: 1 device not closed Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
L’erreur me pointe à ```java
if(mc.theWorld.getWorldTime() == 15000)Il y a aussi un autre bug en "rapport" avec ma dimension (je met entre guillemet parce que logiquement non, mais si). Je créer et enregistre ma dimension par ```java DimensionManager.registerDimension(DIMENSIONID, this.frightfulDimensionType); DimensionManager.createProviderFor(DIMENSIONID); ```Quand j'essaye de créer un monde, ça crash :
[18:24:10] [Server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@11b08534)
[18:24:11] [Server thread/INFO] [FML]: Loading dimension -5 (New World) (net.minecraft.server.integrated.IntegratedServer@11b08534)
[18:24:11] [Server thread/ERROR]: Encountered an unexpected exception
java.lang.NullPointerException
at net.minecraft.village.VillageCollection.fileNameForProvider(VillageCollection.java:305) ~[VillageCollection.class:?]
at net.minecraft.world.WorldServerMulti.init(WorldServerMulti.java:67) ~[WorldServerMulti.class:?]
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:90) ~[IntegratedServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:123) ~[IntegratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:492) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_92]
[18:24:11] [Server thread/ERROR]: This crash report has been saved to: G:\Codage\Minecraft\This_is_Halloween\v1.3\MC 1.9\run.\crash-reports\crash-2016-08-10_18.24.11-server.txt
[18:24:11] [Server thread/INFO]: Stopping server
[18:24:11] [Server thread/INFO]: Saving players
[18:24:11] [Server thread/INFO]: Saving worlds
[18:24:11] [Server thread/INFO]: Saving chunks for level ‘New World’/Overworld
[18:24:11] [Server thread/ERROR]: Exception stopping the server
java.lang.NullPointerException
at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:406) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.saveAllWorlds(IntegratedServer.java:237) ~[IntegratedServer.class:?]
at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:452) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:368) ~[IntegratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:585) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_92]
[18:24:11] [Server thread/INFO] [FML]: Applying holder lookups
[18:24:11] [Server thread/INFO] [FML]: Holder lookups applied
[18:24:11] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STARTING and forced into state SERVER_STOPPED. Errors may have been discarded.
[18:24:12] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:646]: –-- Minecraft Crash Report ----
// Daisy, daisy…Time: 10/08/16 18:24
Description: Exception in server tick loopjava.lang.NullPointerException: Exception in server tick loop
at net.minecraft.village.VillageCollection.fileNameForProvider(VillageCollection.java:305)
at net.minecraft.world.WorldServerMulti.init(WorldServerMulti.java:67)
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:90)
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:123)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:492)
at java.lang.Thread.run(Unknown Source)A detailed walkthrough of the error, its code path and all known details is as follows:
– System Details –
Details:
Minecraft Version: 1.9
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_92, Oracle Corporation
Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 618242424 bytes (589 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP 9.23 Powered by Forge 12.16.1.1887 4 mods loaded, 4 mods active
States: ‘U’ = Unloaded ‘L’ = Loaded ‘C’ = Constructed ‘H’ = Pre-initialized ‘I’ = Initialized ‘J’ = Post-initialized ‘A’ = Available ‘D’ = Disabled ‘E’ = Errored
UCHIJAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)
UCHIJAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.9-12.16.1.1887.jar)
UCHIJAA Forge{12.16.1.1887} [Minecraft Forge] (forgeSrc-1.9-12.16.1.1887.jar)
UCHIJAA This_is_Halloween{1.3} [This_is_Halloween] (bin)
Loaded coremods (and transformers):
GL info:ERRORRuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 0 / 8; []
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to ‘fml,forge’
[18:24:12] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:646]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2016-08-10_18.24.11-server.txt
[18:24:12] [Client Shutdown Thread/INFO]: Stopping server
[18:24:12] [Client Shutdown Thread/INFO]: Saving players
[18:24:12] [Client Shutdown Thread/INFO]: Saving worlds
[18:24:12] [Client Shutdown Thread/INFO]: Saving chunks for level ‘New World’/Overworld
Exception in thread “Client Shutdown Thread” AL lib: (EE) alc_cleanup: 1 device not closed
Java HotSpot 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future releaseVisiblement, ça serrait au moment de charger ma dimension. Mais ce que je trouve étonnant, c'est que les logs parlent de villages … alors qu'il n'y a pas de village dans ma dimension. Par contre, si j'enlève ces deux lignes, ça marche parfaitement (quand je n'ai pas l'autre crash). J'ai aussi une question : dans les logs, j'ai ça :
2016-08-10 18:23:37,193 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2016-08-10 18:23:37,225 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2016-08-10 18:23:37,226 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStreamJe sais pas si c'est Minecraft ou Java qui affiche ça, mais je voudrais savoir ce que c'est. Ce n'est pas dérangeant du tout, ça marche bien, mais bon ... Merci d'avance
-
- La première est un NPE donc soit Minecraft est null, soit le monde est null, tu tick le client ou le monde ? Envoi la fonction entière ce sera plus claire.
- Peut être qu’il faut préciser que ton monde n’a pas de village (c’est une supposition, je n’y connais pas grand chose en dimensions)
- C’est un simple avertissement, il n’a rien d’important (j’ai la même chose dans mes logs)
PS : si tu mets à jour ton mod pense à respecter la convention java au passage.
-
- Il semblerait que ça soit l’entity type qui soit null, je vois ça dans les logs :
Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)
C’est le joueur que je tick, voilà ma fonction : ```java
@SubscribeEvent
public void nightSound(TickEvent.PlayerTickEvent event)
{
if (event.phase == TickEvent.Phase.END)
{
Minecraft mc = FMLClientHandler.instance().getClient();if(mc.theWorld.getWorldTime() == 15000)
{
mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, SoundsRegistering.ambient_nightSound, SoundCategory.AMBIENT, 0.2F, 1.0F, false);
}if(mc.theWorld.getWorldTime() == 16000)
{
mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, SoundsRegistering.ambient_nightSound, SoundCategory.AMBIENT, 0.2F, 1.0F, false);
}if(mc.theWorld.getWorldTime() == 17000)
{
mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, SoundsRegistering.ambient_nightSound, SoundCategory.AMBIENT, 0.2F, 1.0F, false);
}if(mc.theWorld.getWorldTime() == 18000)
{
mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, SoundsRegistering.ambient_nightSound, SoundCategory.AMBIENT, 0.2F, 1.0F, false);
}if(mc.theWorld.getWorldTime() == 19000)
{
mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, SoundsRegistering.ambient_nightSound, SoundCategory.AMBIENT, 0.2F, 1.0F, false);
}if(mc.theWorld.getWorldTime() == 20000)
{
mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, SoundsRegistering.ambient_nightSound, SoundCategory.AMBIENT, 0.2F, 1.0F, false);
}
}
}Ce que je ne comprend pas, c'est pourquoi ça crash quand je charge un monde et pas au moment où ça doit jouer le son. De plus, le son se joue quand même la nuit. 2) Je ne sais pas comment faire (si c'est bien ça qu'il faut faire …). Mais je ne comprend pas pourquoi ça fait ça quand je créer un monde. Ca devrait plutôt le faire quand je rentre dans ma dimension. 3) Ok merci :) EDIT : Pour la convention java, j'essaye mais je n'y arrive pas toujours
-
- Impossible car tu n’appelles pas l’entité à ce moment là. Essaie plutôt un WorldTick
Voici un meilleur code :
@SubscribeEvent public void nightSound(TickEvent.WorldTickEvent event) { if (event.phase == TickEvent.Phase.END) { Minecraft mc = FMLClientHandler.instance().getClient(); switch (mc.theWorld.getWorldTime()) { case 15000: case 16000: case 17000: case 18000: case 19000: case 20000: mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, SoundsRegistering.ambient_nightSound, SoundCategory.AMBIENT, 0.2F, 1.0F, false); break; } }
- tu n’arrives pas à quoi ?
- Impossible car tu n’appelles pas l’entité à ce moment là. Essaie plutôt un WorldTick
-
Salut
J’ai essayé (en gardant mon code) de tick le world et pas le joueur, c’est pareil. J’ai ensuite mis ton code, mais il y a eu une erreur à cette ligne :
java switch (mc.theWorld.getWorldTime())
Ca ne peut pas switch des valeurs de type long. J’ai ajouté un int pour faire ```java
switch ((int)mc.theWorld.getWorldTime())[13:27:33] [Server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.fml.common.gameevent.TickEvent$WorldTickEvent@7b87a4de:
java.lang.NullPointerException
at thisishalloween.client.ClientTickHandler.nightSound(ClientTickHandler.java:73) ~[ClientTickHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_14_ClientTickHandler_nightSound_WorldTickEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?]
at net.minecraftforge.fml.common.FMLCommonHandler.onPostWorldTick(FMLCommonHandler.java:261) [FMLCommonHandler.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:788) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) [IntegratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_92]
[13:27:33] [Server thread/ERROR] [FML]: Index: 1 Listeners:
[13:27:33] [Server thread/ERROR] [FML]: 0: NORMAL
[13:27:33] [Server thread/ERROR] [FML]: 1: ASM: thisishalloween.client.ClientTickHandler@54b7bfbe nightSound(Lnet/minecraftforge/fml/common/gameevent/TickEvent$WorldTickEvent;)V
[13:27:33] [Server thread/ERROR]: Encountered an unexpected exception
java.lang.NullPointerException
at thisishalloween.client.ClientTickHandler.nightSound(ClientTickHandler.java:73) ~[ClientTickHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_14_ClientTickHandler_nightSound_WorldTickEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) ~[EventBus.class:?]
at net.minecraftforge.fml.common.FMLCommonHandler.onPostWorldTick(FMLCommonHandler.java:261) ~[FMLCommonHandler.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:788) ~[MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) ~[IntegratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_92]
[13:27:33] [Server thread/ERROR]: This crash report has been saved to: G:\Codage\Minecraft\This_is_Halloween\v1.3\MC 1.9\run.\crash-reports\crash-2016-08-11_13.27.33-server.txt
[13:27:33] [Server thread/INFO]: Stopping server
[13:27:33] [Server thread/INFO]: Saving players
[13:27:33] [Server thread/INFO]: Saving worlds
[13:27:33] [Server thread/INFO]: Saving chunks for level ‘New World’/Overworld
[13:27:34] [Server thread/INFO]: Saving chunks for level ‘New World’/Nether
[13:27:34] [Server thread/INFO]: Saving chunks for level ‘New World’/The End
[13:27:34] [Server thread/INFO] [FML]: Unloading dimension 0
[13:27:34] [Server thread/INFO] [FML]: Unloading dimension -1
[13:27:34] [Server thread/INFO] [FML]: Unloading dimension 1
[13:27:34] [Server thread/INFO] [FML]: Applying holder lookups
[13:27:34] [Server thread/INFO] [FML]: Holder lookups applied
[13:27:34] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
[13:27:35] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:646]: –-- Minecraft Crash Report ----
// On the bright side, I bought you a teddy bear!Time: 11/08/16 13:27
Description: Exception in server tick loopjava.lang.NullPointerException: Exception in server tick loop
at thisishalloween.client.ClientTickHandler.nightSound(ClientTickHandler.java:73)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_14_ClientTickHandler_nightSound_WorldTickEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
at net.minecraftforge.fml.common.FMLCommonHandler.onPostWorldTick(FMLCommonHandler.java:261)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:788)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532)
at java.lang.Thread.run(Unknown Source)A detailed walkthrough of the error, its code path and all known details is as follows:
– System Details –
Details:
Minecraft Version: 1.9
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_92, Oracle Corporation
Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 624213848 bytes (595 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP 9.23 Powered by Forge 12.16.1.1887 4 mods loaded, 4 mods active
States: ‘U’ = Unloaded ‘L’ = Loaded ‘C’ = Constructed ‘H’ = Pre-initialized ‘I’ = Initialized ‘J’ = Post-initialized ‘A’ = Available ‘D’ = Disabled ‘E’ = Errored
UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)
UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.9-12.16.1.1887.jar)
UCHIJAAAA Forge{12.16.1.1887} [Minecraft Forge] (forgeSrc-1.9-12.16.1.1887.jar)
UCHIJAAAA This_is_Halloween{1.3} [This_is_Halloween] (bin)
Loaded coremods (and transformers):
GL info:ERRORRuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 0 / 8; []
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to ‘fml,forge’
[13:27:35] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:646]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2016-08-11_13.27.33-server.txt
[13:27:35] [Client Shutdown Thread/INFO]: Stopping server
[13:27:35] [Client Shutdown Thread/INFO]: Saving players
[13:27:35] [Client Shutdown Thread/INFO]: Saving worlds
AL lib: (EE) alc_cleanup: 1 device not closed
Java HotSpot 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future releaseEn regardant plus bas, ça parle de server. Peut-être est-ce à cause de ça. Mais c'est censé être uniquement client, c'est enregistrer dans le ClientProxy Pour ta question, je n'arrive pas à toujours respecter la convention. J'essaye de faire plus attention, mais ça ne suffit pas quelques fois.
-
Ajoutes juste un null check.
-
J’ai testé ça, j’ai testé d’autres trucs et j’ai enfin trouvé (malgré que ça soit bizarre) : la fonction n’est pas appelé côté client. Ca peut paraître bizarre, mais pourtant c’est ça.```java
@SubscribeEvent
public void nightSound(TickEvent.WorldTickEvent event)
{
if(event.world.isRemote)
{
if (event.phase == TickEvent.Phase.END)
{
System.out.println(“test”);
//if(event.world != null && event.side.isClient() && event.type.WORLD != null && event.type.CLIENT != null && event.type.PLAYER != null)
{
System.out.println(“rien n’est nul”);
Minecraft mc = FMLClientHandler.instance().getClient();switch ((int)mc.theWorld.getWorldTime())
{
case 15000:
case 16000:
case 17000:
case 18000:
case 19000:
case 20000:
mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, SoundsRegistering.ambient_nightSound, SoundCategory.AMBIENT, 0.2F, 1.0F, false);
break;
}
}
}
}
}Si j'enlève le world isRemote, ça crash. Or, si je le met ça marche bien mais il n'y a pas les messages (ce qui prouve que la fonction n'est pas appelé. Mais c'est quand même bizarre vu que la classe est enregistré dans le ClientProxy
-
Utilises alors TickEvent.ClientTickEvent
-
J’ai testé, Minecraft charge bien mais il m’affiche le menu principal une demi-seconde et crash en me précisant cette ligne : ```java
switch ((int)mc.theWorld.getWorldTime())Sinon, j'ai réessayé PlayerTickEvent et ça marche bien seulement si je met :```java if(event.side.isClient()) ```Ca ne me gène pas de l'utiliser (au contraire, si c'est pour le bon fonctionnement je suis pour) mais pourquoi c'est aussi appelé côté serveur sinon ? C'est enregistrer dans le client proxy pourtant.
-
Les events enregistrés dans le client proxy sont toujours appelés côté serveur intégré, vu que c’est le programme client, le seul endroit où ils ne sont pas appelés, c’est le serveur dédié, mais tu peux mettre un @SideOnly(Side.CLIENT) sur la fonction pour éviter ça.
Et pour le NPE, tu peux faire un null check sur mc.theWorld au lieu d’utiliser PlayerTickEvent. -
Ok merci
Je n’ai plus que deux problèmes dans le mod. Dans le blockPortal, j’utilisait
java mcServer.getConfigurationManager().transferPlayerToDimension(player, ThisisHalloween.DIMENSION_ID, new TeleporterFrightful(mcServer.worldServerForDimension(ThisisHalloween.DIMENSION_ID)));
pour me tp dans ma dimension. Mais getConfigurationManager n’existe plus. J’ai cherché et j’ai trouvé ```java
entityIn.changeDimension(ThisisHalloween.DIMENSION_ID);Encore dans le blockPortal, cette fonction```java entity1.copyDataFromOld(entity); ``` est private. Là, on n'y peut malheureusement pas grand chose, mais est-elle importante ? Elle est dans cette fonction :```java private void travelToDimension(Entity entity, int id) { if (!entity.worldObj.isRemote && !entity.isDead) { entity.worldObj.theProfiler.startSection("changeDimension"); MinecraftServer minecraftserver = entity.getServer(); int j = entity.dimension; WorldServer worldserver = minecraftserver.worldServerForDimension(j); WorldServer worldserver1 = minecraftserver.worldServerForDimension(id); entity.dimension = id; if (j == 1 && id == 1) { worldserver1 = minecraftserver.worldServerForDimension(0); entity.dimension = 0; } entity.worldObj.removeEntity(entity); entity.isDead = false; entity.worldObj.theProfiler.startSection("reposition"); //. minecraftserver.getConfigurationManager().transferEntityToWorld(entity, j, worldserver, worldserver1, new Teleporter(worldserver1)); entity.worldObj.theProfiler.endStartSection("reloading"); Entity entity1 = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1); if (entity1 != null) { // entity1.copyDataFromOld(entity); if (j == 1 && id == 1) { BlockPos spawnPoint = worldserver1.getSpawnPoint(); spawnPoint = entity.worldObj.getTopSolidOrLiquidBlock(spawnPoint); entity1.setLocationAndAngles(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), entity1.rotationYaw, entity1.rotationPitch); } worldserver1.spawnEntityInWorld(entity1); } entity.isDead = true; entity.worldObj.theProfiler.endSection(); worldserver.resetUpdateEntityTick(); worldserver1.resetUpdateEntityTick(); entity.worldObj.theProfiler.endSection(); } }
Pour le problème de la création d’un monde à l’enregistrement du WorldProvider (voir dernier post page 1), c’est de ma faute, j’ai oublier un truc.```java
@Override
public DimensionType getDimensionType()
{
return ThisisHalloween.FRIGHTFUL_DIMENSION_TYPE;
}Merci d'avance