mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-26 23:13:15 +00:00
* Add ForgeSpawnEggItem to lazily handle EntityTypes * Remove OnlyIn * Surround EntityType#spawn() call with try/catch
37 lines
2.4 KiB
Diff
37 lines
2.4 KiB
Diff
--- a/net/minecraft/dispenser/IDispenseItemBehavior.java
|
|
+++ b/net/minecraft/dispenser/IDispenseItemBehavior.java
|
|
@@ -69,6 +_,7 @@
|
|
import net.minecraft.world.server.ServerWorld;
|
|
|
|
public interface IDispenseItemBehavior {
|
|
+ org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger();
|
|
IDispenseItemBehavior field_223216_a_ = (p_210297_0_, p_210297_1_) -> {
|
|
return p_210297_1_;
|
|
};
|
|
@@ -169,7 +_,12 @@
|
|
public ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) {
|
|
Direction direction = p_82487_1_.func_189992_e().func_177229_b(DispenserBlock.field_176441_a);
|
|
EntityType<?> entitytype = ((SpawnEggItem)p_82487_2_.func_77973_b()).func_208076_b(p_82487_2_.func_77978_p());
|
|
- entitytype.func_220331_a(p_82487_1_.func_197524_h(), p_82487_2_, (PlayerEntity)null, p_82487_1_.func_180699_d().func_177972_a(direction), SpawnReason.DISPENSER, direction != Direction.UP, false);
|
|
+ try { // FORGE: fix potential crash
|
|
+ entitytype.func_220331_a(p_82487_1_.func_197524_h(), p_82487_2_, (PlayerEntity) null, p_82487_1_.func_180699_d().func_177972_a(direction), SpawnReason.DISPENSER, direction != Direction.UP, false);
|
|
+ } catch (Exception e) {
|
|
+ LOGGER.error("Error while dispensing spawn egg from dispenser at {}", p_82487_1_.func_180699_d(), e);
|
|
+ return ItemStack.field_190927_a;
|
|
+ }
|
|
p_82487_2_.func_190918_g(1);
|
|
return p_82487_2_;
|
|
}
|
|
@@ -373,8 +_,9 @@
|
|
world.func_175656_a(blockpos, AbstractFireBlock.func_235326_a_(world, blockpos));
|
|
} else if (CampfireBlock.func_241470_h_(blockstate)) {
|
|
world.func_175656_a(blockpos, blockstate.func_206870_a(BlockStateProperties.field_208190_q, Boolean.valueOf(true)));
|
|
- } else if (blockstate.func_177230_c() instanceof TNTBlock) {
|
|
- TNTBlock.func_196534_a(world, blockpos);
|
|
+ } else if (blockstate.isFlammable(world, blockpos, p_82487_1_.func_189992_e().func_177229_b(DispenserBlock.field_176441_a).func_176734_d())) {
|
|
+ blockstate.catchFire(world, blockpos, p_82487_1_.func_189992_e().func_177229_b(DispenserBlock.field_176441_a).func_176734_d(), null);
|
|
+ if (blockstate.func_177230_c() instanceof TNTBlock)
|
|
world.func_217377_a(blockpos, false);
|
|
} else {
|
|
this.func_239796_a_(false);
|