Block patches and event work (#5138)

This commit is contained in:
Anthony Anderson authored and LexManos committed 2018-09-20 13:11:02 -07:00
1 parent b25f92b0c0
commit 0cd21ebe7e
12 files changed
+1096 -44

No files matched your search

@@ -21,8 +21,7 @@ package net.minecraftforge.event.entity;
import net.minecraft.entity.Entity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* EntityMobGriefingEvent is fired when mob griefing is about to occur and allows an event listener to specify whether it should or not.<br>
@@ -24,7 +24,6 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
@@ -38,7 +37,7 @@ import net.minecraftforge.eventbus.api.Cancelable;
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
@net.minecraftforge.eventbus.api.Cancelable
@Cancelable
public class LivingDestroyBlockEvent extends LivingEvent
{
private final BlockPos pos;
@@ -69,7 +69,7 @@ public class PlayerInteractEvent extends PlayerEvent
* Let result be the return value of {@link Entity#applyPlayerInteraction}, or {@link #cancellationResult} if the event is cancelled.
* If we are on the client and result is not {@link EnumActionResult#SUCCESS}, the client will then try {@link EntityInteract}.
*/
@net.minecraftforge.eventbus.api.Cancelable
@Cancelable
public static class EntityInteractSpecific extends PlayerInteractEvent
{
private final Vec3d localPos;
@@ -110,7 +110,7 @@ public class PlayerInteractEvent extends PlayerEvent
* or {@link #cancellationResult} if the event is cancelled.
* If we are on the client and result is not {@link EnumActionResult#SUCCESS}, the client will then try {@link RightClickItem}.
*/
@net.minecraftforge.eventbus.api.Cancelable
@Cancelable
public static class EntityInteract extends PlayerInteractEvent
{
private final Entity target;
@@ -248,7 +248,7 @@ public class PlayerInteractEvent extends PlayerEvent
* Also note that creative mode directly breaks the block without running any other logic.
* Therefore, in creative mode, {@link #setUseBlock} and {@link #setUseItem} have no effect.
*/
@net.minecraftforge.eventbus.api.Cancelable
@Cancelable
public static class LeftClickBlock extends PlayerInteractEvent
{
private Result useBlock = DEFAULT;
@@ -369,11 +369,11 @@ public class PlayerInteractEvent extends PlayerEvent
}
/**
* @return The effective, i.e. logical, side of this interaction. This will be {@link Side#CLIENT} on the client thread, and {@link Side#SERVER} on the server thread.
* @return The effective, i.e. logical, side of this interaction. This will be {@link Dist#CLIENT} on the client thread, and {@link Dist#DEDICATED_SERVER} on the server thread.
*/
public Side getSide()
public Dist getSide()
{
return getWorld().isRemote ? Side.CLIENT : Side.SERVER;
return getWorld().isRemote ? Dist.CLIENT : Dist.DEDICATED_SERVER;
}
/**
@@ -24,7 +24,6 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
@@ -34,7 +33,7 @@ import net.minecraftforge.eventbus.api.Event.HasResult;
* This event has a result. {@link HasResult}<br>
*
* setResult(ALLOW) informs game that player is still "in bed"<br>
* setResult(DEFAULT) causes game to check {@link Block#isBed(IBlockState, IBlockAccess, BlockPos, Entity)} instead
* setResult(DEFAULT) causes game to check {@link Block#isBed(IBlockState, net.minecraft.world.IWorldReader, BlockPos, Entity)} instead
*/
@HasResult
public class SleepingLocationCheckEvent extends PlayerEvent
@@ -22,7 +22,7 @@ package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* This event is fired when the game checks if players can sleep at this time.<br>
@@ -24,7 +24,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;
import javax.annotation.Nonnull;
@@ -38,7 +38,7 @@ import javax.annotation.Nonnull;
* setResult(ALLOW) is the same as the old setHandled();
*/
@Cancelable
@net.minecraftforge.eventbus.api.Event.HasResult
@HasResult
public class UseHoeEvent extends PlayerEvent
{
@@ -21,14 +21,14 @@ package net.minecraftforge.event.terraingen;
import java.util.Random;
import net.minecraft.world.biome.BiomeDecorator;
//import net.minecraft.world.biome.BiomeDecorator;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
//import net.minecraft.world.gen.feature.WorldGenerator;
/**
* OreGenEvent is fired when an event involving ore generation occurs.<br>
@@ -122,6 +122,7 @@ public class OreGenEvent extends Event
* <br>
* This event is fired on the {@link MinecraftForge#ORE_GEN_BUS}.<br>
**/
/* TODO Re-Evaluate
@HasResult
public static class GenerateMinable extends OreGenEvent
{
@@ -147,4 +148,6 @@ public class OreGenEvent extends Event
return generator;
}
}
*/
}
@@ -25,11 +25,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.MapGenBase;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate;
import net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable;
//import net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable;
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate;
import net.minecraftforge.eventbus.api.Event.Result;
@@ -42,12 +40,14 @@ public abstract class TerrainGen
return event.getNewValues();
}
/* TODO Re-Evaluate
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
InitMapGenEvent event = new InitMapGenEvent(type, original);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.getNewGen();
}
*/
public static boolean populate(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type)
{
@@ -95,12 +95,14 @@ public abstract class TerrainGen
return decorate(world, rand, new ChunkPos(pos), type);
}
/* TODO Re-Evaluate
public static boolean generateOre(World world, Random rand, WorldGenerator generator, BlockPos pos, GenerateMinable.EventType type)
{
GenerateMinable event = new GenerateMinable(world, rand, generator, pos, type);
MinecraftForge.ORE_GEN_BUS.post(event);
return event.getResult() != Result.DENY;
}
*/
public static boolean saplingGrowTree(World world, Random rand, BlockPos pos)
{
@@ -19,7 +19,6 @@
package net.minecraftforge.event.terraingen;
import net.minecraft.world.biome.BiomeProvider;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
@@ -35,7 +34,7 @@ import net.minecraft.world.WorldType;
* <br>
* All children of this event are fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.<br>
**/
public class WorldTypeEvent extends net.minecraftforge.eventbus.api.Event
public class WorldTypeEvent extends Event
{
private final WorldType worldType;
@@ -19,14 +19,8 @@
package net.minecraftforge.event.world;
import net.minecraft.server.management.PlayerChunkMapEntry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
/**
@@ -36,38 +30,33 @@ import net.minecraft.world.chunk.Chunk;
* <br>
* {@link #chunk} contains the ChunkPos of the Chunk this event is affecting.<br>
* {@link #player} contains the EntityPlayer that is involved with this chunk being watched. <br>
* {@link #chunkInstance} contains the instance of the Chunk. <br>
* <br>
* The {@link #player}'s world may not be the same as the world of the chunk
* when the player is teleporting to another dimension.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public class ChunkWatchEvent extends Event //TODO: extend ChunkEvent in 1.13
public class ChunkWatchEvent extends ChunkEvent
{
private final EntityPlayerMP player;
private final Chunk chunkInstance;
private final ChunkPos pos;
public ChunkWatchEvent(Chunk chunk, EntityPlayerMP player)
{
this.chunk = chunk.getPos();
super(chunk);
this.player = player;
this.chunkInstance = chunk;
this.pos = chunk.getPos();
}
public EntityPlayerMP getPlayer()
{
return player;
return this.player;
}
/**
* The affected chunk.
* @return The affected chunk.
*/
@Nullable
public Chunk getChunkInstance()
public ChunkPos getPos()
{
return chunkInstance;
return this.pos;
}
/**
@@ -83,7 +72,7 @@ public class ChunkWatchEvent extends Event //TODO: extend ChunkEvent in 1.13
**/
public static class Watch extends ChunkWatchEvent
{
public Watch(Chunk chunk, EntityPlayerMP player) { super(chunk, player); }
public Watch(Chunk chunk, EntityPlayerMP player) {super(chunk, player);}
}
/**
@@ -99,6 +88,6 @@ public class ChunkWatchEvent extends Event //TODO: extend ChunkEvent in 1.13
**/
public static class UnWatch extends ChunkWatchEvent
{
public UnWatch(Chunk chunk, EntityPlayerMP player) { super(chunk, player); }
public UnWatch(Chunk chunk, EntityPlayerMP player) {super(chunk, player);}
}
}