mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
This commit is contained in:
1 parent
845c5958e0
commit
40bce4b498
9 files changed
+115
-11
No files matched your search
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/world/level/block/FungusBlock.java
|
||||
+++ b/net/minecraft/world/level/block/FungusBlock.java
|
||||
@@ -44,6 +_,8 @@
|
||||
}
|
||||
|
||||
public void m_7719_(ServerLevel p_53603_, Random p_53604_, BlockPos p_53605_, BlockState p_53606_) {
|
||||
- this.f_53597_.get().m_203334_().m_65385_(p_53603_, p_53603_.m_7726_().m_8481_(), p_53604_, p_53605_);
|
||||
+ net.minecraftforge.event.world.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_53603_, p_53604_, p_53605_, this.f_53597_.get());
|
||||
+ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY)) return;
|
||||
+ event.getFeature().m_203334_().m_65385_(p_53603_, p_53603_.m_7726_().m_8481_(), p_53604_, p_53605_);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/block/MushroomBlock.java
|
||||
+++ b/net/minecraft/world/level/block/MushroomBlock.java
|
||||
@@ -70,7 +_,7 @@
|
||||
@@ -70,13 +_,15 @@
|
||||
if (blockstate.m_204336_(BlockTags.f_13057_)) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -9,3 +9,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
public boolean m_54859_(ServerLevel p_54860_, BlockPos p_54861_, BlockState p_54862_, Random p_54863_) {
|
||||
+ net.minecraftforge.event.world.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_54860_, p_54863_, p_54861_, this.f_153981_.get());
|
||||
+ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY)) return false;
|
||||
p_54860_.m_7471_(p_54861_, false);
|
||||
- if (this.f_153981_.get().m_203334_().m_65385_(p_54860_, p_54860_.m_7726_().m_8481_(), p_54863_, p_54861_)) {
|
||||
+ if (event.getFeature().m_203334_().m_65385_(p_54860_, p_54860_.m_7726_().m_8481_(), p_54863_, p_54861_)) {
|
||||
return true;
|
||||
} else {
|
||||
p_54860_.m_7731_(p_54861_, p_54862_, 3);
|
||||
@@ -8,11 +8,3 @@
|
||||
this.m_55980_(p_56004_, p_56005_, p_56003_, p_56006_);
|
||||
}
|
||||
|
||||
@@ -41,6 +_,7 @@
|
||||
if (p_55983_.m_61143_(f_55973_) == 0) {
|
||||
p_55981_.m_7731_(p_55982_, p_55983_.m_61122_(f_55973_), 4);
|
||||
} else {
|
||||
+ if (!net.minecraftforge.event.ForgeEventFactory.saplingGrowTree(p_55981_, p_55984_, p_55982_)) return;
|
||||
this.f_55975_.m_6334_(p_55981_, p_55981_.m_7726_().m_8481_(), p_55982_, p_55983_, p_55984_);
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java
|
||||
+++ b/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java
|
||||
@@ -30,10 +_,11 @@
|
||||
|
||||
public boolean m_59990_(ServerLevel p_59991_, ChunkGenerator p_59992_, BlockPos p_59993_, BlockState p_59994_, Random p_59995_, int p_59996_, int p_59997_) {
|
||||
Holder<? extends ConfiguredFeature<?, ?>> holder = this.m_203620_(p_59995_);
|
||||
- if (holder == null) {
|
||||
+ net.minecraftforge.event.world.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_59991_, p_59995_, p_59993_, holder);
|
||||
+ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY) || holder == null) {
|
||||
return false;
|
||||
} else {
|
||||
- ConfiguredFeature<?, ?> configuredfeature = holder.m_203334_();
|
||||
+ ConfiguredFeature<?, ?> configuredfeature = event.getFeature().m_203334_();
|
||||
BlockState blockstate = Blocks.f_50016_.m_49966_();
|
||||
p_59991_.m_7731_(p_59993_.m_142082_(p_59996_, 0, p_59997_), blockstate, 4);
|
||||
p_59991_.m_7731_(p_59993_.m_142082_(p_59996_ + 1, 0, p_59997_), blockstate, 4);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/world/level/block/grower/AbstractTreeGrower.java
|
||||
+++ b/net/minecraft/world/level/block/grower/AbstractTreeGrower.java
|
||||
@@ -18,10 +_,11 @@
|
||||
|
||||
public boolean m_6334_(ServerLevel p_60006_, ChunkGenerator p_60007_, BlockPos p_60008_, BlockState p_60009_, Random p_60010_) {
|
||||
Holder<? extends ConfiguredFeature<?, ?>> holder = this.m_203525_(p_60010_, this.m_60011_(p_60006_, p_60008_));
|
||||
- if (holder == null) {
|
||||
+ net.minecraftforge.event.world.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_60006_, p_60010_, p_60008_, holder);
|
||||
+ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY) || holder == null) {
|
||||
return false;
|
||||
} else {
|
||||
- ConfiguredFeature<?, ?> configuredfeature = holder.m_203334_();
|
||||
+ ConfiguredFeature<?, ?> configuredfeature = event.getFeature().m_203334_();
|
||||
p_60006_.m_7731_(p_60008_, Blocks.f_50016_.m_49966_(), 4);
|
||||
if (configuredfeature.m_65385_(p_60006_, p_60007_, p_60010_, p_60008_)) {
|
||||
return true;
|
||||
@@ -17,6 +17,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.server.ReloadableServerResources;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.util.random.WeightedRandomList;
|
||||
@@ -26,6 +27,7 @@ import net.minecraft.world.entity.projectile.FireworkRocketEntity;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.portal.PortalShape;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
@@ -691,11 +693,20 @@ public class ForgeEventFactory
|
||||
return result == Result.DEFAULT ? level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) : result == Result.ALLOW;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ForgeEventFactory#blockGrowFeature}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.18.2")
|
||||
public static boolean saplingGrowTree(LevelAccessor level, Random rand, BlockPos pos)
|
||||
{
|
||||
SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(level, rand, pos);
|
||||
return !blockGrowFeature(level, rand, pos, null).getResult().equals(Result.DENY);
|
||||
}
|
||||
|
||||
public static SaplingGrowTreeEvent blockGrowFeature(LevelAccessor level, Random rand, BlockPos pos, Holder<? extends ConfiguredFeature<?, ?>> holder)
|
||||
{
|
||||
SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(level, rand, pos, holder);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getResult() != Result.DENY;
|
||||
return event;
|
||||
}
|
||||
|
||||
public static void fireChunkWatch(boolean watch, ServerPlayer entity, ChunkPos chunkpos, ServerLevel level)
|
||||
|
||||
@@ -8,10 +8,12 @@ package net.minecraftforge.event.world;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.SaplingBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event.HasResult;
|
||||
@@ -36,12 +38,20 @@ public class SaplingGrowTreeEvent extends WorldEvent
|
||||
{
|
||||
private final BlockPos pos;
|
||||
private final Random rand;
|
||||
private Holder<? extends ConfiguredFeature<?, ?>> feature;
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.18.2")
|
||||
public SaplingGrowTreeEvent(LevelAccessor world, Random rand, BlockPos pos)
|
||||
{
|
||||
this(world, rand, pos, null);
|
||||
}
|
||||
|
||||
public SaplingGrowTreeEvent(LevelAccessor world, Random rand, BlockPos pos, Holder<? extends ConfiguredFeature<?, ?>> feature)
|
||||
{
|
||||
super(world);
|
||||
this.rand = rand;
|
||||
this.pos = pos;
|
||||
this.feature = feature;
|
||||
}
|
||||
|
||||
public BlockPos getPos()
|
||||
@@ -53,4 +63,15 @@ public class SaplingGrowTreeEvent extends WorldEvent
|
||||
{
|
||||
return rand;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the holder of the feature which will be placed}
|
||||
*/
|
||||
public Holder<? extends ConfiguredFeature<?, ?>> getFeature() {
|
||||
return feature;
|
||||
}
|
||||
|
||||
public void setFeature(Holder<? extends ConfiguredFeature<?, ?>> feature) {
|
||||
this.feature = feature;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.minecraftforge.debug.world;
|
||||
|
||||
import net.minecraft.data.worldgen.features.TreeFeatures;
|
||||
import net.minecraftforge.event.world.SaplingGrowTreeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@Mod("block_grow_feature_test")
|
||||
@Mod.EventBusSubscriber
|
||||
public class BlockGrowFeatureTest
|
||||
{
|
||||
public static final boolean ENABLE = true;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onGrowReplaceFeature(SaplingGrowTreeEvent event)
|
||||
{
|
||||
if (ENABLE) {
|
||||
event.setFeature(TreeFeatures.BIRCH_BEES_005);
|
||||
if (event.getFeature().equals(TreeFeatures.BIRCH_BEES_005)) {
|
||||
LogManager.getLogger().info("BlockGrowFeatureTest replaced feature");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,5 +236,7 @@ license="LGPL v2.1"
|
||||
modId="dyn_map_color_test"
|
||||
[[mods]]
|
||||
modId="potentialspawnsevent_test"
|
||||
[[mods]]
|
||||
modId="block_grow_feature_test"
|
||||
|
||||
# ADD ABOVE THIS LINE
|
||||
Reference in new issue
Block a user