Merge branch 'mc-1.14.x' into mc-1.15.x
This commit is contained in:
commit
8f3a56dd32
|
@ -1,5 +1,5 @@
|
||||||
# Mod properties
|
# Mod properties
|
||||||
mod_version=1.89.1
|
mod_version=1.89.2
|
||||||
|
|
||||||
# Minecraft properties (update mods.toml when changing)
|
# Minecraft properties (update mods.toml when changing)
|
||||||
mc_version=1.15.2
|
mc_version=1.15.2
|
||||||
|
|
|
@ -13,13 +13,12 @@
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@ -32,16 +31,16 @@ private DropConsumer()
|
||||||
|
|
||||||
private static Function<ItemStack, ItemStack> dropConsumer;
|
private static Function<ItemStack, ItemStack> dropConsumer;
|
||||||
private static List<ItemStack> remainingDrops;
|
private static List<ItemStack> remainingDrops;
|
||||||
private static WeakReference<World> dropWorld;
|
private static World dropWorld;
|
||||||
private static AxisAlignedBB dropBounds;
|
private static AxisAlignedBB dropBounds;
|
||||||
private static WeakReference<Entity> dropEntity;
|
private static Entity dropEntity;
|
||||||
|
|
||||||
public static void set( Entity entity, Function<ItemStack, ItemStack> consumer )
|
public static void set( Entity entity, Function<ItemStack, ItemStack> consumer )
|
||||||
{
|
{
|
||||||
dropConsumer = consumer;
|
dropConsumer = consumer;
|
||||||
remainingDrops = new ArrayList<>();
|
remainingDrops = new ArrayList<>();
|
||||||
dropEntity = new WeakReference<>( entity );
|
dropEntity = entity;
|
||||||
dropWorld = new WeakReference<>( entity.world );
|
dropWorld = entity.world;
|
||||||
dropBounds = new AxisAlignedBB( entity.getPosition() ).grow( 2, 2, 2 );
|
dropBounds = new AxisAlignedBB( entity.getPosition() ).grow( 2, 2, 2 );
|
||||||
|
|
||||||
entity.captureDrops( new ArrayList<>() );
|
entity.captureDrops( new ArrayList<>() );
|
||||||
|
@ -52,25 +51,12 @@ public static void set( World world, BlockPos pos, Function<ItemStack, ItemStack
|
||||||
dropConsumer = consumer;
|
dropConsumer = consumer;
|
||||||
remainingDrops = new ArrayList<>( 2 );
|
remainingDrops = new ArrayList<>( 2 );
|
||||||
dropEntity = null;
|
dropEntity = null;
|
||||||
dropWorld = new WeakReference<>( world );
|
dropWorld = world;
|
||||||
dropBounds = new AxisAlignedBB( pos ).grow( 2, 2, 2 );
|
dropBounds = new AxisAlignedBB( pos ).grow( 2, 2, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemStack> clear()
|
public static List<ItemStack> clear()
|
||||||
{
|
{
|
||||||
if( dropEntity != null )
|
|
||||||
{
|
|
||||||
Entity entity = dropEntity.get();
|
|
||||||
if( entity != null )
|
|
||||||
{
|
|
||||||
Collection<ItemEntity> dropped = entity.captureDrops( null );
|
|
||||||
if( dropped != null )
|
|
||||||
{
|
|
||||||
for( ItemEntity entityItem : dropped ) handleDrops( entityItem.getItem() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ItemStack> remainingStacks = remainingDrops;
|
List<ItemStack> remainingStacks = remainingDrops;
|
||||||
|
|
||||||
dropConsumer = null;
|
dropConsumer = null;
|
||||||
|
@ -92,11 +78,20 @@ private static void handleDrops( ItemStack stack )
|
||||||
public static void onEntitySpawn( EntityJoinWorldEvent event )
|
public static void onEntitySpawn( EntityJoinWorldEvent event )
|
||||||
{
|
{
|
||||||
// Capture any nearby item spawns
|
// Capture any nearby item spawns
|
||||||
if( dropWorld != null && dropWorld.get() == event.getWorld() && event.getEntity() instanceof ItemEntity
|
if( dropWorld == event.getWorld() && event.getEntity() instanceof ItemEntity
|
||||||
&& dropBounds.contains( event.getEntity().getPositionVector() ) )
|
&& dropBounds.contains( event.getEntity().getPositionVector() ) )
|
||||||
{
|
{
|
||||||
handleDrops( ((ItemEntity) event.getEntity()).getItem() );
|
handleDrops( ((ItemEntity) event.getEntity()).getItem() );
|
||||||
event.setCanceled( true );
|
event.setCanceled( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onLivingDrops( LivingDropsEvent drops )
|
||||||
|
{
|
||||||
|
if( dropEntity == null || drops.getEntity() != dropEntity ) return;
|
||||||
|
|
||||||
|
for( ItemEntity drop : drops.getDrops() ) handleDrops( drop.getItem() );
|
||||||
|
drops.setCanceled( true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# New features in CC: Tweaked 1.89.2
|
||||||
|
|
||||||
|
* Fix dupe bug when killing an entity with a turtle.
|
||||||
|
|
||||||
# New features in CC: Tweaked 1.89.1
|
# New features in CC: Tweaked 1.89.1
|
||||||
|
|
||||||
* Fix crashes when rendering monitors of varying sizes.
|
* Fix crashes when rendering monitors of varying sizes.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
New features in CC: Tweaked 1.89.1
|
New features in CC: Tweaked 1.89.2
|
||||||
|
|
||||||
* Fix crashes when rendering monitors of varying sizes.
|
* Fix dupe bug when killing an entity with a turtle.
|
||||||
|
|
||||||
Type "help changelog" to see the full version history.
|
Type "help changelog" to see the full version history.
|
||||||
|
|
Loading…
Reference in New Issue