This commit is contained in:
Ben Kerllenevich
2021-06-17 10:18:32 -04:00
parent d9a75665da
commit 90faff263b
11 changed files with 327 additions and 358 deletions

View File

@@ -1,39 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: draycia <lonelyyordle@gmail.com>
Date: Tue, 31 Mar 2020 23:48:55 -0700
Subject: [PATCH] Configurable villager breeding
diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
index aaf8d2cd3089adba69c873c4ea62b0e8837b21d6..2ff9dffc0f0b20582f5b3bffd01743ee26c63c20 100644
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
@@ -712,7 +712,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
@Override
public boolean canBreed() {
- return this.bx + this.fv() >= 12 && this.getAge() == 0;
+ return world.purpurConfig.villagerCanBreed && this.bx + this.fv() >= 12 && this.getAge() == 0; // Purpur
}
private boolean fr() {
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 201974ec4db915e5a79ed36625f0870a7ff84207..db5638c4f2b6d672e619c9ba44184b6d9fe113a1 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -517,6 +517,7 @@ public class PurpurWorldConfig {
public boolean villagerFollowEmeraldBlock = false;
public int villagerSpawnIronGolemRadius = 0;
public int villagerSpawnIronGolemLimit = 0;
+ public boolean villagerCanBreed = true;
private void villagerSettings() {
villagerBrainTicks = getInt("mobs.villager.brain-ticks", villagerBrainTicks);
villagerUseBrainTicksOnlyWhenLagging = getBoolean("mobs.villager.use-brain-ticks-only-when-lagging", villagerUseBrainTicksOnlyWhenLagging);
@@ -525,6 +526,7 @@ public class PurpurWorldConfig {
villagerFollowEmeraldBlock = getBoolean("mobs.villager.follow-emerald-blocks", villagerFollowEmeraldBlock);
villagerSpawnIronGolemRadius = getInt("mobs.villager.spawn-iron-golem.radius", villagerSpawnIronGolemRadius);
villagerSpawnIronGolemLimit = getInt("mobs.villager.spawn-iron-golem.limit", villagerSpawnIronGolemLimit);
+ villagerCanBreed = getBoolean("mobs.villager.can-breed", villagerCanBreed);
}
public boolean villagerTraderCanBeLeashed = false;

View File

@@ -1,43 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: draycia <lonelyyordle@gmail.com>
Date: Tue, 14 Apr 2020 00:35:12 -0700
Subject: [PATCH] Redstone deactivates spawners
diff --git a/src/main/java/net/minecraft/world/level/MobSpawnerAbstract.java b/src/main/java/net/minecraft/world/level/MobSpawnerAbstract.java
index 33a5dbcc11455f81088d9fd685a8c4b1b8f4b1f2..b65609bab36650c46e9dabdd25a139ae2af9d83a 100644
--- a/src/main/java/net/minecraft/world/level/MobSpawnerAbstract.java
+++ b/src/main/java/net/minecraft/world/level/MobSpawnerAbstract.java
@@ -69,6 +69,7 @@ public abstract class MobSpawnerAbstract {
private boolean h() {
BlockPosition blockposition = this.b();
+ if (getWorld().purpurConfig.spawnerDeactivateByRedstone && getWorld().isBlockIndirectlyPowered(blockposition)) { return false; } // Purpur
return this.a().isAffectsSpawningPlayerNearby((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, (double) this.requiredPlayerRange); // Paper
}
@@ -348,7 +349,7 @@ public abstract class MobSpawnerAbstract {
public abstract void a(int i);
- public abstract World a();
+ public abstract World a(); public World getWorld() { return a(); } // Purpur - OBFHELPER
public abstract BlockPosition b();
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index db5638c4f2b6d672e619c9ba44184b6d9fe113a1..a36b9ea779fd984a16332e66f122d9505fad67de 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -330,6 +330,11 @@ public class PurpurWorldConfig {
signRightClickEdit = getBoolean("blocks.sign.right-click-edit", signRightClickEdit);
}
+ public boolean spawnerDeactivateByRedstone = false;
+ private void spawnerSettings() {
+ spawnerDeactivateByRedstone = getBoolean("blocks.spawner.deactivate-by-redstone", spawnerDeactivateByRedstone);
+ }
+
public boolean turtleEggsBreakFromExpOrbs = true;
public boolean turtleEggsBreakFromItems = true;
public boolean turtleEggsBreakFromMinecarts = true;

View File

@@ -1,47 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Fri, 24 Jul 2020 19:38:21 -0500
Subject: [PATCH] Add vindicator johnny spawn chance
diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityVindicator.java b/src/main/java/net/minecraft/world/entity/monster/EntityVindicator.java
index f0eda0b83bab8e3a8adbb569b5997402b0e08e9a..fe84d6d2b74b6ae00c4c66682107296a40b69adc 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EntityVindicator.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityVindicator.java
@@ -6,6 +6,7 @@ import java.util.Map;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.chat.ChatMessage;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.server.level.WorldServer;
import net.minecraft.sounds.SoundEffect;
@@ -122,6 +123,12 @@ public class EntityVindicator extends EntityIllagerAbstract {
((Navigation) this.getNavigation()).a(true);
this.a(difficultydamagescaler);
this.b(difficultydamagescaler);
+ // Purpur start
+ World world = worldaccess.getMinecraftWorld();
+ if (world.purpurConfig.vindicatorJohnnySpawnChance > 0D && random.nextDouble() <= world.purpurConfig.vindicatorJohnnySpawnChance) {
+ setCustomName(new ChatMessage("Johnny"));
+ }
+ // Purpur end
return groupdataentity1;
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index ad4da617cf718e1c03e1532a9b45d7f927539a14..b328c9f69fd43ca7ed57ee7f5b46ca998f2cb672 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -40,6 +40,11 @@ public class PurpurWorldConfig {
}
}
+ public double vindicatorJohnnySpawnChance = 0D;
+ private void vindicatorSettings() {
+ vindicatorJohnnySpawnChance = getDouble("mobs.vindicator.johnny.spawn-chance", vindicatorJohnnySpawnChance);
+ }
+
private ConfigurationSection getConfigurationSection(String path) {
ConfigurationSection section = PurpurConfig.config.getConfigurationSection("world-settings." + worldName + "." + path);
return section != null ? section : PurpurConfig.config.getConfigurationSection("world-settings.default." + path);

View File

@@ -1,132 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Tue, 4 Aug 2020 17:11:58 -0500
Subject: [PATCH] Add option to disable certain block updates
diff --git a/src/main/java/net/minecraft/world/level/block/BlockChorusFruit.java b/src/main/java/net/minecraft/world/level/block/BlockChorusFruit.java
index 42a5345d569661726742a7ca53c2eb09f79a1958..248777af038bcbb20399d2aa24a42e77f8b8a9ba 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockChorusFruit.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockChorusFruit.java
@@ -24,6 +24,7 @@ public class BlockChorusFruit extends BlockSprawling {
@Override
public IBlockData getPlacedState(BlockActionContext blockactioncontext) {
+ if (net.pl3x.purpur.PurpurConfig.disableChorusPlantUpdates) return this.getBlockData(); // Purpur
return this.a((IBlockAccess) blockactioncontext.getWorld(), blockactioncontext.getClickPosition());
}
@@ -40,6 +41,7 @@ public class BlockChorusFruit extends BlockSprawling {
@Override
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
+ if (net.pl3x.purpur.PurpurConfig.disableChorusPlantUpdates) return iblockdata; // Purpur
if (!iblockdata.canPlace(generatoraccess, blockposition)) {
generatoraccess.getBlockTickList().a(blockposition, this, 1);
return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
diff --git a/src/main/java/net/minecraft/world/level/block/BlockHugeMushroom.java b/src/main/java/net/minecraft/world/level/block/BlockHugeMushroom.java
index 987301bfb9d963e3bebc2653bd95cf7f17a2a1e4..fd61c18905e81b1b193260f1c32b4ad0e29be227 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockHugeMushroom.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockHugeMushroom.java
@@ -24,30 +24,57 @@ public class BlockHugeMushroom extends Block {
public BlockHugeMushroom(BlockBase.Info blockbase_info) {
super(blockbase_info);
- this.j((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.blockStateList.getBlockData()).set(BlockHugeMushroom.a, true)).set(BlockHugeMushroom.b, true)).set(BlockHugeMushroom.c, true)).set(BlockHugeMushroom.d, true)).set(BlockHugeMushroom.e, true)).set(BlockHugeMushroom.f, true));
+ this.j(this.blockStateList.getBlockData()
+ .set(BlockHugeMushroom.a, true)
+ .set(BlockHugeMushroom.b, true)
+ .set(BlockHugeMushroom.c, true)
+ .set(BlockHugeMushroom.d, true)
+ .set(BlockHugeMushroom.e, true)
+ .set(BlockHugeMushroom.f, true));
}
@Override
public IBlockData getPlacedState(BlockActionContext blockactioncontext) {
World world = blockactioncontext.getWorld();
+ if (net.pl3x.purpur.PurpurConfig.disableMushroomBlockUpdates) return this.getBlockData();
BlockPosition blockposition = blockactioncontext.getClickPosition();
-
- return (IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockHugeMushroom.f, this != world.getType(blockposition.down()).getBlock())).set(BlockHugeMushroom.e, this != world.getType(blockposition.up()).getBlock())).set(BlockHugeMushroom.a, this != world.getType(blockposition.north()).getBlock())).set(BlockHugeMushroom.b, this != world.getType(blockposition.east()).getBlock())).set(BlockHugeMushroom.c, this != world.getType(blockposition.south()).getBlock())).set(BlockHugeMushroom.d, this != world.getType(blockposition.west()).getBlock());
+ return this.getBlockData()
+ .set(BlockHugeMushroom.f, this != world.getType(blockposition.down()).getBlock())
+ .set(BlockHugeMushroom.e, this != world.getType(blockposition.up()).getBlock())
+ .set(BlockHugeMushroom.a, this != world.getType(blockposition.north()).getBlock())
+ .set(BlockHugeMushroom.b, this != world.getType(blockposition.east()).getBlock())
+ .set(BlockHugeMushroom.c, this != world.getType(blockposition.south()).getBlock())
+ .set(BlockHugeMushroom.d, this != world.getType(blockposition.west()).getBlock());
}
@Override
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
- return iblockdata1.a((Block) this) ? (IBlockData) iblockdata.set((IBlockState) BlockHugeMushroom.g.get(enumdirection), false) : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
+ if (net.pl3x.purpur.PurpurConfig.disableMushroomBlockUpdates) return iblockdata;
+ return iblockdata1.a(this) ? iblockdata.set(BlockHugeMushroom.g.get(enumdirection), false) : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
}
@Override
public IBlockData a(IBlockData iblockdata, EnumBlockRotation enumblockrotation) {
- return (IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) iblockdata.set((IBlockState) BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.NORTH)), iblockdata.get(BlockHugeMushroom.a))).set((IBlockState) BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.SOUTH)), iblockdata.get(BlockHugeMushroom.c))).set((IBlockState) BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.EAST)), iblockdata.get(BlockHugeMushroom.b))).set((IBlockState) BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.WEST)), iblockdata.get(BlockHugeMushroom.d))).set((IBlockState) BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.UP)), iblockdata.get(BlockHugeMushroom.e))).set((IBlockState) BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.DOWN)), iblockdata.get(BlockHugeMushroom.f));
+ if (net.pl3x.purpur.PurpurConfig.disableMushroomBlockUpdates) return iblockdata;
+ return iblockdata
+ .set(BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.NORTH)), iblockdata.get(BlockHugeMushroom.a))
+ .set(BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.SOUTH)), iblockdata.get(BlockHugeMushroom.c))
+ .set(BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.EAST)), iblockdata.get(BlockHugeMushroom.b))
+ .set(BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.WEST)), iblockdata.get(BlockHugeMushroom.d))
+ .set(BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.UP)), iblockdata.get(BlockHugeMushroom.e))
+ .set(BlockHugeMushroom.g.get(enumblockrotation.a(EnumDirection.DOWN)), iblockdata.get(BlockHugeMushroom.f));
}
@Override
public IBlockData a(IBlockData iblockdata, EnumBlockMirror enumblockmirror) {
- return (IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) iblockdata.set((IBlockState) BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.NORTH)), iblockdata.get(BlockHugeMushroom.a))).set((IBlockState) BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.SOUTH)), iblockdata.get(BlockHugeMushroom.c))).set((IBlockState) BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.EAST)), iblockdata.get(BlockHugeMushroom.b))).set((IBlockState) BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.WEST)), iblockdata.get(BlockHugeMushroom.d))).set((IBlockState) BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.UP)), iblockdata.get(BlockHugeMushroom.e))).set((IBlockState) BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.DOWN)), iblockdata.get(BlockHugeMushroom.f));
+ if (net.pl3x.purpur.PurpurConfig.disableMushroomBlockUpdates) return iblockdata;
+ return iblockdata
+ .set(BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.NORTH)), iblockdata.get(BlockHugeMushroom.a))
+ .set(BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.SOUTH)), iblockdata.get(BlockHugeMushroom.c))
+ .set(BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.EAST)), iblockdata.get(BlockHugeMushroom.b))
+ .set(BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.WEST)), iblockdata.get(BlockHugeMushroom.d))
+ .set(BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.UP)), iblockdata.get(BlockHugeMushroom.e))
+ .set(BlockHugeMushroom.g.get(enumblockmirror.b(EnumDirection.DOWN)), iblockdata.get(BlockHugeMushroom.f));
}
@Override
diff --git a/src/main/java/net/minecraft/world/level/block/BlockNote.java b/src/main/java/net/minecraft/world/level/block/BlockNote.java
index feec1db88b22a4d13ffd3034633da79ed41b94fe..148718f8f96d94e76a4a7a96d5955b624c2dc661 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockNote.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockNote.java
@@ -35,11 +35,13 @@ public class BlockNote extends Block {
@Override
public IBlockData getPlacedState(BlockActionContext blockactioncontext) {
+ if (net.pl3x.purpur.PurpurConfig.disableNoteBlockUpdates) return this.getBlockData(); // Purpur
return (IBlockData) this.getBlockData().set(BlockNote.INSTRUMENT, BlockPropertyInstrument.a(blockactioncontext.getWorld().getType(blockactioncontext.getClickPosition().down())));
}
@Override
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
+ if (net.pl3x.purpur.PurpurConfig.disableNoteBlockUpdates) return iblockdata; // Purpur
return enumdirection == EnumDirection.DOWN ? (IBlockData) iblockdata.set(BlockNote.INSTRUMENT, BlockPropertyInstrument.a(iblockdata1)) : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
index 013f8a21be68f4e0470c0b873252bf21dd611127..ad41b9a096e8618a1a033a47918dd26c75781f96 100644
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -202,6 +202,15 @@ public class PurpurConfig {
allowWaterPlacementInTheEnd = getBoolean("settings.allow-water-placement-in-the-end", allowWaterPlacementInTheEnd);
}
+ public static boolean disableMushroomBlockUpdates = false;
+ public static boolean disableNoteBlockUpdates = false;
+ public static boolean disableChorusPlantUpdates = false;
+ private static void blockUpdatesSettings() {
+ disableMushroomBlockUpdates = getBoolean("settings.blocks.disable-mushroom-updates", disableMushroomBlockUpdates);
+ disableNoteBlockUpdates = getBoolean("settings.blocks.disable-note-block-updates", disableNoteBlockUpdates);
+ disableChorusPlantUpdates = getBoolean("settings.blocks.disable-chorus-plant-updates", disableChorusPlantUpdates);
+ }
+
public static boolean loggerSuppressInitLegacyMaterialError = false;
public static boolean loggerSuppressIgnoredAdvancementWarnings = false;
private static void loggerSettings() {

View File

@@ -1,85 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Tue, 4 Aug 2020 21:11:03 -0500
Subject: [PATCH] Dispensers place anvils option
diff --git a/src/main/java/net/minecraft/core/EnumDirection.java b/src/main/java/net/minecraft/core/EnumDirection.java
index 703bdefeb615ef8d15b428a893b5e4939d726f13..1a765ece1ad6d691c509a018469aa9ecf4f2f8f3 100644
--- a/src/main/java/net/minecraft/core/EnumDirection.java
+++ b/src/main/java/net/minecraft/core/EnumDirection.java
@@ -116,6 +116,7 @@ public enum EnumDirection implements INamable {
return fromType1(this.h);
}
+ public EnumDirection rotateCW() { return g(); } // Purpur - OBFHELPER
public EnumDirection g() {
switch (this) {
case NORTH:
@@ -131,6 +132,7 @@ public enum EnumDirection implements INamable {
}
}
+ public EnumDirection rotateCCW() { return h(); } // Purpur - OBFHELPER
public EnumDirection h() {
switch (this) {
case NORTH:
@@ -162,6 +164,7 @@ public enum EnumDirection implements INamable {
return this.j;
}
+ public EnumDirection.EnumAxis getAxis() { return n(); } // Purpur - OBFHELPER
public EnumDirection.EnumAxis n() {
return this.k;
}
diff --git a/src/main/java/net/minecraft/core/dispenser/IDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/IDispenseBehavior.java
index 0055a96b51a1d38d31e129c417c97bcfc9d0b745..31237773907341ee64c71507b5e1bf247ef2c524 100644
--- a/src/main/java/net/minecraft/core/dispenser/IDispenseBehavior.java
+++ b/src/main/java/net/minecraft/core/dispenser/IDispenseBehavior.java
@@ -52,6 +52,7 @@ import net.minecraft.world.level.IMaterial;
import net.minecraft.world.level.IWorldReader;
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.BlockAnvil;
import net.minecraft.world.level.block.BlockBeehive;
import net.minecraft.world.level.block.BlockCampfire;
import net.minecraft.world.level.block.BlockDispenser;
@@ -995,6 +996,23 @@ public interface IDispenseBehavior {
}
}));
BlockDispenser.a((IMaterial) Items.SHEARS.getItem(), (IDispenseBehavior) (new DispenseBehaviorShears()));
+ // Purpur start
+ BlockDispenser.a(Blocks.ANVIL, new DispenseBehaviorMaybe() {
+ @Override
+ protected ItemStack a(ISourceBlock dispenser, ItemStack itemstack) {
+ World world = dispenser.getWorld();
+ if (!world.purpurConfig.dispenserPlaceAnvils) return super.a(dispenser, itemstack);
+ EnumDirection facing = dispenser.getBlockData().get(BlockDispenser.FACING);
+ BlockPosition blockposition = dispenser.getBlockPosition().shift(facing);
+ IBlockData iblockdata = world.getType(blockposition);
+ if (iblockdata.isAir()) {
+ world.setTypeUpdate(blockposition, Blocks.ANVIL.getBlockData().set(BlockAnvil.FACING, facing.getAxis() == EnumDirection.EnumAxis.Y ? EnumDirection.NORTH : facing.rotateCW()));
+ itemstack.subtract(1);
+ }
+ return itemstack;
+ }
+ });
+ // Purpur end
}
static void a(ISourceBlock isourceblock, Entity entity, EnumDirection enumdirection) {
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index b328c9f69fd43ca7ed57ee7f5b46ca998f2cb672..54b8021bfac69800d4cec996a94c2fea53249130 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -297,8 +297,10 @@ public class PurpurWorldConfig {
}
public boolean dispenserApplyCursedArmor = true;
+ public boolean dispenserPlaceAnvils = false;
private void dispenserSettings() {
dispenserApplyCursedArmor = getBoolean("blocks.dispenser.apply-cursed-to-armor-slots", dispenserApplyCursedArmor);
+ dispenserPlaceAnvils = getBoolean("blocks.dispenser.place-anvils", dispenserPlaceAnvils);
}
public boolean farmlandGetsMoistFromBelow = false;

View File

@@ -0,0 +1,39 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: draycia <lonelyyordle@gmail.com>
Date: Tue, 31 Mar 2020 23:48:55 -0700
Subject: [PATCH] Configurable villager breeding
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index 88d6b1596463d86f6e4e67da54f16da14b8563bc..2707f3795ee83725d24ea76c9a57646975747c12 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -736,7 +736,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@Override
public boolean canBreed() {
- return this.foodLevel + this.countFoodPointsInInventory() >= 12 && this.getAge() == 0;
+ return level.purpurConfig.villagerCanBreed && this.foodLevel + this.countFoodPointsInInventory() >= 12 && this.getAge() == 0;
}
private boolean hungry() {
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 9d054fb175a80874869f630d6e15122530270661..7baff952c57f657bc242035bf9eee142883c9a81 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -902,6 +902,7 @@ public class PurpurWorldConfig {
public boolean villagerCanBeLeashed = false;
public int villagerSpawnIronGolemRadius = 0;
public int villagerSpawnIronGolemLimit = 0;
+ public boolean villagerCanBreed = true;
private void villagerSettings() {
villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
@@ -912,6 +913,7 @@ public class PurpurWorldConfig {
villagerCanBeLeashed = getBoolean("mobs.villager.can-be-leashed", villagerCanBeLeashed);
villagerSpawnIronGolemRadius = getInt("mobs.villager.spawn-iron-golem.radius", villagerSpawnIronGolemRadius);
villagerSpawnIronGolemLimit = getInt("mobs.villager.spawn-iron-golem.limit", villagerSpawnIronGolemLimit);
+ villagerCanBreed = getBoolean("mobs.villager.can-breed", villagerCanBreed);
}
public boolean vindicatorRidable = false;

View File

@@ -0,0 +1,34 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: draycia <lonelyyordle@gmail.com>
Date: Tue, 14 Apr 2020 00:35:12 -0700
Subject: [PATCH] Redstone deactivates spawners
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
index 9228c0bc797fb95c8ac949bdc568eadafee84a80..f2c9f841d397f445cd3d0420f19e765c28e5598d 100644
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
@@ -78,6 +78,7 @@ public abstract class BaseSpawner {
}
public boolean isNearPlayer(Level world, BlockPos pos) { // Paper private->public
+ if (world.purpurConfig.spawnerDeactivateByRedstone && world.hasNeighborSignal(pos)) return false; // Purpur
return world.isAffectsSpawningPlayerNearby((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, (double) this.requiredPlayerRange); // Paper
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 7baff952c57f657bc242035bf9eee142883c9a81..76a1e23af43176fd91e3201aba68a725a84d9090 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -871,6 +871,11 @@ public class PurpurWorldConfig {
tropicalFishRidable = getBoolean("mobs.tropical_fish.ridable", tropicalFishRidable);
}
+ public boolean spawnerDeactivateByRedstone = false;
+ private void spawnerSettings() {
+ spawnerDeactivateByRedstone = getBoolean("blocks.spawner.deactivate-by-redstone", spawnerDeactivateByRedstone);
+ }
+
public boolean turtleRidable = false;
public boolean turtleRidableInWater = false;
public boolean turtleEggsBreakFromExpOrbs = true;

View File

@@ -4,32 +4,32 @@ Date: Wed, 29 Apr 2020 00:45:58 -0700
Subject: [PATCH] Totems work in inventory
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 068052f2df6baca9169b1b5bc9c990798649be8f..50b64ab1cbc1940d2f8b5d938e41f5a31830da5b 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -1423,6 +1423,19 @@ public abstract class EntityLiving extends Entity {
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 36a1b330d5ad04da6aa231098998a17a7a0f6a74..158eeee4b207fc51c46507ba087874304a7eab93 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1516,6 +1516,19 @@ public abstract class LivingEntity extends Entity {
}
}
+ // Purpur start
+ if (world.purpurConfig.totemOfUndyingWorksInInventory && this instanceof EntityPlayer && (itemstack == null || itemstack.getItem() != Items.TOTEM_OF_UNDYING)) {
+ EntityPlayer player = (EntityPlayer) this;
+ for (ItemStack item : player.inventory.items) {
+ if (level.purpurConfig.totemOfUndyingWorksInInventory && this instanceof ServerPlayer && (itemstack == null || itemstack.getItem() != Items.TOTEM_OF_UNDYING)) {
+ ServerPlayer player = (ServerPlayer) this;
+ for (ItemStack item : player.getInventory().items) {
+ if (item.getItem() == Items.TOTEM_OF_UNDYING) {
+ itemstack1 = item;
+ itemstack = item.cloneItemStack();
+ itemstack = item.cloneItemStack(false);
+ break;
+ }
+ }
+ }
+ // Purpur end
+
EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity());
EntityResurrectEvent event = new EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity());
event.setCancelled(itemstack == null);
this.world.getServer().getPluginManager().callEvent(event);
this.level.getCraftServer().getPluginManager().callEvent(event);
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index a36b9ea779fd984a16332e66f122d9505fad67de..ad4da617cf718e1c03e1532a9b45d7f927539a14 100644
index 76a1e23af43176fd91e3201aba68a725a84d9090..1654f18aa3d24e4cf9d60ae5f6a7ae2e0fc98fcb 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -247,6 +247,11 @@ public class PurpurWorldConfig {

View File

@@ -0,0 +1,47 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Fri, 24 Jul 2020 19:38:21 -0500
Subject: [PATCH] Add vindicator johnny spawn chance
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
index 51082fb81477b96c778796e8daf288b366cecf22..a55ff1e98914e16a82804e85deb873b4f32fdb26 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
@@ -7,6 +7,7 @@ import java.util.function.Predicate;
import javax.annotation.Nullable;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
@@ -128,6 +129,12 @@ public class Vindicator extends AbstractIllager {
((GroundPathNavigation)this.getNavigation()).setCanOpenDoors(true);
this.populateDefaultEquipmentSlots(difficulty);
this.populateDefaultEquipmentEnchantments(difficulty);
+ // Purpur start
+ Level level = world.getMinecraftWorld();
+ if (level.purpurConfig.vindicatorJohnnySpawnChance > 0D && random.nextDouble() <= level.purpurConfig.vindicatorJohnnySpawnChance) {
+ setCustomName(new TranslatableComponent("Johnny"));
+ }
+ // Purpur end
return spawnGroupData;
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 1654f18aa3d24e4cf9d60ae5f6a7ae2e0fc98fcb..3235a7f593a602a0b2a75f98bd4cf2a0718ae297 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -928,9 +928,11 @@ public class PurpurWorldConfig {
public boolean vindicatorRidable = false;
public boolean vindicatorRidableInWater = false;
+ public double vindicatorJohnnySpawnChance = 0D;
private void vindicatorSettings() {
vindicatorRidable = getBoolean("mobs.vindicator.ridable", vindicatorRidable);
vindicatorRidableInWater = getBoolean("mobs.vindicator.ridable-in-water", vindicatorRidableInWater);
+ vindicatorJohnnySpawnChance = getDouble("mobs.vindicator.johnny.spawn-chance", vindicatorJohnnySpawnChance);
}
public boolean wanderingTraderRidable = false;

View File

@@ -0,0 +1,138 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Tue, 4 Aug 2020 17:11:58 -0500
Subject: [PATCH] Add option to disable certain block updates
diff --git a/src/main/java/net/minecraft/world/level/block/ChorusPlantBlock.java b/src/main/java/net/minecraft/world/level/block/ChorusPlantBlock.java
index bdd3369ac1b5386642d706921e5b2c94450ae96b..3ce2146099ca55b1ac96c02fdb95712a0becf43f 100644
--- a/src/main/java/net/minecraft/world/level/block/ChorusPlantBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ChorusPlantBlock.java
@@ -21,6 +21,7 @@ public class ChorusPlantBlock extends PipeBlock {
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
+ if (net.pl3x.purpur.PurpurConfig.disableChorusPlantUpdates) return this.defaultBlockState(); // Purpur
return this.getStateForPlacement(ctx.getLevel(), ctx.getClickedPos());
}
@@ -36,6 +37,7 @@ public class ChorusPlantBlock extends PipeBlock {
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
+ if (net.pl3x.purpur.PurpurConfig.disableChorusPlantUpdates) return state; // Purpur
if (!state.canSurvive(world, pos)) {
world.getBlockTicks().scheduleTick(pos, this, 1);
return super.updateShape(state, direction, neighborState, world, pos, neighborPos);
diff --git a/src/main/java/net/minecraft/world/level/block/HugeMushroomBlock.java b/src/main/java/net/minecraft/world/level/block/HugeMushroomBlock.java
index 3c6d97b51c6fec130b80e5965afa2c49d48843c9..174d16ae5c45dd3a4c9b4cc58b36121bef38d9cc 100644
--- a/src/main/java/net/minecraft/world/level/block/HugeMushroomBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/HugeMushroomBlock.java
@@ -22,29 +22,65 @@ public class HugeMushroomBlock extends Block {
public HugeMushroomBlock(BlockBehaviour.Properties settings) {
super(settings);
- this.registerDefaultState(this.stateDefinition.any().setValue(NORTH, Boolean.valueOf(true)).setValue(EAST, Boolean.valueOf(true)).setValue(SOUTH, Boolean.valueOf(true)).setValue(WEST, Boolean.valueOf(true)).setValue(UP, Boolean.valueOf(true)).setValue(DOWN, Boolean.valueOf(true)));
+ // Purpur start
+ this.registerDefaultState(this.stateDefinition.any()
+ .setValue(NORTH, true)
+ .setValue(EAST, true)
+ .setValue(SOUTH, true)
+ .setValue(WEST, true)
+ .setValue(UP, true)
+ .setValue(DOWN, true));
+ // Purpur end
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
+ if (net.pl3x.purpur.PurpurConfig.disableMushroomBlockUpdates) return this.defaultBlockState(); // Purpur
BlockGetter blockGetter = ctx.getLevel();
BlockPos blockPos = ctx.getClickedPos();
- return this.defaultBlockState().setValue(DOWN, Boolean.valueOf(!blockGetter.getBlockState(blockPos.below()).is(this))).setValue(UP, Boolean.valueOf(!blockGetter.getBlockState(blockPos.above()).is(this))).setValue(NORTH, Boolean.valueOf(!blockGetter.getBlockState(blockPos.north()).is(this))).setValue(EAST, Boolean.valueOf(!blockGetter.getBlockState(blockPos.east()).is(this))).setValue(SOUTH, Boolean.valueOf(!blockGetter.getBlockState(blockPos.south()).is(this))).setValue(WEST, Boolean.valueOf(!blockGetter.getBlockState(blockPos.west()).is(this)));
+ // Purpur start
+ return this.defaultBlockState()
+ .setValue(DOWN, this != blockGetter.getTypeIfLoaded(blockPos.below()).getBlock())
+ .setValue(UP, this != blockGetter.getTypeIfLoaded(blockPos.above()).getBlock())
+ .setValue(NORTH, this != blockGetter.getTypeIfLoaded(blockPos.north()).getBlock())
+ .setValue(EAST, this != blockGetter.getTypeIfLoaded(blockPos.east()).getBlock())
+ .setValue(SOUTH, this != blockGetter.getTypeIfLoaded(blockPos.south()).getBlock())
+ .setValue(WEST, this != blockGetter.getTypeIfLoaded(blockPos.west()).getBlock());
+ // Purpur end
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
+ if (net.pl3x.purpur.PurpurConfig.disableMushroomBlockUpdates) return state; // Purpur
return neighborState.is(this) ? state.setValue(PROPERTY_BY_DIRECTION.get(direction), Boolean.valueOf(false)) : super.updateShape(state, direction, neighborState, world, pos, neighborPos);
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
- return state.setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.NORTH)), state.getValue(NORTH)).setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.SOUTH)), state.getValue(SOUTH)).setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.EAST)), state.getValue(EAST)).setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.WEST)), state.getValue(WEST)).setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.UP)), state.getValue(UP)).setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.DOWN)), state.getValue(DOWN));
+ // Purpur start
+ if (net.pl3x.purpur.PurpurConfig.disableMushroomBlockUpdates) return state;
+ return state
+ .setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.NORTH)), state.getValue(NORTH))
+ .setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.SOUTH)), state.getValue(SOUTH))
+ .setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.EAST)), state.getValue(EAST))
+ .setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.WEST)), state.getValue(NORTH))
+ .setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.UP)), state.getValue(UP))
+ .setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.DOWN)), state.getValue(DOWN));
+ // Purpur end
}
@Override
public BlockState mirror(BlockState state, Mirror mirror) {
- return state.setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.NORTH)), state.getValue(NORTH)).setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.SOUTH)), state.getValue(SOUTH)).setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.EAST)), state.getValue(EAST)).setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.WEST)), state.getValue(WEST)).setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.UP)), state.getValue(UP)).setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.DOWN)), state.getValue(DOWN));
+ // Purpur start
+ if (net.pl3x.purpur.PurpurConfig.disableMushroomBlockUpdates) return state;
+ return state
+ .setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.NORTH)), state.getValue(NORTH))
+ .setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.SOUTH)), state.getValue(SOUTH))
+ .setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.EAST)), state.getValue(EAST))
+ .setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.WEST)), state.getValue(NORTH))
+ .setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.UP)), state.getValue(UP))
+ .setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.DOWN)), state.getValue(DOWN));
+ // Purpur end
}
@Override
diff --git a/src/main/java/net/minecraft/world/level/block/NoteBlock.java b/src/main/java/net/minecraft/world/level/block/NoteBlock.java
index f8e58d9f71703139a736d93e7f1996e027a29444..d3c8fd8399629efb8bcbaf7d9a0c43340fcdfeda 100644
--- a/src/main/java/net/minecraft/world/level/block/NoteBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/NoteBlock.java
@@ -35,11 +35,13 @@ public class NoteBlock extends Block {
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
+ if (net.pl3x.purpur.PurpurConfig.disableNoteBlockUpdates) return this.defaultBlockState(); // Purpur
return (BlockState) this.defaultBlockState().setValue(NoteBlock.INSTRUMENT, NoteBlockInstrument.byState(ctx.getLevel().getBlockState(ctx.getClickedPos().below())));
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
+ if (net.pl3x.purpur.PurpurConfig.disableNoteBlockUpdates) return this.defaultBlockState(); // Purpur
return direction == Direction.DOWN ? (BlockState) state.setValue(NoteBlock.INSTRUMENT, NoteBlockInstrument.byState(neighborState)) : super.updateShape(state, direction, neighborState, world, pos, neighborPos);
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
index e1f9d3bd4460ca9b99557411011fa2efcf58faac..64cd0a7afb466d9cd6d4ec1fd700a9d05994f716 100644
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -202,6 +202,15 @@ public class PurpurConfig {
allowWaterPlacementInTheEnd = getBoolean("settings.allow-water-placement-in-the-end", allowWaterPlacementInTheEnd);
}
+ public static boolean disableMushroomBlockUpdates = false;
+ public static boolean disableNoteBlockUpdates = false;
+ public static boolean disableChorusPlantUpdates = false;
+ private static void blockUpdatesSettings() {
+ disableMushroomBlockUpdates = getBoolean("settings.blocks.disable-mushroom-updates", disableMushroomBlockUpdates);
+ disableNoteBlockUpdates = getBoolean("settings.blocks.disable-note-block-updates", disableNoteBlockUpdates);
+ disableChorusPlantUpdates = getBoolean("settings.blocks.disable-chorus-plant-updates", disableChorusPlantUpdates);
+ }
+
public static boolean loggerSuppressInitLegacyMaterialError = false;
public static boolean loggerSuppressIgnoredAdvancementWarnings = false;
private static void loggerSettings() {

View File

@@ -0,0 +1,57 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Tue, 4 Aug 2020 21:11:03 -0500
Subject: [PATCH] Dispensers place anvils option
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
index 92623ae25249d63efb92be8bd6c95228f9155ad2..20bf6d01046488eff53a109f5239351aedaafede 100644
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
@@ -53,6 +53,7 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
+import net.minecraft.world.level.block.AnvilBlock;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.block.BeehiveBlock;
import net.minecraft.world.level.block.Block;
@@ -1029,6 +1030,23 @@ public interface DispenseItemBehavior {
}
}
}));
+ // Purpur start
+ DispenserBlock.registerBehavior(Items.ANVIL, (new OptionalDispenseItemBehavior() {
+ @Override
+ public ItemStack execute(BlockSource dispenser, ItemStack stack) {
+ Level level = dispenser.getLevel();
+ if (!level.purpurConfig.dispenserPlaceAnvils) return super.execute(dispenser, stack);
+ Direction facing = dispenser.getBlockState().getValue(DispenserBlock.FACING);
+ BlockPos pos = dispenser.getPos().relative(facing);
+ BlockState state = level.getBlockState(pos);
+ if (state.isAir()) {
+ level.setBlockAndUpdate(pos, Blocks.ANVIL.defaultBlockState().setValue(AnvilBlock.FACING, facing.getAxis() == Direction.Axis.Y ? Direction.NORTH : facing.getClockWise()));
+ stack.shrink(1);
+ }
+ return stack;
+ }
+ }));
+ // Purpur end
}
static void setEntityPokingOutOfBlock(BlockSource pointer, Entity entity, Direction direction) {
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 3235a7f593a602a0b2a75f98bd4cf2a0718ae297..3d8fc2f58dfa775913942ef2121953578db84a34 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -292,8 +292,10 @@ public class PurpurWorldConfig {
}
public boolean dispenserApplyCursedArmor = true;
+ public boolean dispenserPlaceAnvils = false;
private void dispenserSettings() {
dispenserApplyCursedArmor = getBoolean("blocks.dispenser.apply-cursed-to-armor-slots", dispenserApplyCursedArmor);
+ dispenserPlaceAnvils = getBoolean("blocks.dispenser.place-anvils", dispenserPlaceAnvils);
}
public boolean farmlandGetsMoistFromBelow = false;