mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Remove custom fake player in favor of vanilla one, stopped using fake player for worldgen.
This commit is contained in:
parent
9c16eef80e
commit
144e8e4d0a
5 changed files with 10 additions and 56 deletions
|
@ -42,7 +42,6 @@ import de.ellpeck.actuallyadditions.mod.recipe.HairyBallHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.recipe.TreasureChestHandler;
|
import de.ellpeck.actuallyadditions.mod.recipe.TreasureChestHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
|
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.FakePlayerUtil;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
@ -130,7 +129,6 @@ public class ActuallyAdditions{
|
||||||
proxy.postInit(event);
|
proxy.postInit(event);
|
||||||
|
|
||||||
ModUtil.LOGGER.info("PostInitialization Finished.");
|
ModUtil.LOGGER.info("PostInitialization Finished.");
|
||||||
FakePlayerUtil.info();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.event;
|
package de.ellpeck.actuallyadditions.mod.event;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.data.WorldData;
|
import de.ellpeck.actuallyadditions.mod.data.WorldData;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.FakePlayerUtil;
|
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
@ -25,7 +24,6 @@ public class WorldLoadingEvents{
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onUnload(WorldEvent.Unload event){
|
public void onUnload(WorldEvent.Unload event){
|
||||||
WorldData.unload(event.getWorld());
|
WorldData.unload(event.getWorld());
|
||||||
FakePlayerUtil.unloadFakePlayer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -60,12 +60,13 @@ public class WorldGenLushCaves extends WorldGenerator{
|
||||||
if(!possiblePoses.isEmpty()){
|
if(!possiblePoses.isEmpty()){
|
||||||
for(int i = 0; i <= amount; i++){
|
for(int i = 0; i <= amount; i++){
|
||||||
Collections.shuffle(possiblePoses);
|
Collections.shuffle(possiblePoses);
|
||||||
|
BlockPos pos = possiblePoses.get(0);
|
||||||
if(rand.nextBoolean()){
|
if(rand.nextBoolean()){
|
||||||
WorldGenAbstractTree trees = rand.nextBoolean() ? (rand.nextBoolean() ? new WorldGenBigTree(false) : new WorldGenShrub(Blocks.LOG.getDefaultState(), Blocks.LEAVES.getDefaultState())) : new WorldGenTrees(false);
|
WorldGenAbstractTree trees = rand.nextBoolean() ? (rand.nextBoolean() ? new WorldGenBigTree(false) : new WorldGenShrub(Blocks.LOG.getDefaultState(), Blocks.LEAVES.getDefaultState())) : new WorldGenTrees(false);
|
||||||
trees.generate(world, rand, possiblePoses.get(0).up());
|
trees.generate(world, rand, pos.up());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ItemDye.applyBonemeal(new ItemStack(Items.DYE, 1, EnumDyeColor.WHITE.getDyeDamage()), world, possiblePoses.get(0));
|
Blocks.GRASS.grow(world, rand, pos, world.getBlockState(pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* This file ("FakePlayerUtil.java") is part of the Actually Additions mod for Minecraft.
|
|
||||||
* It is created and owned by Ellpeck and distributed
|
|
||||||
* under the Actually Additions License to be found at
|
|
||||||
* http://ellpeck.de/actaddlicense
|
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
||||||
*
|
|
||||||
* © 2015-2016 Ellpeck
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.util;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public final class FakePlayerUtil{
|
|
||||||
|
|
||||||
private static final String FAKE_NAME = ModUtil.MOD_ID+"fakeplayer";
|
|
||||||
private static final GameProfile FAKE_PROFILE = new GameProfile(UUID.nameUUIDFromBytes(FAKE_NAME.getBytes()), FAKE_NAME);
|
|
||||||
private static FakePlayer theFakePlayer;
|
|
||||||
|
|
||||||
public static void info(){
|
|
||||||
ModUtil.LOGGER.info(ModUtil.NAME+"' Fake Player: '"+FAKE_PROFILE.getName()+"', UUID: "+FAKE_PROFILE.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FakePlayer getFakePlayer(World world){
|
|
||||||
if(world instanceof WorldServer){
|
|
||||||
if(theFakePlayer == null){
|
|
||||||
theFakePlayer = FakePlayerFactory.get((WorldServer)world, FAKE_PROFILE);
|
|
||||||
}
|
|
||||||
return theFakePlayer;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void unloadFakePlayer(){
|
|
||||||
theFakePlayer = null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -41,6 +41,8 @@ import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
import net.minecraftforge.fluids.IFluidBlock;
|
||||||
|
@ -167,7 +169,6 @@ public final class WorldUtil{
|
||||||
//Fluids
|
//Fluids
|
||||||
if(replaceable && !(block instanceof IFluidBlock) && !(block instanceof BlockLiquid)){
|
if(replaceable && !(block instanceof IFluidBlock) && !(block instanceof BlockLiquid)){
|
||||||
FluidStack fluid = null;
|
FluidStack fluid = null;
|
||||||
//TODO Remove when FluidContainerRegistry is gone
|
|
||||||
if(FluidContainerRegistry.isFilledContainer(stack)){
|
if(FluidContainerRegistry.isFilledContainer(stack)){
|
||||||
fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||||
}
|
}
|
||||||
|
@ -201,10 +202,12 @@ public final class WorldUtil{
|
||||||
|
|
||||||
//Everything else
|
//Everything else
|
||||||
try{
|
try{
|
||||||
EntityPlayer fake = FakePlayerUtil.getFakePlayer(world);
|
if(world instanceof WorldServer){
|
||||||
|
FakePlayer fake = FakePlayerFactory.getMinecraft((WorldServer)world);
|
||||||
stack.onItemUse(fake, world, offsetPos, fake.getActiveHand(), side.getOpposite(), 0.5F, 0.5F, 0.5F);
|
stack.onItemUse(fake, world, offsetPos, fake.getActiveHand(), side.getOpposite(), 0.5F, 0.5F, 0.5F);
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(Exception e){
|
catch(Exception e){
|
||||||
ModUtil.LOGGER.error("Something that places Blocks at "+offsetPos.getX()+", "+offsetPos.getY()+", "+offsetPos.getZ()+" in World "+world.provider.getDimension()+" threw an Exception! Don't let that happen again!", e);
|
ModUtil.LOGGER.error("Something that places Blocks at "+offsetPos.getX()+", "+offsetPos.getY()+", "+offsetPos.getZ()+" in World "+world.provider.getDimension()+" threw an Exception! Don't let that happen again!", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue