Skip to content

Commit

Permalink
Fix some patch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Nov 3, 2023
1 parent 4496d36 commit e03e826
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
9 changes: 5 additions & 4 deletions patches/minecraft/net/minecraft/block/SaplingBlock.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import java.util.Random;
import net.minecraft.block.trees.Tree;
import net.minecraft.state.IntegerProperty;
@@ -11,11 +_,15 @@
@@ -11,11 +_,16 @@
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.TreeType;
+import org.bukkit.event.world.StructureGrowEvent;
Expand All @@ -29,15 +30,15 @@

public void func_225542_b_(BlockState p_225542_1_, ServerWorld p_225542_2_, BlockPos p_225542_3_, Random p_225542_4_) {
- if (p_225542_2_.func_201696_r(p_225542_3_.func_177984_a()) >= 9 && p_225542_4_.nextInt(7) == 0) {
+ if (p_225542_2_.func_201696_r(p_225542_3_.func_177984_a()) >= 9 && p_225542_4_.nextInt(Math.max(2, (int) (((100.0F / p_225542_2_.spigotConfig.saplingModifier) * 7) + 0.5F))) == 0) { // Spigot
+ if (p_225542_2_.func_201696_r(p_225542_3_.func_177984_a()) >= 9 && p_225542_4_.nextFloat() < (100.0F / p_225542_2_.spigotConfig.saplingModifier / (100.0f * 7))) { // Spigot
+ if (!p_225542_2_.isAreaLoaded(p_225542_3_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light
+ // CraftBukkit start
+ p_225542_2_.captureTreeGeneration = true;
+ // CraftBukkit end
this.func_226942_a_(p_225542_2_, p_225542_3_, p_225542_1_, p_225542_4_);
+ // CraftBukkit start
+ p_225542_2_.captureTreeGeneration = false;
+ if(p_225542_2_.capturedBlockStates.size() > 0){
+ if(!p_225542_2_.capturedBlockStates.isEmpty()){
+ TreeType treeType = SaplingBlock.treeType;
+ SaplingBlock.treeType = null;
+ Location location = new Location(p_225542_2_.getWorld(), p_225542_3_.func_177958_n(), p_225542_3_.func_177956_o(), p_225542_3_.func_177952_p());
Expand All @@ -46,7 +47,7 @@
+ StructureGrowEvent event = null;
+ if(treeType != null){
+ event = new StructureGrowEvent(location, treeType, false, null, blocks);
+ p_225542_2_.getCBServer().getPluginManager().callEvent(event);
+ Bukkit.getPluginManager().callEvent(event);
+ }
+ if(event == null || !event.isCancelled()){
+ for (org.bukkit.block.BlockState block : blocks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.IEquipable;
@@ -67,8 +_,15 @@
@@ -67,8 +_,17 @@
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.TreeType;
+import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.v1_16_R3.util.DummyGeneratorAccess;
+import org.bukkit.event.block.BlockDispenseEvent;
+import org.bukkit.event.block.BlockFertilizeEvent;
+import org.bukkit.event.world.StructureGrowEvent;

public interface IDispenseItemBehavior {
Expand Down Expand Up @@ -142,11 +144,11 @@
+ IDispenseItemBehavior idispensebehavior = (IDispenseItemBehavior) DispenserBlock.field_149943_a.get(eventStack.func_77973_b());
+ if (idispensebehavior != IDispenseItemBehavior.field_223216_a_ && idispensebehavior != this) {
+ idispensebehavior.dispense(p_82487_1_, eventStack);
+ return itemstack1;
+ return p_82487_2_;
+ }
+ }
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
+ FireworkRocketEntity fireworkrocketentity = new FireworkRocketEntity(p_82487_1_.func_197524_h(), itemstack1, p_82487_1_.func_82615_a(), p_82487_1_.func_82617_b(), p_82487_1_.func_82615_a(), true); // Paper - GH-2871 - fix last firework in stack having no effects when dispensed
+ FireworkRocketEntity fireworkrocketentity = new FireworkRocketEntity(p_82487_1_.func_197524_h(), p_82487_2_, p_82487_1_.func_82615_a(), p_82487_1_.func_82617_b(), p_82487_1_.func_82615_a(), true); // Paper - GH-2871 - fix last firework in stack having no effects when dispensed
IDispenseItemBehavior.func_239785_a_(p_82487_1_, fireworkrocketentity, direction);
fireworkrocketentity.func_70186_c((double)direction.func_82601_c(), (double)direction.func_96559_d(), (double)direction.func_82599_e(), 0.5F, 1.0F);
p_82487_1_.func_197524_h().func_217376_c(fireworkrocketentity);
Expand Down Expand Up @@ -261,7 +263,7 @@
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(p_82487_2_);
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.func_177958_n(), blockpos.func_177956_o(), blockpos.func_177952_p()));
+ if (!DispenserBlock.eventFired) {
+ ((World) iworld).getCBServer().getPluginManager().callEvent(event);
+ Bukkit.getPluginManager().callEvent(event);
+ }
+ if (event.isCancelled()) {
+ return p_82487_2_;
Expand Down Expand Up @@ -328,7 +330,7 @@
world.func_217377_a(blockpos, false);
} else {
this.func_239796_a_(false);
@@ -392,12 +_,54 @@
@@ -392,12 +_,59 @@
this.func_239796_a_(true);
World world = p_82487_1_.func_197524_h();
BlockPos blockpos = p_82487_1_.func_180699_d().func_177972_a(p_82487_1_.func_189992_e().func_177229_b(DispenserBlock.field_176441_a));
Expand Down Expand Up @@ -361,7 +363,7 @@

+ // CraftBukkit start
+ world.captureTreeGeneration = false;
+ if (world.capturedBlockStates.size() > 0) {
+ if (!world.capturedBlockStates.isEmpty()) { // Mohist
+ TreeType treeType = SaplingBlock.treeType;
+ SaplingBlock.treeType = null;
+ Location location = new Location(world.getWorld(), blockpos.func_177958_n(), blockpos.func_177956_o(), blockpos.func_177952_p());
Expand All @@ -372,7 +374,12 @@
+ structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks);
+ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent);
+ }
+ if (structureEvent == null || !structureEvent.isCancelled()) {
+
+ BlockFertilizeEvent fertilizeEvent = new BlockFertilizeEvent(location.getBlock(), null, blocks);
+ fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled());
+ org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent);
+
+ if (!fertilizeEvent.isCancelled()) {
+ for (org.bukkit.block.BlockState blockstate : blocks) {
+ blockstate.update(true);
+ }
Expand Down
2 changes: 1 addition & 1 deletion patches/minecraft/net/minecraft/world/World.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
+
+ // CraftBukkit start Added the following
+ private RegistryKey<DimensionType> typeKey;
+ public CraftWorld craftWorld;//Mohist - compat for Forge
+ public CraftWorld craftWorld; //Mohist - compat for Forge
+ public boolean pvpMode;
+ public boolean keepSpawnInMemory = true;
+ public static org.bukkit.generator.ChunkGenerator generator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.mohistmc.bukkit.pluginfix.fix;
package com.mohistmc.bukkit.pluginfix;

import com.mohistmc.bukkit.nms.utils.RemapUtils;
import org.objectweb.asm.ClassReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package com.mohistmc.bukkit.pluginfix;

import com.mohistmc.bukkit.pluginfix.fix.DynmapFix;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Type;
Expand Down

0 comments on commit e03e826

Please sign in to comment.