mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-04-21 18:58:16 +02:00
99/103 rejected minecraft source files applied
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/clock/ServerClockManager.java
|
||||
+++ b/net/minecraft/world/clock/ServerClockManager.java
|
||||
@@ -112,7 +_,7 @@
|
||||
ServerClockManager.ClockInstance instance = this.getInstance(clock);
|
||||
action.accept(instance);
|
||||
Map<Holder<WorldClock>, ClockState> updates = Map.of(clock, instance.packNetworkState(this.server));
|
||||
- this.server.getPlayerList().broadcastAll(new ClientboundSetTimePacket(this.getGameTime(), updates)); // TODO 26.1 per-player time
|
||||
+ this.server.getPlayerList().broadcastAll(new ClientboundSetTimePacket(this.getGameTime(), updates)); // TODO 26.1 per-player time // Purpur - TODO: Configurable daylight cycle
|
||||
this.setDirty();
|
||||
}
|
||||
|
||||
@@ -128,7 +_,7 @@
|
||||
// Paper end
|
||||
|
||||
public ClientboundSetTimePacket createFullSyncPacket() {
|
||||
- // TODO 26.1 per-player time
|
||||
+ // TODO 26.1 per-player time // Purpur - TODO: Configurable daylight cycle
|
||||
return new ClientboundSetTimePacket(this.getGameTime(), Util.mapValues(this.clocks, clock -> clock.packNetworkState(this.server)));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/world/entity/ai/attributes/RangedAttribute.java
|
||||
+++ b/net/minecraft/world/entity/ai/attributes/RangedAttribute.java
|
||||
@@ -29,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
public double sanitizeValue(final double value) {
|
||||
+ if (!org.purpurmc.purpur.PurpurConfig.clampAttributes) return Double.isNaN(value) ? this.minValue : value; // Purpur - Add attribute clamping and armor limit config
|
||||
return Double.isNaN(value) ? this.minValue : Mth.clamp(value, this.minValue, this.maxValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
@@ -89,7 +_,7 @@
|
||||
}
|
||||
};
|
||||
Set<Pair<Holder<PoiType>, BlockPos>> poiPositions = poiManager.findAllClosestFirstWithType(
|
||||
- poiType, cacheTest, body.blockPosition(), 48, PoiManager.Occupancy.HAS_SPACE
|
||||
+ poiType, cacheTest, body.blockPosition(), level.purpurConfig.villagerAcquirePoiSearchRadius, PoiManager.Occupancy.HAS_SPACE // Purpur - Configurable villager search radius
|
||||
)
|
||||
.limit(5L)
|
||||
.filter(px -> validPoi.test(level, (BlockPos)px.getSecond()))
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java
|
||||
@@ -53,7 +_,7 @@
|
||||
Node toNode = path.getNextNode();
|
||||
BlockPos fromPos = fromNode.asBlockPos();
|
||||
BlockState fromState = level.getBlockState(fromPos);
|
||||
- if (fromState.is(BlockTags.MOB_INTERACTABLE_DOORS, s -> s.getBlock() instanceof DoorBlock)) {
|
||||
+ if (fromState.is(BlockTags.MOB_INTERACTABLE_DOORS, s -> s.getBlock() instanceof DoorBlock)&& !DoorBlock.requiresRedstone(entity.level(), blockState, blockPos)) { // Purpur - Option to make doors require redstone
|
||||
DoorBlock fromBlock = (DoorBlock)fromState.getBlock();
|
||||
if (!fromBlock.isOpen(fromState)) {
|
||||
// CraftBukkit start - entities opening doors
|
||||
@@ -70,7 +_,7 @@
|
||||
|
||||
BlockPos toPos = toNode.asBlockPos();
|
||||
BlockState toState = level.getBlockState(toPos);
|
||||
- if (toState.is(BlockTags.MOB_INTERACTABLE_DOORS, s -> s.getBlock() instanceof DoorBlock)) {
|
||||
+ if (toState.is(BlockTags.MOB_INTERACTABLE_DOORS, s -> s.getBlock() instanceof DoorBlock) && !DoorBlock.requiresRedstone(entity.level(), blockState1, blockPos1)) { // Purpur - Option to make doors require redstone
|
||||
DoorBlock door = (DoorBlock)toState.getBlock();
|
||||
if (!door.isOpen(toState)) {
|
||||
// CraftBukkit start - entities opening doors
|
||||
@@ -117,7 +_,7 @@
|
||||
iterator.remove();
|
||||
} else {
|
||||
BlockState state = level.getBlockState(doorPos);
|
||||
- if (!state.is(BlockTags.MOB_INTERACTABLE_DOORS, s -> s.getBlock() instanceof DoorBlock)) {
|
||||
+ if (!state.is(BlockTags.MOB_INTERACTABLE_DOORS, s -> s.getBlock() instanceof DoorBlock) || DoorBlock.requiresRedstone(entity.level(), blockState, blockPos)) { // Purpur - Option to make doors require redstone
|
||||
iterator.remove();
|
||||
} else {
|
||||
DoorBlock block = (DoorBlock)state.getBlock();
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/world/entity/ai/behavior/ShowTradesToPlayer.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/ShowTradesToPlayer.java
|
||||
@@ -41,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean canStillUse(final ServerLevel level, final Villager body, final long timestamp) {
|
||||
+ if (!body.level().purpurConfig.villagerDisplayTradeItem) return false; // Purpur - Option for villager display trade item
|
||||
return this.checkExtraStartConditions(level, body) && this.lookTime > 0 && body.getBrain().getMemory(MemoryModuleType.INTERACTION_TARGET).isPresent();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
--- a/net/minecraft/world/entity/ai/behavior/SleepInBed.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/SleepInBed.java
|
||||
@@ -89,7 +_,14 @@
|
||||
InteractWithDoor.closeDoorsThatIHaveOpenedOrPassedThrough(level, body, null, null, doors, nearestEntities);
|
||||
}
|
||||
|
||||
- body.startSleeping(body.getBrain().getMemory(MemoryModuleType.HOME).get().pos());
|
||||
+ // Purpur start - Option for beds to explode on villager sleep
|
||||
+ net.minecraft.core.BlockPos bedPosition = body.getBrain().getMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.HOME).get().pos();
|
||||
+ if (level.purpurConfig.bedExplodeOnVillagerSleep && body.is(net.minecraft.world.entity.EntityType.VILLAGER) && level.getBlockState(bedPosition).getBlock() instanceof net.minecraft.world.level.block.BedBlock) {
|
||||
+ level.explode(null, (double) bedPosition.getX() + 0.5D, (double) bedPosition.getY() + 0.5D, (double) bedPosition.getZ() + 0.5D, (float) level.purpurConfig.bedExplosionPower, level.purpurConfig.bedExplosionFire, level.purpurConfig.bedExplosionEffect);
|
||||
+ return;
|
||||
+ }
|
||||
+ body.startSleeping(bedPosition);
|
||||
+ // Purpur end - Option for beds to explode on villager sleep
|
||||
brain.setMemory(MemoryModuleType.LAST_SLEPT, timestamp);
|
||||
brain.eraseMemory(MemoryModuleType.WALK_TARGET);
|
||||
brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
||||
@@ -0,0 +1,54 @@
|
||||
--- a/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java
|
||||
@@ -286,7 +_,7 @@
|
||||
LevelChunk levelChunk = level.getChunkSource().getChunkNow(chunkPos.x(), chunkPos.z());
|
||||
if (levelChunk != null) {
|
||||
for (BlockEntity potentialTarget : levelChunk.getBlockEntities().values()) {
|
||||
- if (potentialTarget instanceof ChestBlockEntity chestBlockEntity) {
|
||||
+ if (potentialTarget instanceof net.minecraft.world.level.block.entity.BaseContainerBlockEntity chestBlockEntity) { // Purpur - copper golem can place items in barrels or shulkers option
|
||||
double distance = chestBlockEntity.getBlockPos().distToCenterSqr(body.position());
|
||||
if (distance < closestDistance) {
|
||||
TransportItemsBetweenContainers.TransportItemTarget targetValidToPick = this.isTargetValidToPick(
|
||||
@@ -375,7 +_,11 @@
|
||||
}
|
||||
|
||||
private boolean isTargetBlocked(final Level level, final TransportItemsBetweenContainers.TransportItemTarget target) {
|
||||
- return ChestBlock.isChestBlockedAt(level, target.pos);
|
||||
+ // Purpur start - copper golem can place items in barrels or shulkers option
|
||||
+ boolean isBarrelBlocked = !level.purpurConfig.copperGolemCanOpenBarrel && target.state.is(net.minecraft.world.level.block.Blocks.BARREL);
|
||||
+ boolean isShulkerBlocked = !level.purpurConfig.copperGolemCanOpenShulker && target.blockEntity instanceof net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity shulkerBoxBlockEntity && !net.minecraft.world.level.block.ShulkerBoxBlock.canOpen(target.state, level, target.pos, shulkerBoxBlockEntity);
|
||||
+ return target.state.is(net.minecraft.world.level.block.Blocks.BARREL) ? isBarrelBlocked : isShulkerBlocked || net.minecraft.world.level.block.ChestBlock.isChestBlockedAt(level, target.pos);
|
||||
+ // Purpur end - copper golem can place items in barrels or shulkers option
|
||||
}
|
||||
|
||||
private boolean targetHasNotChanged(final Level level, final TransportItemsBetweenContainers.TransportItemTarget target) {
|
||||
@@ -455,7 +_,7 @@
|
||||
}
|
||||
|
||||
private boolean isWantedBlock(final PathfinderMob mob, final BlockState block) {
|
||||
- return isPickingUpItems(mob) ? this.sourceBlockType.test(block) : this.destinationBlockType.test(block);
|
||||
+ return isPickingUpItems(mob) ? this.sourceBlockType.test(block) : (mob.level().purpurConfig.copperGolemCanOpenBarrel && state.is(net.minecraft.world.level.block.Blocks.BARREL)) || (mob.level().purpurConfig.copperGolemCanOpenShulker && state.is(net.minecraft.tags.BlockTags.SHULKER_BOXES)) || this.destinationBlockType.test(block); // Purpur - copper golem can place items in barrels or shulkers option
|
||||
}
|
||||
|
||||
private static double getInteractionRange(final PathfinderMob body) {
|
||||
@@ -507,6 +_,11 @@
|
||||
}
|
||||
|
||||
private static boolean matchesLeavingItemsRequirement(final PathfinderMob body, final Container container) {
|
||||
+ // Purpur start - copper golem can place items in barrels or shulkers option
|
||||
+ if (body.level().purpurConfig.copperGolemCanOpenShulker && container instanceof net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity && body.getMainHandItem().is(net.minecraft.tags.ItemTags.SHULKER_BOXES)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end - copper golem can place items in barrels or shulkers option
|
||||
return container.isEmpty() || hasItemMatchingHandItem(body, container);
|
||||
}
|
||||
|
||||
@@ -544,7 +_,7 @@
|
||||
int slot = 0;
|
||||
|
||||
for (ItemStack itemStack : container) {
|
||||
- if (!itemStack.isEmpty()) {
|
||||
+ if (!itemStack.isEmpty() && (!(container instanceof net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity) || !itemStack.is(net.minecraft.tags.ItemTags.SHULKER_BOXES))) { // Purpur - copper golem can place items in barrels or shulkers option
|
||||
int itemCount = Math.min(itemStack.getCount(), 16);
|
||||
return container.removeItem(slot, itemCount);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
--- a/net/minecraft/world/entity/ai/goal/SwellGoal.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/SwellGoal.java
|
||||
@@ -46,6 +_,14 @@
|
||||
this.creeper.setSwellDir(-1);
|
||||
} else {
|
||||
this.creeper.setSwellDir(1);
|
||||
+ // Purpur start - option to allow creeper to encircle target when fusing
|
||||
+ if (this.creeper.level().purpurConfig.creeperEncircleTarget) {
|
||||
+ net.minecraft.world.phys.Vec3 relative = this.creeper.position().subtract(this.target.position());
|
||||
+ relative = relative.yRot((float) Math.PI / 3).normalize().multiply(2, 2, 2);
|
||||
+ net.minecraft.world.phys.Vec3 destination = this.target.position().add(relative);
|
||||
+ this.creeper.getNavigation().moveTo(destination.x, destination.y, destination.z, 1);
|
||||
+ }
|
||||
+ // Purpur end - option to allow creeper to encircle target when fusing
|
||||
}
|
||||
} else {
|
||||
this.creeper.setSwellDir(-1);
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
||||
@@ -54,9 +_,9 @@
|
||||
}
|
||||
};
|
||||
Set<Pair<Holder<PoiType>, BlockPos>> pois = poiManager.findAllWithType(
|
||||
- e -> e.is(PoiTypes.HOME), cacheTest, body.blockPosition(), 48, PoiManager.Occupancy.ANY
|
||||
+ e -> e.is(PoiTypes.HOME), cacheTest, body.blockPosition(), level.purpurConfig.villagerNearestBedSensorSearchRadius, PoiManager.Occupancy.ANY
|
||||
)
|
||||
- .collect(Collectors.toSet());
|
||||
+ .collect(Collectors.toSet()); // Purpur - Configurable villager search radius
|
||||
Path path = AcquirePoi.findPathToPois(body, pois);
|
||||
if (path != null && path.canReach()) {
|
||||
BlockPos targetPos = path.getTarget();
|
||||
@@ -0,0 +1,34 @@
|
||||
--- a/net/minecraft/world/entity/animal/Animal.java
|
||||
+++ b/net/minecraft/world/entity/animal/Animal.java
|
||||
@@ -146,7 +_,7 @@
|
||||
ItemStack itemStack = player.getItemInHand(hand);
|
||||
if (this.isFood(itemStack)) {
|
||||
int age = this.getAge();
|
||||
- if (player instanceof ServerPlayer serverPlayer && age == 0 && this.canFallInLove()) {
|
||||
+ if (player instanceof ServerPlayer serverPlayer && age == 0 && this.canFallInLove() && (this.level().purpurConfig.animalBreedingCooldownSeconds <= 0 || !this.level().hasBreedingCooldown(player.getUUID(), this.getClass()))) { // Purpur - Add adjustable breeding cooldown to config
|
||||
final ItemStack breedCopy = itemStack.copy(); // Paper - Fix EntityBreedEvent copying
|
||||
this.usePlayerItem(player, hand, itemStack);
|
||||
this.setInLove(serverPlayer, breedCopy); // Paper - Fix EntityBreedEvent copying
|
||||
@@ -227,10 +_,20 @@
|
||||
public void spawnChildFromBreeding(final ServerLevel level, final Animal partner) {
|
||||
AgeableMob offspring = this.getBreedOffspring(level, partner);
|
||||
if (offspring != null) {
|
||||
- offspring.setBaby(true);
|
||||
- offspring.snapTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
|
||||
+ //offspring.setBaby(true); // Purpur - Add adjustable breeding cooldown to config - moved down
|
||||
+ //offspring.snapTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); // Purpur - Add adjustable breeding cooldown to config - moved down
|
||||
// CraftBukkit start - Call EntityBreedEvent
|
||||
ServerPlayer breeder = Optional.ofNullable(this.getLoveCause()).or(() -> Optional.ofNullable(partner.getLoveCause())).orElse(null);
|
||||
+ // Purpur start - Add adjustable breeding cooldown to config
|
||||
+ if (breeder != null && level.purpurConfig.animalBreedingCooldownSeconds > 0) {
|
||||
+ if (level.hasBreedingCooldown(breeder.getUUID(), this.getClass())) {
|
||||
+ return;
|
||||
+ }
|
||||
+ level.addBreedingCooldown(breeder.getUUID(), this.getClass());
|
||||
+ }
|
||||
+ offspring.setBaby(true);
|
||||
+ offspring.snapTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
|
||||
+ // Purpur end - Add adjustable breeding cooldown to config
|
||||
int experience = this.getRandom().nextInt(7) + 1;
|
||||
org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(offspring, this, partner, breeder, this.breedItem, experience);
|
||||
if (entityBreedEvent.isCancelled()) {
|
||||
@@ -0,0 +1,73 @@
|
||||
--- a/net/minecraft/world/entity/animal/bee/Bee.java
|
||||
+++ b/net/minecraft/world/entity/animal/bee/Bee.java
|
||||
@@ -172,7 +_,7 @@
|
||||
// Paper end - Fix MC-167279
|
||||
this.lookControl = new Bee.BeeLookControl(this);
|
||||
this.setPathfindingMalus(PathType.FIRE_IN_NEIGHBOR, -1.0F);
|
||||
- this.setPathfindingMalus(PathType.WATER, -1.0F);
|
||||
+ if (this.level().purpurConfig.beeCanInstantlyStartDrowning) this.setPathfindingMalus(PathType.WATER, -1.0F); // Purpur - bee can instantly start drowning in water option
|
||||
this.setPathfindingMalus(PathType.WATER_BORDER, 16.0F);
|
||||
this.setPathfindingMalus(PathType.COCOA, -1.0F);
|
||||
this.setPathfindingMalus(PathType.FENCE, -1.0F);
|
||||
@@ -363,13 +_,19 @@
|
||||
if (this.stayOutOfHiveCountdown <= 0 && !this.beePollinateGoal.isPollinating() && !this.hasStung() && this.getTarget() == null) {
|
||||
boolean wantsToEnterHive = this.hasNectar()
|
||||
|| this.isTiredOfLookingForNectar()
|
||||
- || this.level().environmentAttributes().getValue(EnvironmentAttributes.BEES_STAY_IN_HIVE, this.position());
|
||||
+ || this.level().environmentAttributes().getValue(EnvironmentAttributes.BEES_STAY_IN_HIVE, this.position()) || isNightOrRaining(this.level()); // Purpur - Bee can work when raining or at night
|
||||
return wantsToEnterHive && !this.isHiveNearFire();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+ // Purpur start - Bee can work when raining or at night
|
||||
+ public static boolean isNightOrRaining(Level level) {
|
||||
+ return level.dimensionType().hasSkyLight() && (level.isDarkOutside() && !level.purpurConfig.beeCanWorkAtNight || level.isRaining() && !level.purpurConfig.beeCanWorkInRain); // Purpur - Bee can work when raining or at night
|
||||
+ }
|
||||
+ // Purpur end - Bee can work when raining or at night
|
||||
+
|
||||
public void setStayOutOfHiveCountdown(final int ticks) {
|
||||
this.stayOutOfHiveCountdown = ticks;
|
||||
}
|
||||
@@ -390,7 +_,7 @@
|
||||
@Override
|
||||
protected void customServerAiStep(final ServerLevel level) {
|
||||
boolean hasStung = this.hasStung();
|
||||
- if (this.isInWater()) {
|
||||
+ if (this.level().purpurConfig.beeCanInstantlyStartDrowning && this.isInWater()) { // Purpur - bee can instantly start drowning in water option
|
||||
this.underWaterTicks++;
|
||||
} else {
|
||||
this.underWaterTicks = 0;
|
||||
@@ -400,6 +_,7 @@
|
||||
this.hurtServer(level, this.damageSources().drown(), 1.0F);
|
||||
}
|
||||
|
||||
+ if (hasStung && !this.level().purpurConfig.beeDiesAfterSting) setHasStung(false); else // Purpur - Stop bees from dying after stinging
|
||||
if (hasStung) {
|
||||
this.timeSinceSting++;
|
||||
if (this.timeSinceSting % 5 == 0 && this.random.nextInt(Mth.clamp(1200 - this.timeSinceSting, 1, 1200)) == 0) {
|
||||
@@ -1168,6 +_,7 @@
|
||||
Bee.this.savedFlowerPos = nearbyPos.get();
|
||||
Bee.this.navigation
|
||||
.moveTo(Bee.this.savedFlowerPos.getX() + 0.5, Bee.this.savedFlowerPos.getY() + 0.5, Bee.this.savedFlowerPos.getZ() + 0.5, 1.2F);
|
||||
+ new org.purpurmc.purpur.event.entity.BeeFoundFlowerEvent((org.bukkit.entity.Bee) Bee.this.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(Bee.this.savedFlowerPos, Bee.this.level())).callEvent(); // Purpur - Bee API
|
||||
return true;
|
||||
} else {
|
||||
Bee.this.remainingCooldownBeforeLocatingNewFlower = Mth.nextInt(Bee.this.random, 20, 60);
|
||||
@@ -1214,6 +_,7 @@
|
||||
this.pollinating = false;
|
||||
Bee.this.navigation.stop();
|
||||
Bee.this.remainingCooldownBeforeLocatingNewFlower = 200;
|
||||
+ new org.purpurmc.purpur.event.entity.BeeStopPollinatingEvent((org.bukkit.entity.Bee) Bee.this.getBukkitEntity(), Bee.this.savedFlowerPos == null ? null : org.bukkit.craftbukkit.util.CraftLocation.toBukkit(Bee.this.savedFlowerPos, Bee.this.level()), Bee.this.hasNectar()).callEvent(); // Purpur - Bee API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1260,6 +_,7 @@
|
||||
this.setWantedPos();
|
||||
}
|
||||
|
||||
+ if (this.successfulPollinatingTicks == 0) new org.purpurmc.purpur.event.entity.BeeStartedPollinatingEvent((org.bukkit.entity.Bee) Bee.this.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(Bee.this.savedFlowerPos, Bee.this.level())).callEvent(); // Purpur - Bee API
|
||||
this.successfulPollinatingTicks++;
|
||||
if (Bee.this.random.nextFloat() < 0.05F && this.successfulPollinatingTicks > this.lastSoundPlayedTick + 60) {
|
||||
this.lastSoundPlayedTick = this.successfulPollinatingTicks;
|
||||
@@ -0,0 +1,90 @@
|
||||
--- a/net/minecraft/world/entity/animal/cow/AbstractCow.java
|
||||
+++ b/net/minecraft/world/entity/animal/cow/AbstractCow.java
|
||||
@@ -40,7 +_,7 @@
|
||||
this.goalSelector.addGoal(0, new FloatGoal(this));
|
||||
this.goalSelector.addGoal(1, new PanicGoal(this, 2.0));
|
||||
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
|
||||
- this.goalSelector.addGoal(3, new TemptGoal(this, 1.25, i -> i.is(ItemTags.COW_FOOD), false));
|
||||
+ this.goalSelector.addGoal(3, new TemptGoal(this, 1.25, i -> level().purpurConfig.cowFeedMushrooms > 0 && (i.is(net.minecraft.world.level.block.Blocks.RED_MUSHROOM.asItem()) || i.is(net.minecraft.world.level.block.Blocks.BROWN_MUSHROOM.asItem())) || i.is(ItemTags.COW_FOOD), false)); // Purpur - Cows eat mushrooms
|
||||
this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25));
|
||||
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
|
||||
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
|
||||
@@ -100,6 +_,10 @@
|
||||
ItemStack bucketOrMilkBucket = ItemUtils.createFilledResult(itemStack, player, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
|
||||
player.setItemInHand(hand, bucketOrMilkBucket);
|
||||
return InteractionResult.SUCCESS;
|
||||
+ // Purpur start - Cows eat mushrooms - feed mushroom to change to mooshroom
|
||||
+ } else if (level().purpurConfig.cowFeedMushrooms > 0 && this.getType() != EntityType.MOOSHROOM && isMushroom(itemInHand)) {
|
||||
+ return this.feedMushroom(player, itemInHand);
|
||||
+ // Purpur end - Cows eat mushrooms
|
||||
} else {
|
||||
return super.mobInteract(player, hand);
|
||||
}
|
||||
@@ -109,4 +_,67 @@
|
||||
public EntityDimensions getDefaultDimensions(final Pose pose) {
|
||||
return this.isBaby() ? BABY_DIMENSIONS : super.getDefaultDimensions(pose);
|
||||
}
|
||||
+
|
||||
+ // Purpur start - Cows eat mushrooms - feed mushroom to change to mooshroom
|
||||
+ private int redMushroomsFed = 0;
|
||||
+ private int brownMushroomsFed = 0;
|
||||
+
|
||||
+ private boolean isMushroom(ItemStack stack) {
|
||||
+ return stack.getItem() == net.minecraft.world.level.block.Blocks.RED_MUSHROOM.asItem() || stack.getItem() == net.minecraft.world.level.block.Blocks.BROWN_MUSHROOM.asItem();
|
||||
+ }
|
||||
+
|
||||
+ private int incrementFeedCount(ItemStack stack) {
|
||||
+ if (stack.getItem() == net.minecraft.world.level.block.Blocks.RED_MUSHROOM.asItem()) {
|
||||
+ return ++redMushroomsFed;
|
||||
+ } else {
|
||||
+ return ++brownMushroomsFed;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private InteractionResult feedMushroom(Player player, ItemStack stack) {
|
||||
+ level().broadcastEntityEvent(this, (byte) 18); // hearts
|
||||
+ playSound(SoundEvents.COW_MILK, 1.0F, 1.0F);
|
||||
+ if (incrementFeedCount(stack) < level().purpurConfig.cowFeedMushrooms) {
|
||||
+ if (!player.getAbilities().instabuild) {
|
||||
+ stack.shrink(1);
|
||||
+ }
|
||||
+ return InteractionResult.CONSUME; // require 5 mushrooms to transform (prevents mushroom duping)
|
||||
+ }
|
||||
+ MushroomCow mooshroom = EntityType.MOOSHROOM.create(level(), net.minecraft.world.entity.EntitySpawnReason.CONVERSION);
|
||||
+ if (mooshroom == null) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ if (stack.getItem() == net.minecraft.world.level.block.Blocks.BROWN_MUSHROOM.asItem()) {
|
||||
+ mooshroom.setVariant(MushroomCow.Variant.BROWN);
|
||||
+ } else {
|
||||
+ mooshroom.setVariant(MushroomCow.Variant.RED);
|
||||
+ }
|
||||
+ mooshroom.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
||||
+ mooshroom.setHealth(this.getHealth());
|
||||
+ mooshroom.setAge(getAge());
|
||||
+ mooshroom.copyPosition(this);
|
||||
+ mooshroom.setYBodyRot(this.yBodyRot);
|
||||
+ mooshroom.setYHeadRot(this.getYHeadRot());
|
||||
+ mooshroom.yRotO = this.yRotO;
|
||||
+ mooshroom.xRotO = this.xRotO;
|
||||
+ if (this.hasCustomName()) {
|
||||
+ mooshroom.setCustomName(this.getCustomName());
|
||||
+ }
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, mooshroom, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ this.level().addFreshEntity(mooshroom);
|
||||
+ this.remove(RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
|
||||
+ if (!player.getAbilities().instabuild) {
|
||||
+ stack.shrink(1);
|
||||
+ }
|
||||
+ for (int i = 0; i < 15; ++i) {
|
||||
+ ((net.minecraft.server.level.ServerLevel) level()).sendParticlesSource(((net.minecraft.server.level.ServerLevel) level()).players(), null, net.minecraft.core.particles.ParticleTypes.HAPPY_VILLAGER,
|
||||
+ false, true,
|
||||
+ getX() + random.nextFloat(), getY() + (random.nextFloat() * 2), getZ() + random.nextFloat(), 1,
|
||||
+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0);
|
||||
+ }
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // Purpur end - Cows eat mushrooms
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
--- a/net/minecraft/world/entity/animal/dolphin/Dolphin.java
|
||||
+++ b/net/minecraft/world/entity/animal/dolphin/Dolphin.java
|
||||
@@ -77,6 +_,7 @@
|
||||
public static final float BABY_SCALE = 0.65F;
|
||||
private static final boolean DEFAULT_GOT_FISH = false;
|
||||
public @Nullable BlockPos treasurePos;
|
||||
+ private boolean isNaturallyAggressiveToPlayers; // Purpur - Dolphins naturally aggressive to players chance
|
||||
|
||||
public Dolphin(final EntityType<? extends Dolphin> type, final Level level) {
|
||||
super(type, level);
|
||||
@@ -92,6 +_,7 @@
|
||||
this.setAirSupply(this.getMaxAirSupply());
|
||||
this.setXRot(0.0F);
|
||||
SpawnGroupData spawnGroupData = Objects.requireNonNullElseGet(groupData, () -> new AgeableMob.AgeableMobGroupData(0.1F));
|
||||
+ this.isNaturallyAggressiveToPlayers = level.getLevel().purpurConfig.dolphinNaturallyAggressiveToPlayersChance > 0.0D && random.nextDouble() <= level.getLevel().purpurConfig.dolphinNaturallyAggressiveToPlayersChance; // Purpur - Dolphins naturally aggressive to players chance
|
||||
return super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData);
|
||||
}
|
||||
|
||||
@@ -157,18 +_,20 @@
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(0, new BreathAirGoal(this));
|
||||
this.goalSelector.addGoal(0, new TryFindWaterGoal(this));
|
||||
+ this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2000000476837158D, true)); // Purpur - Dolphins naturally aggressive to players chance
|
||||
this.goalSelector.addGoal(1, new Dolphin.DolphinSwimToTreasureGoal(this));
|
||||
this.goalSelector.addGoal(2, new Dolphin.DolphinSwimWithPlayerGoal(this, 4.0));
|
||||
this.goalSelector.addGoal(4, new RandomSwimmingGoal(this, 1.0, 10));
|
||||
this.goalSelector.addGoal(4, new RandomLookAroundGoal(this));
|
||||
this.goalSelector.addGoal(5, new LookAtPlayerGoal(this, Player.class, 6.0F));
|
||||
this.goalSelector.addGoal(5, new DolphinJumpGoal(this, 10));
|
||||
- this.goalSelector.addGoal(6, new MeleeAttackGoal(this, 1.2F, true));
|
||||
+ //this.goalSelector.addGoal(6, new MeleeAttackGoal(this, 1.2F, true)); // Purpur - moved up - Dolphins naturally aggressive to players chance
|
||||
this.goalSelector.addGoal(8, new Dolphin.PlayWithItemsGoal());
|
||||
this.goalSelector.addGoal(8, new FollowPlayerRiddenEntityGoal(this, AbstractBoat.class));
|
||||
this.goalSelector.addGoal(8, new FollowPlayerRiddenEntityGoal(this, AbstractNautilus.class));
|
||||
this.goalSelector.addGoal(9, new AvoidEntityGoal<>(this, Guardian.class, 8.0F, 1.0, 1.0));
|
||||
this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Guardian.class).setAlertOthers());
|
||||
+ this.targetSelector.addGoal(2, new net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (ignored, ignored2) -> isNaturallyAggressiveToPlayers)); // Purpur - Dolphins naturally aggressive to players chance
|
||||
}
|
||||
|
||||
public static AttributeSupplier.Builder createAttributes() {
|
||||
@@ -395,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
+ if (this.dolphin.level().purpurConfig.dolphinDisableTreasureSearching) return false; // Purpur - Add option to disable dolphin treasure searching
|
||||
return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
--- a/net/minecraft/world/entity/animal/equine/Llama.java
|
||||
+++ b/net/minecraft/world/entity/animal/equine/Llama.java
|
||||
@@ -75,6 +_,7 @@
|
||||
private boolean didSpit;
|
||||
private @Nullable Llama caravanHead;
|
||||
public @Nullable Llama caravanTail; // Paper - public
|
||||
+ public boolean shouldJoinCaravan = true; // Purpur - Llama API
|
||||
|
||||
public Llama(final EntityType<? extends Llama> type, final Level level) {
|
||||
super(type, level);
|
||||
@@ -104,6 +_,7 @@
|
||||
super.addAdditionalSaveData(output);
|
||||
output.store("Variant", Llama.Variant.LEGACY_CODEC, this.getVariant());
|
||||
output.putInt("Strength", this.getStrength());
|
||||
+ output.putBoolean("Purpur.ShouldJoinCaravan", shouldJoinCaravan); // Purpur - Llama API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,6 +_,7 @@
|
||||
this.setStrength(input.getIntOr("Strength", 0));
|
||||
super.readAdditionalSaveData(input);
|
||||
this.setVariant(input.read("Variant", Llama.Variant.LEGACY_CODEC).orElse(Llama.Variant.DEFAULT));
|
||||
+ this.shouldJoinCaravan = input.getBooleanOr("Purpur.ShouldJoinCaravan", true); // Purpur - Llama API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -387,6 +_,7 @@
|
||||
|
||||
public void leaveCaravan() {
|
||||
if (this.caravanHead != null) {
|
||||
+ new org.purpurmc.purpur.event.entity.LlamaLeaveCaravanEvent((org.bukkit.entity.Llama) getBukkitEntity()).callEvent(); // Purpur - Llama API
|
||||
this.caravanHead.caravanTail = null;
|
||||
}
|
||||
|
||||
@@ -394,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void joinCaravan(final Llama tail) {
|
||||
+ if (!this.level().purpurConfig.llamaJoinCaravans || !shouldJoinCaravan || !new org.purpurmc.purpur.event.entity.LlamaJoinCaravanEvent((org.bukkit.entity.Llama) getBukkitEntity(), (org.bukkit.entity.Llama) caravanHead.getBukkitEntity()).callEvent()) return; // Purpur - Llama API // Purpur - Config to disable Llama caravans
|
||||
this.caravanHead = tail;
|
||||
this.caravanHead.caravanTail = this;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
--- a/net/minecraft/world/entity/animal/feline/Cat.java
|
||||
+++ b/net/minecraft/world/entity/animal/feline/Cat.java
|
||||
@@ -382,6 +_,14 @@
|
||||
return this.isTame() && partner instanceof Cat cat && cat.isTame() && super.canMate(partner);
|
||||
}
|
||||
|
||||
+ // Purpur start - Configurable default collar color
|
||||
+ @Override
|
||||
+ public void tame(Player player) {
|
||||
+ setCollarColor(level().purpurConfig.catDefaultCollarColor);
|
||||
+ super.tame(player);
|
||||
+ }
|
||||
+ // Purpur end - Configurable default collar color
|
||||
+
|
||||
@Override
|
||||
public @Nullable SpawnGroupData finalizeSpawn(
|
||||
final ServerLevelAccessor level, final DifficultyInstance difficulty, final EntitySpawnReason spawnReason, @Nullable SpawnGroupData groupData
|
||||
@@ -476,7 +_,7 @@
|
||||
}
|
||||
|
||||
private void tryToTame(final Player player) {
|
||||
- if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit
|
||||
+ if (((this.level().purpurConfig.alwaysTameInCreative && player.hasInfiniteMaterials()) || this.random.nextInt(3) == 0) && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit // Purpur - Config to always tame in Creative
|
||||
this.tame(player);
|
||||
this.setOrderedToSit(true);
|
||||
this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED);
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/animal/feline/Ocelot.java
|
||||
+++ b/net/minecraft/world/entity/animal/feline/Ocelot.java
|
||||
@@ -234,7 +_,7 @@
|
||||
public boolean checkSpawnObstruction(final LevelReader level) {
|
||||
if (level.isUnobstructed(this) && !level.containsAnyLiquid(this.getBoundingBox())) {
|
||||
BlockPos pos = this.blockPosition();
|
||||
- if (pos.getY() < level.getSeaLevel()) {
|
||||
+ if (!level().purpurConfig.ocelotSpawnUnderSeaLevel && pos.getY() < level.getSeaLevel()) { // Purpur - Option Ocelot Spawn Under Sea Level
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/world/entity/animal/fish/WaterAnimal.java
|
||||
+++ b/net/minecraft/world/entity/animal/fish/WaterAnimal.java
|
||||
@@ -80,8 +_,7 @@
|
||||
seaLevel = level.getMinecraftWorld().paperConfig().entities.spawning.wateranimalSpawnHeight.maximum.or(seaLevel);
|
||||
minSpawnLevel = level.getMinecraftWorld().paperConfig().entities.spawning.wateranimalSpawnHeight.minimum.or(minSpawnLevel);
|
||||
// Paper end - Make water animal spawn height configurable
|
||||
- return pos.getY() >= minSpawnLevel
|
||||
- && pos.getY() <= seaLevel
|
||||
+ return ((spawnReason == EntitySpawnReason.SPAWNER && level.getMinecraftWorld().purpurConfig.spawnerFixMC238526) || (pos.getY() >= minSpawnLevel && pos.getY() <= seaLevel)) // Purpur - MC-238526 - Fix spawner not spawning water animals correctly
|
||||
&& level.getFluidState(pos.below()).is(FluidTags.WATER)
|
||||
&& level.getBlockState(pos.above()).is(Blocks.WATER);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
--- a/net/minecraft/world/entity/animal/golem/CopperGolemAi.java
|
||||
+++ b/net/minecraft/world/entity/animal/golem/CopperGolemAi.java
|
||||
@@ -41,7 +_,7 @@
|
||||
private static final int TICK_TO_START_ON_REACHED_INTERACTION = 1;
|
||||
private static final int TICK_TO_PLAY_ON_REACHED_SOUND = 9;
|
||||
private static final Predicate<BlockState> TRANSPORT_ITEM_SOURCE_BLOCK = block -> block.is(BlockTags.COPPER_CHESTS);
|
||||
- private static final Predicate<BlockState> TRANSPORT_ITEM_DESTINATION_BLOCK = block -> block.is(Blocks.CHEST) || block.is(Blocks.TRAPPED_CHEST);
|
||||
+ private static final Predicate<BlockState> TRANSPORT_ITEM_DESTINATION_BLOCK = block -> block.is(Blocks.CHEST) || block.is(Blocks.TRAPPED_CHEST); // Purpur - copper golem can place items in barrels or shulkers option - diff on change
|
||||
|
||||
protected static List<ActivityData<CopperGolem>> getActivities() {
|
||||
return List.of(initCoreActivity(), initIdleActivity());
|
||||
@@ -130,6 +_,11 @@
|
||||
}
|
||||
|
||||
if (ticksSinceReachingTarget == 60) {
|
||||
+ // Purpur start - copper golem can place items in barrels or shulkers option
|
||||
+ if (container instanceof net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity shulkerBoxBlockEntity && shulkerBoxBlockEntity.openCount > 0) {
|
||||
+ container.stopOpen(copperGolem);
|
||||
+ }
|
||||
+ // Purpur end - copper golem can place items in barrels or shulkers option
|
||||
if (container.getEntitiesWithContainerOpen().contains(body)) {
|
||||
container.stopOpen(copperGolem);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
--- a/net/minecraft/world/entity/animal/golem/IronGolem.java
|
||||
+++ b/net/minecraft/world/entity/animal/golem/IronGolem.java
|
||||
@@ -58,13 +_,25 @@
|
||||
private static final UniformInt PERSISTENT_ANGER_TIME = TimeUtil.rangeOfSeconds(20, 39);
|
||||
private long persistentAngerEndTime;
|
||||
private @Nullable EntityReference<LivingEntity> persistentAngerTarget;
|
||||
+ private java.util.@Nullable UUID summoner; // Purpur - Summoner API
|
||||
|
||||
public IronGolem(final EntityType<? extends IronGolem> type, final Level level) {
|
||||
super(type, level);
|
||||
}
|
||||
|
||||
+ // Purpur start - Summoner API
|
||||
+ public java.util.@Nullable UUID getSummoner() {
|
||||
+ return summoner;
|
||||
+ }
|
||||
+
|
||||
+ public void setSummoner(java.util.@Nullable UUID summoner) {
|
||||
+ this.summoner = summoner;
|
||||
+ }
|
||||
+ // Purpur end - Summoner API
|
||||
+
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
+ if (this.level().purpurConfig.ironGolemPoppyCalm) this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.ReceiveFlower(this)); // Purpur - Iron golem calm anger options
|
||||
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0, true));
|
||||
this.goalSelector.addGoal(2, new MoveTowardsTargetGoal(this, 0.9, 32.0F));
|
||||
this.goalSelector.addGoal(2, new MoveBackToVillageGoal(this, 0.6, false));
|
||||
@@ -142,6 +_,7 @@
|
||||
protected void addAdditionalSaveData(final ValueOutput output) {
|
||||
super.addAdditionalSaveData(output);
|
||||
output.putBoolean("PlayerCreated", this.isPlayerCreated());
|
||||
+ output.storeNullable("Purpur.Summoner", net.minecraft.core.UUIDUtil.CODEC, getSummoner()); // Purpur - Summoner API
|
||||
this.addPersistentAngerSaveData(output);
|
||||
}
|
||||
|
||||
@@ -149,6 +_,7 @@
|
||||
protected void readAdditionalSaveData(final ValueInput input) {
|
||||
super.readAdditionalSaveData(input);
|
||||
this.setPlayerCreated(input.getBooleanOr("PlayerCreated", false));
|
||||
+ this.setSummoner(input.read("Purpur.Summoner", net.minecraft.core.UUIDUtil.CODEC).orElse(null)); // Purpur - Summoner API
|
||||
this.readPersistentAngerSaveData(this.level(), input);
|
||||
}
|
||||
|
||||
@@ -267,6 +_,7 @@
|
||||
float pitch = 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F;
|
||||
this.playSound(SoundEvents.IRON_GOLEM_REPAIR, 1.0F, pitch);
|
||||
itemStack.consume(1, player);
|
||||
+ if (this.level().purpurConfig.ironGolemHealCalm && isAngry() && getHealth() == getMaxHealth()) stopBeingAngry(); // Purpur - Iron golem calm anger options
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/world/entity/animal/parrot/Parrot.java
|
||||
+++ b/net/minecraft/world/entity/animal/parrot/Parrot.java
|
||||
@@ -164,6 +_,7 @@
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(0, new TamableAnimal.TamableAnimalPanicGoal(1.25));
|
||||
this.goalSelector.addGoal(0, new FloatGoal(this));
|
||||
+ if (this.level().purpurConfig.parrotBreedable) this.goalSelector.addGoal(1, new net.minecraft.world.entity.ai.goal.BreedGoal(this, 1.0D)); // Purpur - Breedable parrots
|
||||
this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, Player.class, 8.0F));
|
||||
this.goalSelector.addGoal(2, new SitWhenOrderedToGoal(this));
|
||||
this.goalSelector.addGoal(2, new FollowOwnerGoal(this, 1.0, 5.0F, 1.0F));
|
||||
@@ -270,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide()) {
|
||||
- if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit
|
||||
+ if (((this.level().purpurConfig.alwaysTameInCreative && player.hasInfiniteMaterials()) || this.random.nextInt(10) == 0) && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit // Purpur - Config to always tame in Creative
|
||||
this.tame(player);
|
||||
this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED);
|
||||
} else {
|
||||
@@ -278,6 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ if (this.level().purpurConfig.parrotBreedable) return super.mobInteract(player, hand); // Purpur - Breedable parrots
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (!itemStack.is(ItemTags.PARROT_POISONOUS_FOOD)) {
|
||||
if (!this.isFlying() && this.isTame() && this.isOwnedBy(player)) {
|
||||
@@ -302,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isFood(final ItemStack itemStack) {
|
||||
- return false;
|
||||
+ return this.level().purpurConfig.parrotBreedable && stack.is(ItemTags.PARROT_FOOD); // Purpur - Breedable parrots
|
||||
}
|
||||
|
||||
public static boolean checkParrotSpawnRules(
|
||||
@@ -317,12 +_,12 @@
|
||||
|
||||
@Override
|
||||
public boolean canMate(final Animal partner) {
|
||||
- return false;
|
||||
+ return super.canMate(otherAnimal); // Purpur - Breedable parrots
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable AgeableMob getBreedOffspring(final ServerLevel level, final AgeableMob partner) {
|
||||
- return null;
|
||||
+ return level.purpurConfig.parrotBreedable ? EntityType.PARROT.create(level, EntitySpawnReason.BREEDING) : null; // Purpur - Breedable parrots
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/world/entity/animal/pig/Pig.java
|
||||
+++ b/net/minecraft/world/entity/animal/pig/Pig.java
|
||||
@@ -158,6 +_,19 @@
|
||||
@Override
|
||||
public InteractionResult mobInteract(final Player player, final InteractionHand hand) {
|
||||
boolean hasFood = this.isFood(player.getItemInHand(hand));
|
||||
+ // Purpur start - Pigs give saddle back
|
||||
+ if (level().purpurConfig.pigGiveSaddleBack && player.isSecondaryUseActive() && !hasFood && isSaddled() && !isVehicle()) {
|
||||
+ this.setItemSlot(EquipmentSlot.SADDLE, ItemStack.EMPTY);
|
||||
+ if (!player.getAbilities().instabuild) {
|
||||
+ ItemStack saddle = new ItemStack(Items.SADDLE);
|
||||
+ if (!player.getInventory().add(saddle)) {
|
||||
+ player.drop(saddle, false);
|
||||
+ }
|
||||
+ }
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // Purpur end - Pigs give saddle back
|
||||
+
|
||||
if (!hasFood && this.isSaddled() && !this.isVehicle() && !player.isSecondaryUseActive()) {
|
||||
if (!this.level().isClientSide()) {
|
||||
player.startRiding(this);
|
||||
@@ -0,0 +1,54 @@
|
||||
--- a/net/minecraft/world/entity/animal/polarbear/PolarBear.java
|
||||
+++ b/net/minecraft/world/entity/animal/polarbear/PolarBear.java
|
||||
@@ -67,6 +_,29 @@
|
||||
super(type, level);
|
||||
}
|
||||
|
||||
+ // Purpur start - Breedable Polar Bears
|
||||
+ public boolean canMate(Animal other) {
|
||||
+ if (other == this) {
|
||||
+ return false;
|
||||
+ } else if (this.isStanding()) {
|
||||
+ return false;
|
||||
+ } else if (this.getTarget() != null) {
|
||||
+ return false;
|
||||
+ } else if (!(other instanceof PolarBear)) {
|
||||
+ return false;
|
||||
+ } else {
|
||||
+ PolarBear bear = (PolarBear) other;
|
||||
+ if (bear.isStanding()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (bear.getTarget() != null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ return this.isInLove() && bear.isInLove();
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Breedable Polar Bears
|
||||
+
|
||||
@Override
|
||||
public @Nullable AgeableMob getBreedOffspring(final ServerLevel level, final AgeableMob partner) {
|
||||
return EntityType.POLAR_BEAR.create(level, EntitySpawnReason.BREEDING);
|
||||
@@ -74,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isFood(final ItemStack itemStack) {
|
||||
- return false;
|
||||
+ return level().purpurConfig.polarBearBreedableItem != null && itemStack.getItem() == level().purpurConfig.polarBearBreedableItem; // Purpur - Breedable Polar Bears
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,6 +_,12 @@
|
||||
this.goalSelector.addGoal(0, new FloatGoal(this));
|
||||
this.goalSelector.addGoal(1, new PolarBear.PolarBearMeleeAttackGoal());
|
||||
this.goalSelector.addGoal(1, new PanicGoal(this, 2.0, bear -> bear.isBaby() ? DamageTypeTags.PANIC_CAUSES : DamageTypeTags.PANIC_ENVIRONMENTAL_CAUSES));
|
||||
+ // Purpur start - Breedable Polar Bears
|
||||
+ if (level().purpurConfig.polarBearBreedableItem != null) {
|
||||
+ this.goalSelector.addGoal(2, new net.minecraft.world.entity.ai.goal.BreedGoal(this, 1.0D));
|
||||
+ this.goalSelector.addGoal(3, new net.minecraft.world.entity.ai.goal.TemptGoal(this, 1.0D, net.minecraft.world.item.crafting.Ingredient.of(level().purpurConfig.polarBearBreedableItem), false));
|
||||
+ }
|
||||
+ // Purpur end - Breedable Polar Bears
|
||||
this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25));
|
||||
this.goalSelector.addGoal(5, new RandomStrollGoal(this, 1.0));
|
||||
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
|
||||
@@ -0,0 +1,26 @@
|
||||
--- a/net/minecraft/world/entity/animal/rabbit/Rabbit.java
|
||||
+++ b/net/minecraft/world/entity/animal/rabbit/Rabbit.java
|
||||
@@ -419,10 +_,23 @@
|
||||
}
|
||||
|
||||
this.setVariant(variant);
|
||||
+
|
||||
+ // Purpur start - Special mobs naturally spawn
|
||||
+ if (variant != Variant.EVIL && level.getLevel().purpurConfig.rabbitNaturalToast > 0D && random.nextDouble() <= level.getLevel().purpurConfig.rabbitNaturalToast) {
|
||||
+ setCustomName(Component.translatable("Toast"));
|
||||
+ }
|
||||
+ // Purpur end - Special mobs naturally spawn
|
||||
+
|
||||
return super.finalizeSpawn(level, difficulty, spawnReason, groupData);
|
||||
}
|
||||
|
||||
private static Rabbit.Variant getRandomRabbitVariant(final LevelAccessor level, final BlockPos pos) {
|
||||
+ // Purpur start - Special mobs naturally spawn
|
||||
+ Level world = level.getMinecraftWorld();
|
||||
+ if (world.purpurConfig.rabbitNaturalKiller > 0D && world.getRandom().nextDouble() <= world.purpurConfig.rabbitNaturalKiller) {
|
||||
+ return Rabbit.Variant.EVIL;
|
||||
+ }
|
||||
+ // Purpur end - Special mobs naturally spawn
|
||||
Holder<Biome> biome = level.getBiome(pos);
|
||||
int randomVal = level.getRandom().nextInt(100);
|
||||
if (biome.is(BiomeTags.SPAWNS_WHITE_RABBITS)) {
|
||||
@@ -0,0 +1,50 @@
|
||||
--- a/net/minecraft/world/entity/animal/squid/Squid.java
|
||||
+++ b/net/minecraft/world/entity/animal/squid/Squid.java
|
||||
@@ -51,10 +_,29 @@
|
||||
|
||||
public Squid(final EntityType<? extends Squid> type, final Level level) {
|
||||
super(type, level);
|
||||
- // this.random.setSeed(this.getId()); // Paper - Share random for entities to make them more random
|
||||
+ if (!level.purpurConfig.entitySharedRandom) this.random.setSeed(this.getId()); // Paper - Share random for entities to make them more random // Purpur - Add toggle for RNG manipulation
|
||||
this.tentacleSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
|
||||
}
|
||||
|
||||
+ // Purpur start - Stop squids floating on top of water
|
||||
+ @Override
|
||||
+ public net.minecraft.world.phys.AABB getAxisForFluidCheck() {
|
||||
+ // Stops squids from floating just over the water
|
||||
+ return super.getAxisForFluidCheck().offsetY(level().purpurConfig.squidOffsetWaterCheck);
|
||||
+ }
|
||||
+ // Purpur end - Stop squids floating on top of water
|
||||
+
|
||||
+ // Purpur start - Flying squids! Oh my!
|
||||
+ public boolean canFly() {
|
||||
+ return this.level().purpurConfig.squidsCanFly;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isInWater() {
|
||||
+ return this.wasTouchingWater || canFly();
|
||||
+ }
|
||||
+ // Purpur end - Flying squids! Oh my!
|
||||
+
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(0, new Squid.SquidRandomMovementGoal(this));
|
||||
@@ -131,6 +_,7 @@
|
||||
}
|
||||
|
||||
if (this.isInWater()) {
|
||||
+ if (canFly()) setNoGravity(!wasTouchingWater); // Purpur - Flying squids! Oh my!
|
||||
if (this.tentacleMovement < (float) Math.PI) {
|
||||
float tentacleScale = this.tentacleMovement / (float) Math.PI;
|
||||
this.tentacleAngle = Mth.sin(tentacleScale * tentacleScale * (float) Math.PI) * (float) Math.PI * 0.25F;
|
||||
@@ -321,7 +_,7 @@
|
||||
int noActionTime = this.squid.getNoActionTime();
|
||||
if (noActionTime > 100) {
|
||||
this.squid.movementVector = Vec3.ZERO;
|
||||
- } else if (this.squid.getRandom().nextInt(reducedTickDelay(50)) == 0 || !this.squid.wasTouchingWater || !this.squid.hasMovementVector()) {
|
||||
+ } else if (this.squid.getRandom().nextInt(reducedTickDelay(50)) == 0 || !this.squid.isInWater() || !this.squid.hasMovementVector()) { // Purpur - Flying squids! Oh my!
|
||||
float angle = this.squid.getRandom().nextFloat() * (float) (Math.PI * 2);
|
||||
this.squid.movementVector = new Vec3(Mth.cos(angle) * 0.2F, -0.1F + this.squid.getRandom().nextFloat() * 0.2F, Mth.sin(angle) * 0.2F);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
--- a/net/minecraft/world/entity/animal/wolf/Wolf.java
|
||||
+++ b/net/minecraft/world/entity/animal/wolf/Wolf.java
|
||||
@@ -97,6 +_,37 @@
|
||||
public static final TargetingConditions.Selector PREY_SELECTOR = (target, level) -> target.is(EntityType.SHEEP)
|
||||
|| target.is(EntityType.RABBIT)
|
||||
|| target.is(EntityType.FOX);
|
||||
+ // Purpur start - Configurable chance for wolves to spawn rabid
|
||||
+ private boolean isRabid = false;
|
||||
+ private static final TargetingConditions.Selector RABID_PREDICATE = (entity, ignored) -> entity instanceof net.minecraft.server.level.ServerPlayer || entity instanceof net.minecraft.world.entity.Mob;
|
||||
+ private final net.minecraft.world.entity.ai.goal.Goal PATHFINDER_VANILLA = new NonTameRandomTargetGoal<>(this, Animal.class, false, PREY_SELECTOR);
|
||||
+ private final net.minecraft.world.entity.ai.goal.Goal PATHFINDER_RABID = new NonTameRandomTargetGoal<>(this, LivingEntity.class, false, RABID_PREDICATE);
|
||||
+ private static final class AvoidRabidWolfGoal extends AvoidEntityGoal<Wolf> {
|
||||
+ private final Wolf wolf;
|
||||
+
|
||||
+ public AvoidRabidWolfGoal(Wolf wolf, float distance, double minSpeed, double maxSpeed) {
|
||||
+ super(wolf, Wolf.class, distance, minSpeed, maxSpeed);
|
||||
+ this.wolf = wolf;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean canUse() {
|
||||
+ return super.canUse() && !this.wolf.isRabid() && this.toAvoid != null && this.toAvoid.isRabid(); // wolves which are not rabid run away from rabid wolves
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void start() {
|
||||
+ this.wolf.setTarget(null);
|
||||
+ super.start();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void tick() {
|
||||
+ this.wolf.setTarget(null);
|
||||
+ super.tick();
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Configurable chance for wolves to spawn rabid
|
||||
private static final float START_HEALTH = 8.0F;
|
||||
private static final float TAME_HEALTH = 40.0F;
|
||||
private static final float ARMOR_REPAIR_UNIT = 0.125F;
|
||||
@@ -118,12 +_,47 @@
|
||||
this.setPathfindingMalus(PathType.ON_TOP_OF_POWDER_SNOW, -1.0F);
|
||||
}
|
||||
|
||||
+ // Purpur start - Configurable chance for wolves to spawn rabid
|
||||
+ public boolean isRabid() {
|
||||
+ return this.isRabid;
|
||||
+ }
|
||||
+
|
||||
+ public void setRabid(boolean isRabid) {
|
||||
+ this.isRabid = isRabid;
|
||||
+ updatePathfinders(true);
|
||||
+ }
|
||||
+
|
||||
+ public void updatePathfinders(boolean modifyEffects) {
|
||||
+ this.targetSelector.removeGoal(PATHFINDER_VANILLA);
|
||||
+ this.targetSelector.removeGoal(PATHFINDER_RABID);
|
||||
+ if (this.isRabid) {
|
||||
+ this.setOwnerReference(null);
|
||||
+ setTame(false, true);
|
||||
+ this.targetSelector.addGoal(5, PATHFINDER_RABID);
|
||||
+ if (modifyEffects) this.addEffect(new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.NAUSEA, 1200));
|
||||
+ } else {
|
||||
+ this.targetSelector.addGoal(5, PATHFINDER_VANILLA);
|
||||
+ this.stopBeingAngry();
|
||||
+ if (modifyEffects) this.removeEffect(net.minecraft.world.effect.MobEffects.NAUSEA);
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Configurable chance for wolves to spawn rabid
|
||||
+
|
||||
+ // Purpur start - Configurable default collar color
|
||||
+ @Override
|
||||
+ public void tame(Player player) {
|
||||
+ setCollarColor(level().purpurConfig.wolfDefaultCollarColor);
|
||||
+ super.tame(player);
|
||||
+ }
|
||||
+ // Purpur end - Configurable default collar color
|
||||
+
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(1, new FloatGoal(this));
|
||||
this.goalSelector.addGoal(1, new TamableAnimal.TamableAnimalPanicGoal(1.5, DamageTypeTags.PANIC_ENVIRONMENTAL_CAUSES));
|
||||
this.goalSelector.addGoal(2, new SitWhenOrderedToGoal(this));
|
||||
this.goalSelector.addGoal(3, new Wolf.WolfAvoidEntityGoal<>(this, Llama.class, 24.0F, 1.5, 1.5));
|
||||
+ this.goalSelector.addGoal(3, new AvoidRabidWolfGoal(this, 24.0F, 1.5D, 1.5D)); // Purpur - Configurable chance for wolves to spawn rabid
|
||||
this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, 0.4F));
|
||||
this.goalSelector.addGoal(5, new MeleeAttackGoal(this, 1.0, true));
|
||||
this.goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.0, 10.0F, 2.0F));
|
||||
@@ -136,7 +_,7 @@
|
||||
this.targetSelector.addGoal(2, new OwnerHurtTargetGoal(this));
|
||||
this.targetSelector.addGoal(3, new HurtByTargetGoal(this).setAlertOthers());
|
||||
this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt));
|
||||
- this.targetSelector.addGoal(5, new NonTameRandomTargetGoal<>(this, Animal.class, false, PREY_SELECTOR));
|
||||
+ //this.targetSelector.addGoal(5, new NonTameRandomTargetGoal<>(this, Animal.class, false, PREY_SELECTOR)); // Purpur - Configurable chance for wolves to spawn rabid - moved to updatePathfinders()
|
||||
this.targetSelector.addGoal(6, new NonTameRandomTargetGoal<>(this, Turtle.class, false, Turtle.BABY_ON_LAND_SELECTOR));
|
||||
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, AbstractSkeleton.class, false));
|
||||
this.targetSelector.addGoal(8, new ResetUniversalAngerTargetGoal<>(this, true));
|
||||
@@ -231,6 +_,7 @@
|
||||
protected void addAdditionalSaveData(final ValueOutput output) {
|
||||
super.addAdditionalSaveData(output);
|
||||
output.store("CollarColor", DyeColor.LEGACY_ID_CODEC, this.getCollarColor());
|
||||
+ output.putBoolean("Purpur.IsRabid", this.isRabid); // Purpur - Configurable chance for wolves to spawn rabid
|
||||
VariantUtils.writeVariant(output, this.getVariant());
|
||||
this.addPersistentAngerSaveData(output);
|
||||
this.getSoundVariant()
|
||||
@@ -245,6 +_,10 @@
|
||||
super.readAdditionalSaveData(input);
|
||||
VariantUtils.readVariant(input, Registries.WOLF_VARIANT).ifPresent(this::setVariant);
|
||||
this.setCollarColor(input.read("CollarColor", DyeColor.LEGACY_ID_CODEC).orElse(DEFAULT_COLLAR_COLOR));
|
||||
+ // Purpur start - Configurable chance for wolves to spawn rabid
|
||||
+ this.isRabid = input.getBooleanOr("Purpur.IsRabid", false);
|
||||
+ this.updatePathfinders(false);
|
||||
+ // Purpur end - Configurable chance for wolves to spawn rabid
|
||||
this.readPersistentAngerSaveData(this.level(), input);
|
||||
input.read("sound_variant", ResourceKey.codec(Registries.WOLF_SOUND_VARIANT))
|
||||
.flatMap(soundVariant -> this.registryAccess().lookupOrThrow(Registries.WOLF_SOUND_VARIANT).get((ResourceKey<WolfSoundVariant>)soundVariant))
|
||||
@@ -268,6 +_,10 @@
|
||||
}
|
||||
|
||||
this.setSoundVariant(WolfSoundVariants.pickRandomSoundVariant(this.registryAccess(), level.getRandom()));
|
||||
+ // Purpur start - Configurable chance for wolves to spawn rabid
|
||||
+ this.isRabid = level.getLevel().purpurConfig.wolfNaturalRabid > 0.0D && random.nextDouble() <= level.getLevel().purpurConfig.wolfNaturalRabid;
|
||||
+ this.updatePathfinders(false);
|
||||
+ // Purpur end - Configurable chance for wolves to spawn rabid
|
||||
return super.finalizeSpawn(level, difficulty, spawnReason, groupData);
|
||||
}
|
||||
|
||||
@@ -316,6 +_,11 @@
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.isAlive()) {
|
||||
+ // Purpur start - Configurable chance for wolves to spawn rabid
|
||||
+ if (this.age % 300 == 0 && this.isRabid()) {
|
||||
+ this.addEffect(new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.NAUSEA, 400));
|
||||
+ }
|
||||
+ // Purpur end - Configurable chance for wolves to spawn rabid
|
||||
this.interestedAngleO = this.interestedAngle;
|
||||
if (this.isInterested()) {
|
||||
this.interestedAngle = this.interestedAngle + (1.0F - this.interestedAngle) * 0.4F;
|
||||
@@ -504,13 +_,27 @@
|
||||
itemStack.consume(1, player);
|
||||
this.tryToTame(player);
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
+ // Purpur start - Configurable chance for wolves to spawn rabid
|
||||
+ } else if (this.level().purpurConfig.wolfMilkCuresRabies && itemInHand.getItem() == Items.MILK_BUCKET && this.isRabid()) {
|
||||
+ if (!player.isCreative()) {
|
||||
+ player.setItemInHand(hand, new ItemStack(Items.BUCKET));
|
||||
+ }
|
||||
+ this.setRabid(false);
|
||||
+ for (int i = 0; i < 10; ++i) {
|
||||
+ ((ServerLevel) level()).sendParticlesSource(((ServerLevel) level()).players(), null, ParticleTypes.HAPPY_VILLAGER,
|
||||
+ false, true,
|
||||
+ getX() + random.nextFloat(), getY() + (random.nextFloat() * 1.5), getZ() + random.nextFloat(), 1,
|
||||
+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0);
|
||||
+ }
|
||||
+ return InteractionResult.SUCCESS_SERVER;
|
||||
+ // Purpur end - Configurable chance for wolves to spawn rabid
|
||||
}
|
||||
|
||||
return super.mobInteract(player, hand);
|
||||
}
|
||||
|
||||
private void tryToTame(final Player player) {
|
||||
- if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call
|
||||
+ if (((this.level().purpurConfig.alwaysTameInCreative && player.hasInfiniteMaterials()) || this.random.nextInt(3) == 0) && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call // Purpur - Config to always tame in Creative
|
||||
this.tame(player);
|
||||
this.navigation.stop();
|
||||
this.setTarget(null);
|
||||
@@ -0,0 +1,56 @@
|
||||
--- a/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
|
||||
+++ b/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
|
||||
@@ -39,6 +_,24 @@
|
||||
this.setPos(x, y, z);
|
||||
}
|
||||
|
||||
+ // Purpur start - End crystal explosion options
|
||||
+ public boolean shouldExplode() {
|
||||
+ return showsBottom() ? level().purpurConfig.basedEndCrystalExplode : level().purpurConfig.baselessEndCrystalExplode;
|
||||
+ }
|
||||
+
|
||||
+ public float getExplosionPower() {
|
||||
+ return (float) (showsBottom() ? level().purpurConfig.basedEndCrystalExplosionPower : level().purpurConfig.baselessEndCrystalExplosionPower);
|
||||
+ }
|
||||
+
|
||||
+ public boolean hasExplosionFire() {
|
||||
+ return showsBottom() ? level().purpurConfig.basedEndCrystalExplosionFire : level().purpurConfig.baselessEndCrystalExplosionFire;
|
||||
+ }
|
||||
+
|
||||
+ public Level.ExplosionInteraction getExplosionEffect() {
|
||||
+ return showsBottom() ? level().purpurConfig.basedEndCrystalExplosionEffect : level().purpurConfig.baselessEndCrystalExplosionEffect;
|
||||
+ }
|
||||
+ // Purpur end - End crystal explosion options
|
||||
+
|
||||
@Override
|
||||
protected Entity.MovementEmission getMovementEmission() {
|
||||
return Entity.MovementEmission.NONE;
|
||||
@@ -75,6 +_,8 @@
|
||||
}
|
||||
}
|
||||
// Paper end - Fix invulnerable end crystals
|
||||
+ if (this.level().purpurConfig.endCrystalCramming > 0 && this.level().getEntitiesOfClass(EndCrystal.class, getBoundingBox()).size() > this.level().purpurConfig.endCrystalCramming) this.hurt(this.damageSources().cramming(), 6.0F); // Purpur - End Crystal Cramming
|
||||
+
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,15 +_,17 @@
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (!source.is(DamageTypeTags.IS_EXPLOSION)) {
|
||||
+ if (shouldExplode()) {// Purpur - End crystal explosion options
|
||||
DamageSource damageSource = source.getEntity() != null ? this.damageSources().explosion(this, source.getEntity()) : null;
|
||||
// CraftBukkit start
|
||||
- org.bukkit.event.entity.ExplosionPrimeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExplosionPrimeEvent(this, 6.0F, false);
|
||||
+ org.bukkit.event.entity.ExplosionPrimeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExplosionPrimeEvent(this, getExplosionPower(), hasExplosionFire()); // Purpur - End crystal explosion options
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // Paper - add Bukkit remove cause
|
||||
- level.explode(this, damageSource, null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.BLOCK);
|
||||
+ level.explode(this, damageSource, null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), getExplosionEffect()); // Purpur - End crystal explosion options
|
||||
+ } else this.unsetRemoved(); // Purpur - End crystal explosion options
|
||||
} else {
|
||||
this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // Paper - add Bukkit remove cause
|
||||
// CraftBukkit end
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||
+++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||
@@ -964,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
protected boolean canRide(final Entity vehicle) {
|
||||
+ if (this.level().purpurConfig.enderDragonCanRideVehicles) return this.boardingCooldown <= 0; // Purpur - Configs for if Wither/Ender Dragon can ride vehicles
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -999,7 +_,7 @@
|
||||
boolean shouldDrop = level.getGameRules().get(GameRules.MOB_DROPS);
|
||||
int xpCount = 500;
|
||||
|
||||
- if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) {
|
||||
+ if (this.dragonFight != null && (level().purpurConfig.enderDragonAlwaysDropsFullExp || !this.dragonFight.hasPreviouslyKilledDragon())) { // Purpur - Ender dragon always drop full exp
|
||||
xpCount = 12000;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
+++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
@@ -82,6 +_,7 @@
|
||||
private static final TargetingConditions.Selector LIVING_ENTITY_SELECTOR = (target, level) -> !target.is(EntityTypeTags.WITHER_FRIENDS)
|
||||
&& target.attackable();
|
||||
private static final TargetingConditions TARGETING_CONDITIONS = TargetingConditions.forCombat().range(20.0).selector(LIVING_ENTITY_SELECTOR);
|
||||
+ private java.util.@Nullable UUID summoner; // Purpur - Summoner API
|
||||
|
||||
public WitherBoss(final EntityType<? extends WitherBoss> type, final Level level) {
|
||||
super(type, level);
|
||||
@@ -90,6 +_,16 @@
|
||||
this.xpReward = 50;
|
||||
}
|
||||
|
||||
+ // Purpur start - Summoner API
|
||||
+ public java.util.@Nullable UUID getSummoner() {
|
||||
+ return summoner;
|
||||
+ }
|
||||
+
|
||||
+ public void setSummoner(java.util.@Nullable UUID summoner) {
|
||||
+ this.summoner = summoner;
|
||||
+ }
|
||||
+ // Purpur end - Summoner API
|
||||
+
|
||||
@Override
|
||||
protected PathNavigation createNavigation(final Level level) {
|
||||
FlyingPathNavigation flyingPathNavigation = new FlyingPathNavigation(this, level);
|
||||
@@ -122,6 +_,7 @@
|
||||
protected void addAdditionalSaveData(final ValueOutput output) {
|
||||
super.addAdditionalSaveData(output);
|
||||
output.putInt("Invul", this.getInvulnerableTicks());
|
||||
+ output.storeNullable("Purpur.Summoner", net.minecraft.core.UUIDUtil.CODEC, getSummoner()); // Purpur - Summoner API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,6 +_,7 @@
|
||||
if (this.hasCustomName()) {
|
||||
this.bossEvent.setName(this.getDisplayName());
|
||||
}
|
||||
+ this.setSummoner(input.read("Purpur.Summoner", net.minecraft.core.UUIDUtil.CODEC).orElse(null)); // Purpur - Summoner API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -274,7 +_,7 @@
|
||||
level.explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB);
|
||||
}
|
||||
// CraftBukkit end
|
||||
- if (!this.isSilent()) {
|
||||
+ if (!this.isSilent() && level.purpurConfig.witherPlaySpawnSound) { // Purpur - Toggle for Wither's spawn sound
|
||||
// CraftBukkit start - Use relative location for far away sounds
|
||||
// level.globalLevelEvent(LevelEvent.SOUND_WITHER_BOSS_SPAWN, this.blockPosition(), 0);
|
||||
int viewDistance = level.getCraftServer().getViewDistance() * 16;
|
||||
@@ -378,8 +_,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (this.tickCount % 20 == 0) {
|
||||
- this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
|
||||
+ // Purpur start - Customizable wither health and healing - customizable heal rate and amount
|
||||
+ if (this.tickCount % level().purpurConfig.witherHealthRegenDelay == 0) {
|
||||
+ this.heal(level().purpurConfig.witherHealthRegenAmount, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
|
||||
+ // Purpur end - Customizable wither health and healing
|
||||
}
|
||||
|
||||
this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth());
|
||||
@@ -576,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
protected boolean canRide(final Entity vehicle) {
|
||||
+ if (this.level().purpurConfig.witherCanRideVehicles) return this.boardingCooldown <= 0; // Purpur - Configs for if Wither/Ender Dragon can ride vehicles
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
--- a/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -54,6 +_,12 @@
|
||||
public boolean canMobPickup = true; // Paper - Item#canEntityPickup
|
||||
private int despawnRate = -1; // Paper - Alternative item-despawn-rate
|
||||
public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API
|
||||
+ // Purpur start - Item entity immunities
|
||||
+ public boolean immuneToCactus = false;
|
||||
+ public boolean immuneToExplosion = false;
|
||||
+ public boolean immuneToFire = false;
|
||||
+ public boolean immuneToLightning = false;
|
||||
+ // Purpur end - Item entity immunities
|
||||
|
||||
public ItemEntity(final EntityType<? extends ItemEntity> type, final Level level) {
|
||||
super(type, level);
|
||||
@@ -314,7 +_,16 @@
|
||||
|
||||
@Override
|
||||
public final boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) {
|
||||
- if (this.isInvulnerableToBase(source)) {
|
||||
+ // Purpur start - Item entity immunities
|
||||
+ if (
|
||||
+ (immuneToCactus && source.is(net.minecraft.world.damagesource.DamageTypes.CACTUS)) ||
|
||||
+ (immuneToFire && (source.is(net.minecraft.tags.DamageTypeTags.IS_FIRE) || source.is(net.minecraft.world.damagesource.DamageTypes.ON_FIRE) || source.is(net.minecraft.world.damagesource.DamageTypes.IN_FIRE))) ||
|
||||
+ (immuneToLightning && source.is(net.minecraft.world.damagesource.DamageTypes.LIGHTNING_BOLT)) ||
|
||||
+ (immuneToExplosion && source.is(net.minecraft.tags.DamageTypeTags.IS_EXPLOSION))
|
||||
+ ) {
|
||||
+ return false;
|
||||
+ } else if (this.isInvulnerableToBase(source)) {
|
||||
+ // Purpur end - Item entity immunities
|
||||
return false;
|
||||
} else if (!level.getGameRules().get(GameRules.MOB_GRIEFING) && source.getEntity() instanceof Mob) {
|
||||
return false;
|
||||
@@ -492,6 +_,12 @@
|
||||
public void setItem(final ItemStack itemStack) {
|
||||
this.getEntityData().set(DATA_ITEM, itemStack);
|
||||
this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(itemStack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper - Alternative item-despawn-rate
|
||||
+ // Purpur start - Item entity immunities
|
||||
+ if (level().purpurConfig.itemImmuneToCactus.contains(itemStack.getItem())) immuneToCactus = true;
|
||||
+ if (level().purpurConfig.itemImmuneToExplosion.contains(itemStack.getItem())) immuneToExplosion = true;
|
||||
+ if (level().purpurConfig.itemImmuneToFire.contains(itemStack.getItem())) immuneToFire = true;
|
||||
+ if (level().purpurConfig.itemImmuneToLightning.contains(itemStack.getItem())) immuneToLightning = true;
|
||||
+ // level end - Item entity immunities
|
||||
}
|
||||
|
||||
public void setTarget(final @Nullable UUID target) {
|
||||
@@ -0,0 +1,65 @@
|
||||
--- a/net/minecraft/world/entity/monster/Creeper.java
|
||||
+++ b/net/minecraft/world/entity/monster/Creeper.java
|
||||
@@ -56,6 +_,7 @@
|
||||
public int explosionRadius = 3;
|
||||
public boolean droppedSkulls;
|
||||
public @Nullable Entity entityIgniter; // CraftBukkit
|
||||
+ private boolean exploding = false; // Purpur - Config to make Creepers explode on death
|
||||
|
||||
public Creeper(final EntityType<? extends Creeper> type, final Level level) {
|
||||
super(type, level);
|
||||
@@ -159,6 +_,27 @@
|
||||
return false; // CraftBukkit
|
||||
}
|
||||
|
||||
+ // Purpur start - Special mobs naturally spawn
|
||||
+ @Override
|
||||
+ public net.minecraft.world.entity.SpawnGroupData finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor world, net.minecraft.world.DifficultyInstance difficulty, net.minecraft.world.entity.EntitySpawnReason spawnReason, net.minecraft.world.entity.@Nullable SpawnGroupData entityData) {
|
||||
+ double chance = world.getLevel().purpurConfig.creeperChargedChance;
|
||||
+ if (chance > 0D && random.nextDouble() <= chance) {
|
||||
+ setPowered(true);
|
||||
+ }
|
||||
+ return super.finalizeSpawn(world, difficulty, spawnReason, entityData);
|
||||
+ }
|
||||
+ // Purpur end - Special mobs naturally spawn
|
||||
+
|
||||
+ // Purpur start - Config to make Creepers explode on death
|
||||
+ @Override
|
||||
+ protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(ServerLevel world, DamageSource damageSource) {
|
||||
+ if (!this.exploding && this.level().purpurConfig.creeperExplodeWhenKilled && damageSource.getEntity() instanceof net.minecraft.server.level.ServerPlayer) {
|
||||
+ this.explodeCreeper();
|
||||
+ }
|
||||
+ return super.dropAllDeathLoot(world, damageSource);
|
||||
+ }
|
||||
+ // Purpur end - Config to make Creepers explode on death
|
||||
+
|
||||
@Override
|
||||
public SoundEvent getHurtSound(final DamageSource source) {
|
||||
return SoundEvents.CREEPER_HURT;
|
||||
@@ -243,14 +_,16 @@
|
||||
}
|
||||
|
||||
public void explodeCreeper() {
|
||||
+ this.exploding = true; // Purpur - Config to make Creepers explode on death
|
||||
if (this.level() instanceof ServerLevel level) {
|
||||
float explosionMultiplier = this.isPowered() ? 2.0F : 1.0F;
|
||||
+ float multiplier = level.purpurConfig.creeperHealthRadius ? this.getHealth() / this.getMaxHealth() : 1; // Purpur - Config for health to impact Creeper explosion radius
|
||||
// CraftBukkit start
|
||||
- org.bukkit.event.entity.ExplosionPrimeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExplosionPrimeEvent(this, this.explosionRadius * explosionMultiplier, false);
|
||||
+ org.bukkit.event.entity.ExplosionPrimeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExplosionPrimeEvent(this, (this.explosionRadius * explosionMultiplier) * multiplier, false); // Purpur - Config for health to impact Creeper explosion radius
|
||||
if (!event.isCancelled()) {
|
||||
// CraftBukkit end
|
||||
this.dead = true;
|
||||
- level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); // CraftBukkit // Paper - fix DamageSource API (revert to vanilla, no, just no, don't change this)
|
||||
+ level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), level.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.MOB_GRIEFING) && level().purpurConfig.creeperAllowGriefing ? Level.ExplosionInteraction.MOB : Level.ExplosionInteraction.NONE); // CraftBukkit // Paper - fix DamageSource API (revert to vanilla, no, just no, don't change this) // Purpur - Add enderman and creeper griefing controls
|
||||
this.spawnLingeringCloud();
|
||||
this.triggerOnDeathMobEffects(level, Entity.RemovalReason.KILLED);
|
||||
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
|
||||
@@ -261,6 +_,7 @@
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
+ this.exploding = false; // Purpur - Config to make Creepers explode on death
|
||||
}
|
||||
|
||||
private void spawnLingeringCloud() {
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/world/entity/monster/Ghast.java
|
||||
+++ b/net/minecraft/world/entity/monster/Ghast.java
|
||||
@@ -156,6 +_,11 @@
|
||||
public static boolean checkGhastSpawnRules(
|
||||
final EntityType<Ghast> type, final LevelAccessor level, final EntitySpawnReason spawnReason, final BlockPos pos, final RandomSource random
|
||||
) {
|
||||
+ // Purpur start - Config to disable hostile mob spawn on ice
|
||||
+ if (net.minecraft.world.entity.monster.Monster.canSpawnInBlueAndPackedIce(level, pos)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end - Config to disable hostile mob spawn on ice
|
||||
return level.getDifficulty() != Difficulty.PEACEFUL && random.nextInt(20) == 0 && checkMobSpawnRules(type, level, spawnReason, pos, random);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
--- a/net/minecraft/world/entity/monster/Monster.java
|
||||
+++ b/net/minecraft/world/entity/monster/Monster.java
|
||||
@@ -84,6 +_,11 @@
|
||||
}
|
||||
|
||||
public static boolean isDarkEnoughToSpawn(final ServerLevelAccessor level, final BlockPos pos, final RandomSource random) {
|
||||
+ // Purpur start - Config to disable hostile mob spawn on ice
|
||||
+ if (canSpawnInBlueAndPackedIce(level, pos)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end - Config to disable hostile mob spawn on ice
|
||||
if (level.getBrightness(LightLayer.SKY, pos) > random.nextInt(32)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -113,6 +_,11 @@
|
||||
public static boolean checkAnyLightMonsterSpawnRules(
|
||||
final EntityType<? extends Monster> type, final LevelAccessor level, final EntitySpawnReason spawnReason, final BlockPos pos, final RandomSource random
|
||||
) {
|
||||
+ // Purpur start - Config to disable hostile mob spawn on ice
|
||||
+ if (canSpawnInBlueAndPackedIce(level, pos)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end - Config to disable hostile mob spawn on ice
|
||||
return level.getDifficulty() != Difficulty.PEACEFUL && checkMobSpawnRules(type, level, spawnReason, pos, random);
|
||||
}
|
||||
|
||||
@@ -154,4 +_,12 @@
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Purpur start - Config to disable hostile mob spawn on ice
|
||||
+ public static boolean canSpawnInBlueAndPackedIce(LevelAccessor level, BlockPos pos) {
|
||||
+ net.minecraft.world.level.block.state.BlockState spawnBlock = level.getBlockState(pos.below());
|
||||
+
|
||||
+ return (!level.getMinecraftWorld().purpurConfig.mobsSpawnOnPackedIce && spawnBlock.is(net.minecraft.world.level.block.Blocks.PACKED_ICE)) || (!level.getMinecraftWorld().purpurConfig.mobsSpawnOnBlueIce && spawnBlock.is(net.minecraft.world.level.block.Blocks.BLUE_ICE));
|
||||
+ }
|
||||
+ // Purpur end - Config to disable hostile mob spawn on ice
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/world/entity/monster/Phantom.java
|
||||
+++ b/net/minecraft/world/entity/monster/Phantom.java
|
||||
@@ -167,7 +_,11 @@
|
||||
final ServerLevelAccessor level, final DifficultyInstance difficulty, final EntitySpawnReason spawnReason, final @Nullable SpawnGroupData groupData
|
||||
) {
|
||||
this.anchorPoint = this.blockPosition().above(5);
|
||||
- this.setPhantomSize(0);
|
||||
+ // Purpur start - Configurable phantom size
|
||||
+ int min = level.getLevel().purpurConfig.phantomMinSize;
|
||||
+ int max = level.getLevel().purpurConfig.phantomMaxSize;
|
||||
+ this.setPhantomSize(min == max ? min : level.getRandom().nextInt(max + 1 - min) + min);
|
||||
+ // Purpur end - Configurable phantom size
|
||||
return super.finalizeSpawn(level, difficulty, spawnReason, groupData);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/world/entity/monster/Ravager.java
|
||||
+++ b/net/minecraft/world/entity/monster/Ravager.java
|
||||
@@ -74,6 +_,7 @@
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.goalSelector.addGoal(0, new FloatGoal(this));
|
||||
+ if (level().purpurConfig.ravagerAvoidRabbits) this.goalSelector.addGoal(3, new net.minecraft.world.entity.ai.goal.AvoidEntityGoal<>(this, net.minecraft.world.entity.animal.rabbit.Rabbit.class, 6.0F, 1.0D, 1.2D)); // Purpur - option to make ravagers afraid of rabbits
|
||||
this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.0, true));
|
||||
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 0.4));
|
||||
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
|
||||
@@ -152,7 +_,7 @@
|
||||
)) {
|
||||
BlockState state = serverLevel.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
- if (block instanceof LeavesBlock) {
|
||||
+ if (this.level().purpurConfig.ravagerGriefableBlocks.contains(block)) { // Purpur - Configurable ravager griefable blocks list
|
||||
// CraftBukkit start
|
||||
if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, state.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state
|
||||
continue;
|
||||
@@ -9,3 +9,60 @@
|
||||
private float currentPeekAmountO;
|
||||
private float currentPeekAmount;
|
||||
private @Nullable BlockPos clientOldAttachPosition;
|
||||
@@ -94,6 +_,21 @@
|
||||
this.lookControl = new Shulker.ShulkerLookControl(this);
|
||||
}
|
||||
|
||||
+ // Purpur start - Shulker change color with dye
|
||||
+ @Override
|
||||
+ protected net.minecraft.world.InteractionResult mobInteract(Player player, net.minecraft.world.InteractionHand hand) {
|
||||
+ net.minecraft.world.item.ItemStack itemstack = player.getItemInHand(hand);
|
||||
+ if (player.level().purpurConfig.shulkerChangeColorWithDye && itemstack.getItem() instanceof net.minecraft.world.item.DyeItem dye && dye.getDyeColor() != this.getColor()) {
|
||||
+ this.setVariant(Optional.of(dye.getDyeColor()));
|
||||
+ if (!player.getAbilities().instabuild) {
|
||||
+ itemstack.shrink(1);
|
||||
+ }
|
||||
+ return net.minecraft.world.InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ return super.mobInteract(player, hand);
|
||||
+ }
|
||||
+ // Purpur end - Shulker change color with dye
|
||||
+
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, Player.class, 8.0F, 0.02F, true));
|
||||
@@ -455,11 +_,21 @@
|
||||
private void hitByShulkerBullet() {
|
||||
Vec3 oldPosition = this.position();
|
||||
AABB oldAabb = this.getBoundingBox();
|
||||
- if (!this.isClosed() && this.teleportSomewhere()) {
|
||||
- int shulkerCount = this.level().getEntities(EntityType.SHULKER, oldAabb.inflate(8.0), Entity::isAlive).size();
|
||||
- float failureChance = (shulkerCount - 1) / 5.0F;
|
||||
- if (!(this.level().getRandom().nextFloat() < failureChance)) {
|
||||
+ // Purpur start - Shulker spawn from bullet options
|
||||
+ if ((!this.level().purpurConfig.shulkerSpawnFromBulletRequireOpenLid || !this.isClosed()) && this.teleportSomewhere()) {
|
||||
+ float failureChance = this.level().purpurConfig.shulkerSpawnFromBulletBaseChance;
|
||||
+ if (!this.level().purpurConfig.shulkerSpawnFromBulletNearbyEquation.isBlank()) {
|
||||
+ int shulkerCount = this.level().getEntities((net.minecraft.world.level.entity.EntityTypeTest) EntityType.SHULKER, oldAabb.inflate(this.level().purpurConfig.shulkerSpawnFromBulletNearbyRange), Entity::isAlive).size();
|
||||
+ try {
|
||||
+ failureChance -= ((Number) scriptEngine.eval("let shulkerCount = " + shulkerCount + "; " + this.level().purpurConfig.shulkerSpawnFromBulletNearbyEquation)).floatValue();
|
||||
+ } catch (javax.script.ScriptException e) {
|
||||
+ e.printStackTrace();
|
||||
+ failureChance -= (shulkerCount - 1) / 5.0F;
|
||||
+ }
|
||||
+ }
|
||||
+ if (this.level().getRandom().nextFloat() <= failureChance) {
|
||||
Shulker baby = EntityType.SHULKER.create(this.level(), EntitySpawnReason.BREEDING);
|
||||
+ // Purpur end - Shulker spawn from bullet options
|
||||
if (baby != null) {
|
||||
baby.setVariant(this.getVariant());
|
||||
baby.snapTo(oldPosition);
|
||||
@@ -566,7 +_,7 @@
|
||||
}
|
||||
|
||||
public Optional<DyeColor> getVariant() {
|
||||
- return Optional.ofNullable(this.getColor());
|
||||
+ return Optional.ofNullable(this.level().purpurConfig.shulkerSpawnFromBulletRandomColor ? DyeColor.random(this.level().random) : this.getColor()); // Purpur - Shulker spawn from bullet options
|
||||
}
|
||||
|
||||
public @Nullable DyeColor getColor() {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/net/minecraft/world/entity/monster/Strider.java
|
||||
+++ b/net/minecraft/world/entity/monster/Strider.java
|
||||
@@ -400,6 +_,18 @@
|
||||
@Override
|
||||
public InteractionResult mobInteract(final Player player, final InteractionHand hand) {
|
||||
boolean hasFood = this.isFood(player.getItemInHand(hand));
|
||||
+ // Purpur start
|
||||
+ if (level().purpurConfig.striderGiveSaddleBack && player.isSecondaryUseActive() && !isFood && isSaddled() && !isVehicle()) {
|
||||
+ this.setItemSlot(EquipmentSlot.SADDLE, ItemStack.EMPTY);
|
||||
+ if (!player.getAbilities().instabuild) {
|
||||
+ ItemStack saddle = new ItemStack(Items.SADDLE);
|
||||
+ if (!player.getInventory().add(saddle)) {
|
||||
+ player.drop(saddle, false);
|
||||
+ }
|
||||
+ }
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
if (!hasFood && this.isSaddled() && !this.isVehicle() && !player.isSecondaryUseActive()) {
|
||||
if (!this.level().isClientSide()) {
|
||||
player.startRiding(this);
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/world/entity/monster/illager/Vindicator.java
|
||||
+++ b/net/minecraft/world/entity/monster/illager/Vindicator.java
|
||||
@@ -131,6 +_,11 @@
|
||||
RandomSource random = level.getRandom();
|
||||
this.populateDefaultEquipmentSlots(random, difficulty);
|
||||
this.populateDefaultEquipmentEnchantments(level, random, difficulty);
|
||||
+ // Purpur start - Special mobs naturally spawn
|
||||
+ if (level().purpurConfig.vindicatorJohnnySpawnChance > 0D && random.nextDouble() <= level().purpurConfig.vindicatorJohnnySpawnChance) {
|
||||
+ setCustomName(Component.translatable("Johnny"));
|
||||
+ }
|
||||
+ // Purpur end - Special mobs naturally spawn
|
||||
return spawnGroupData;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
+++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
@@ -669,14 +_,24 @@
|
||||
}
|
||||
|
||||
public static boolean isWearingSafeArmor(final LivingEntity livingEntity) {
|
||||
- for (EquipmentSlot slot : EquipmentSlotGroup.ARMOR) {
|
||||
- if (livingEntity.getItemBySlot(slot).is(ItemTags.PIGLIN_SAFE_ARMOR)) {
|
||||
+ for (EquipmentSlot equipmentSlot : EquipmentSlotGroup.ARMOR) {
|
||||
+ // Purpur start - piglins ignore gold-trimmed armor
|
||||
+ net.minecraft.world.item.ItemStack itemStack = livingEntity.getItemBySlot(equipmentSlot);
|
||||
+ if (itemStack.is(ItemTags.PIGLIN_SAFE_ARMOR) || (livingEntity.level().purpurConfig.piglinIgnoresArmorWithGoldTrim && isWearingGoldTrim(itemStack))) {
|
||||
+ // Purpur end - piglins ignore gold-trimmed armor
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
+
|
||||
+ // Purpur start - piglins ignore gold-trimmed armor
|
||||
+ private static boolean isWearingGoldTrim(net.minecraft.world.item.ItemStack itemstack) {
|
||||
+ net.minecraft.world.item.equipment.trim.ArmorTrim armorTrim = itemstack.getComponents().get(net.minecraft.core.component.DataComponents.TRIM);
|
||||
+ return armorTrim != null && armorTrim.material().is(net.minecraft.world.item.equipment.trim.TrimMaterials.GOLD);
|
||||
+ }
|
||||
+ // Purpur end - piglins ignore gold-trimmed armor
|
||||
|
||||
private static void stopWalking(final Piglin body) {
|
||||
body.getBrain().eraseMemory(MemoryModuleType.WALK_TARGET);
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java
|
||||
+++ b/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java
|
||||
@@ -142,7 +_,7 @@
|
||||
this.populateDefaultEquipmentEnchantments(level, random, difficulty);
|
||||
this.reassessWeaponGoal();
|
||||
this.setCanPickUpLoot(level.getLevel().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.skeletons || random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper - Add world settings for mobs picking up loot
|
||||
- if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty() && SpecialDates.isHalloween() && random.nextFloat() < 0.25F) {
|
||||
+ if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty() && (level.getLevel().purpurConfig.forceHalloweenSeason || SpecialDates.isHalloween()) && random.nextFloat() < this.level().purpurConfig.chanceHeadHalloweenOnEntity) { // Purpur - Halloween options and optimizations
|
||||
this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN));
|
||||
this.setDropChance(EquipmentSlot.HEAD, 0.0F);
|
||||
}
|
||||
@@ -189,7 +_,7 @@
|
||||
double distanceToTarget = Math.sqrt(xd * xd + zd * zd);
|
||||
if (this.level() instanceof ServerLevel serverLevel) {
|
||||
Projectile.Delayed<AbstractArrow> delayedEntity = Projectile.spawnProjectileUsingShootDelayed( // Paper - delayed
|
||||
- arrow, serverLevel, projectile, xd, yd + distanceToTarget * 0.2F, zd, 1.6F, 14 - serverLevel.getDifficulty().getId() * 4
|
||||
+ arrow, serverLevel, projectile, xd, yd + distanceToTarget * 0.2F, zd, 1.6F, serverLevel.purpurConfig.skeletonBowAccuracyMap.getOrDefault(serverLevel.getDifficulty().getId(), (float) (14 - serverLevel.getDifficulty().getId() * 4)) // Purpur - skeleton bow accuracy option
|
||||
);
|
||||
|
||||
// Paper start - call EntityShootBowEvent
|
||||
@@ -0,0 +1,27 @@
|
||||
--- a/net/minecraft/world/entity/monster/zombie/Drowned.java
|
||||
+++ b/net/minecraft/world/entity/monster/zombie/Drowned.java
|
||||
@@ -93,10 +_,23 @@
|
||||
this.goalSelector.addGoal(2, new Drowned.DrownedAttackGoal(this, 1.0, false));
|
||||
this.goalSelector.addGoal(5, new Drowned.DrownedGoToBeachGoal(this, 1.0));
|
||||
this.goalSelector.addGoal(6, new Drowned.DrownedSwimUpGoal(this, 1.0, this.level().getSeaLevel()));
|
||||
+ if (level().purpurConfig.drownedBreakDoors) this.goalSelector.addGoal(6, new net.minecraft.world.entity.ai.goal.MoveThroughVillageGoal(this, 1.0D, true, 4, this::canBreakDoors)); // Purpur - Option to make drowned break doors
|
||||
this.goalSelector.addGoal(7, new RandomStrollGoal(this, 1.0));
|
||||
this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Drowned.class).setAlertOthers(ZombifiedPiglin.class));
|
||||
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (target, level) -> this.okTarget(target)));
|
||||
- if (this.level().spigotConfig.zombieAggressiveTowardsVillager) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); // Paper - Check drowned for villager aggression config
|
||||
+ // Purpur start - Add option to disable zombie aggressiveness towards villagers
|
||||
+ if (this.level().spigotConfig.zombieAggressiveTowardsVillager) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false) { // Paper - Check drowned for villager aggression config
|
||||
+ @Override
|
||||
+ public boolean canUse() {
|
||||
+ return (level().purpurConfig.zombieAggressiveTowardsVillagerWhenLagging || !level().getServer().server.isLagging()) && super.canUse();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean canContinueToUse() {
|
||||
+ return (level().purpurConfig.zombieAggressiveTowardsVillagerWhenLagging || !level().getServer().server.isLagging()) && super.canContinueToUse();
|
||||
+ }
|
||||
+ });
|
||||
+ // Purpur end - Add option to disable zombie aggressiveness towards villagers
|
||||
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true));
|
||||
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Axolotl.class, true, false));
|
||||
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR));
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/world/entity/monster/zombie/ZombieVillager.java
|
||||
+++ b/net/minecraft/world/entity/monster/zombie/ZombieVillager.java
|
||||
@@ -170,10 +_,10 @@
|
||||
public InteractionResult mobInteract(final Player player, final InteractionHand hand) {
|
||||
ItemStack itemStack = player.getItemInHand(hand);
|
||||
if (itemStack.is(Items.GOLDEN_APPLE)) {
|
||||
- if (this.hasEffect(MobEffects.WEAKNESS)) {
|
||||
+ if (this.hasEffect(MobEffects.WEAKNESS) && level().purpurConfig.zombieVillagerCureEnabled) { // Purpur - Add option to disable zombie villagers cure
|
||||
itemStack.consume(1, player);
|
||||
if (!this.level().isClientSide()) {
|
||||
- this.startConverting(player.getUUID(), this.random.nextInt(2401) + 3600);
|
||||
+ this.startConverting(player.getUUID(), this.random.nextInt(level().purpurConfig.zombieVillagerCuringTimeMax - level().purpurConfig.zombieVillagerCuringTimeMin + 1) + level().purpurConfig.zombieVillagerCuringTimeMin); // Purpur - Customizable Zombie Villager curing times
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
@@ -0,0 +1,123 @@
|
||||
--- a/net/minecraft/world/entity/npc/villager/Villager.java
|
||||
+++ b/net/minecraft/world/entity/npc/villager/Villager.java
|
||||
@@ -181,6 +_,8 @@
|
||||
MemoryModuleType.MEETING_POINT,
|
||||
(villager, poiType) -> poiType.is(PoiTypes.MEETING)
|
||||
);
|
||||
+ private boolean isLobotomized = false; public boolean isLobotomized() { return this.isLobotomized; } // Purpur - Lobotomize stuck villagers
|
||||
+ private int notLobotomizedCount = 0; // Purpur - Lobotomize stuck villagers
|
||||
|
||||
public Villager(final EntityType<? extends Villager> type, final Level level) {
|
||||
this(type, level, VillagerType.PLAINS);
|
||||
@@ -199,6 +_,57 @@
|
||||
this.setVillagerData(this.getVillagerData().withType(type).withProfession(level.registryAccess(), VillagerProfession.NONE));
|
||||
}
|
||||
|
||||
+ // Purpur start - Allow leashing villagers
|
||||
+ @Override
|
||||
+ public boolean canBeLeashed() {
|
||||
+ return level().purpurConfig.villagerCanBeLeashed;
|
||||
+ }
|
||||
+ // Purpur end - Allow leashing villagers
|
||||
+
|
||||
+ // Purpur start - Lobotomize stuck villagers
|
||||
+ private boolean checkLobotomized() {
|
||||
+ int interval = this.level().purpurConfig.villagerLobotomizeCheckInterval;
|
||||
+ boolean shouldCheckForTradeLocked = this.level().purpurConfig.villagerLobotomizeWaitUntilTradeLocked;
|
||||
+ if (this.notLobotomizedCount > 3) {
|
||||
+ // check half as often if not lobotomized for the last 3+ consecutive checks
|
||||
+ interval *= 2;
|
||||
+ }
|
||||
+ if (this.level().getGameTime() % interval == 0) {
|
||||
+ // offset Y for short blocks like dirt_path/farmland
|
||||
+ this.isLobotomized = !(shouldCheckForTradeLocked && this.getVillagerXp() == 0) && !canTravelFrom(BlockPos.containing(this.position().x, this.getBoundingBox().minY + 0.0625D, this.position().z));
|
||||
+
|
||||
+ if (this.isLobotomized) {
|
||||
+ this.notLobotomizedCount = 0;
|
||||
+ } else {
|
||||
+ this.notLobotomizedCount++;
|
||||
+ }
|
||||
+ }
|
||||
+ return this.isLobotomized;
|
||||
+ }
|
||||
+
|
||||
+ private boolean canTravelFrom(BlockPos pos) {
|
||||
+ return canTravelTo(pos.east()) || canTravelTo(pos.west()) || canTravelTo(pos.north()) || canTravelTo(pos.south());
|
||||
+ }
|
||||
+
|
||||
+ private boolean canTravelTo(BlockPos pos) {
|
||||
+ net.minecraft.world.level.block.state.BlockState state = this.level().getBlockStateIfLoaded(pos);
|
||||
+ if (state == null) {
|
||||
+ // chunk not loaded
|
||||
+ return false;
|
||||
+ }
|
||||
+ net.minecraft.world.level.block.Block bottom = state.getBlock();
|
||||
+ if (bottom instanceof net.minecraft.world.level.block.FenceBlock ||
|
||||
+ bottom instanceof net.minecraft.world.level.block.FenceGateBlock ||
|
||||
+ bottom instanceof net.minecraft.world.level.block.WallBlock) {
|
||||
+ // bottom block is too tall to get over
|
||||
+ return false;
|
||||
+ }
|
||||
+ net.minecraft.world.level.block.Block top = level().getBlockState(pos.above()).getBlock();
|
||||
+ // only if both blocks have no collision
|
||||
+ return !bottom.hasCollision && !top.hasCollision;
|
||||
+ }
|
||||
+ // Purpur end - Lobotomize stuck villagers
|
||||
+
|
||||
@Override
|
||||
public Brain<Villager> getBrain() {
|
||||
return (Brain<Villager>) super.getBrain();
|
||||
@@ -248,7 +_,18 @@
|
||||
protected void customServerAiStep(final ServerLevel level) {
|
||||
ProfilerFiller profiler = Profiler.get();
|
||||
profiler.push("villagerBrain");
|
||||
- this.getBrain().tick(level, this);
|
||||
+ // Purpur start - Lobotomize stuck villagers
|
||||
+ if (this.level().purpurConfig.villagerLobotomizeEnabled) {
|
||||
+ // treat as inactive if lobotomized
|
||||
+ inactive = inactive || checkLobotomized();
|
||||
+ } else {
|
||||
+ this.isLobotomized = false;
|
||||
+ }
|
||||
+ if (!inactive) {
|
||||
+ this.getBrain().tick(level, this); // Paper - EAR 2
|
||||
+ }
|
||||
+ else if (this.isLobotomized && shouldRestock(level)) restock();
|
||||
+ // Purpur end - Lobotomize stuck villagers
|
||||
profiler.pop();
|
||||
if (this.assignProfessionWhenSpawned) {
|
||||
this.assignProfessionWhenSpawned = false;
|
||||
@@ -319,6 +_,7 @@
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
|
||||
+ if (this.level().purpurConfig.villagerAllowTrading) // Purpur - Add config for villager trading
|
||||
this.startTrading(player);
|
||||
}
|
||||
|
||||
@@ -460,7 +_,7 @@
|
||||
|
||||
public void updateDemand() {
|
||||
for (MerchantOffer offer : this.getOffers()) {
|
||||
- offer.updateDemand();
|
||||
+ offer.updateDemand(this.level().purpurConfig.villagerMinimumDemand); // Purpur - Configurable minimum demand for trades
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean canBreed() {
|
||||
- return this.foodLevel + this.countFoodPointsInInventory() >= 12 && !this.isSleeping() && this.getAge() == 0;
|
||||
+ return this.level().purpurConfig.villagerCanBreed && this.foodLevel + this.countFoodPointsInInventory() >= 12 && !this.isSleeping() && this.getAge() == 0; // Purpur - Configurable villager breeding
|
||||
}
|
||||
|
||||
private boolean hungry() {
|
||||
@@ -867,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void spawnGolemIfNeeded(final ServerLevel level, final long timestamp, final int villagersNeededToAgree) {
|
||||
+ if (level.purpurConfig.villagerSpawnIronGolemRadius > 0 && level.getEntitiesOfClass(net.minecraft.world.entity.animal.golem.IronGolem.class, getBoundingBox().inflate(level.purpurConfig.villagerSpawnIronGolemRadius)).size() > level.purpurConfig.villagerSpawnIronGolemLimit) return; // Purpur - Implement configurable search radius for villagers to spawn iron golems
|
||||
if (this.wantsToSpawnGolem(timestamp)) {
|
||||
AABB villagerSearchBox = this.getBoundingBox().inflate(10.0, 10.0, 10.0);
|
||||
List<Villager> nearbyVillagers = level.getEntitiesOfClass(Villager.class, villagerSearchBox);
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java
|
||||
+++ b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java
|
||||
@@ -133,7 +_,17 @@
|
||||
int xPosition = referencePosition.getX() + this.random.nextInt(radius * 2) - radius;
|
||||
int zPosition = referencePosition.getZ() + this.random.nextInt(radius * 2) - radius;
|
||||
int yPosition = level.getHeight(SpawnPlacements.getHeightmapType(EntityType.WANDERING_TRADER), xPosition, zPosition);
|
||||
- BlockPos spawnPos = new BlockPos(xPosition, yPosition, zPosition);
|
||||
+ // Purpur start - Allow toggling special MobSpawners per world - allow traders to spawn below nether roof
|
||||
+ BlockPos.MutableBlockPos spawnPos = new BlockPos.MutableBlockPos(xPosition, yPosition, zPosition);
|
||||
+ if (level.dimensionType().hasCeiling()) {
|
||||
+ do {
|
||||
+ spawnPos.relative(net.minecraft.core.Direction.DOWN);
|
||||
+ } while (!level.getBlockState(spawnPos).isAir());
|
||||
+ do {
|
||||
+ spawnPos.relative(net.minecraft.core.Direction.DOWN);
|
||||
+ } while (level.getBlockState(spawnPos).isAir() && spawnPos.getY() > 0);
|
||||
+ }
|
||||
+ // Purpur end - Allow toggling special MobSpawners per world
|
||||
if (wanderingTraderSpawnType.isSpawnPositionOk(level, spawnPos, EntityType.WANDERING_TRADER)) {
|
||||
spawnPosition = spawnPos;
|
||||
break;
|
||||
@@ -0,0 +1,17 @@
|
||||
--- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java
|
||||
+++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java
|
||||
@@ -122,7 +_,13 @@
|
||||
} else if (slotIndex != 1 && slotIndex != 0) {
|
||||
if (this.canSmelt(stack)) {
|
||||
if (!this.moveItemStackTo(stack, 0, 1, false)) {
|
||||
- return ItemStack.EMPTY;
|
||||
+ // Purpur start - Added the ability to add combustible items
|
||||
+ if (this.isFuel(item)) {
|
||||
+ if (!this.moveItemStackTo(item, 1, 2, false)) {
|
||||
+ return ItemStack.EMPTY;
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Added the ability to add combustible items
|
||||
}
|
||||
} else if (this.isFuel(stack)) {
|
||||
if (!this.moveItemStackTo(stack, 1, 2, false)) {
|
||||
@@ -0,0 +1,196 @@
|
||||
--- a/net/minecraft/world/inventory/AnvilMenu.java
|
||||
+++ b/net/minecraft/world/inventory/AnvilMenu.java
|
||||
@@ -23,6 +_,12 @@
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// Purpur start - Anvil API
|
||||
+import net.minecraft.network.protocol.game.ClientboundContainerSetDataPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+// Purpur end - Anvil API
|
||||
+
|
||||
public class AnvilMenu extends ItemCombinerMenu {
|
||||
public static final int INPUT_SLOT = 0;
|
||||
public static final int ADDITIONAL_SLOT = 1;
|
||||
@@ -51,6 +_,10 @@
|
||||
private org.bukkit.craftbukkit.inventory.view.CraftAnvilView bukkitEntity;
|
||||
// CraftBukkit end
|
||||
public boolean bypassEnchantmentLevelRestriction = false; // Paper - bypass anvil level restrictions
|
||||
+ // Purpur start - Anvil API
|
||||
+ public boolean bypassCost = false;
|
||||
+ public boolean canDoUnsafeEnchants = false;
|
||||
+ // Purpur end - Anvil API
|
||||
|
||||
public AnvilMenu(final int containerId, final Inventory inventory) {
|
||||
this(containerId, inventory, ContainerLevelAccess.NULL);
|
||||
@@ -76,12 +_,17 @@
|
||||
|
||||
@Override
|
||||
protected boolean mayPickup(final Player player, final boolean hasItem) {
|
||||
- return (player.hasInfiniteMaterials() || player.experienceLevel >= this.cost.get()) && this.cost.get() > AnvilMenu.DEFAULT_DENIED_COST && hasItem; // CraftBukkit - allow cost 0 like a free item
|
||||
+ return (player.hasInfiniteMaterials() || player.experienceLevel >= this.cost.get()) && (this.bypassCost || this.cost.get() > AnvilMenu.DEFAULT_DENIED_COST) && hasItem; // CraftBukkit - allow cost 0 like a free item // Purpur - Anvil API
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTake(final Player player, final ItemStack carried) {
|
||||
+ // Purpur start - Anvil API
|
||||
+ ItemStack itemstack = this.activeQuickItem != null ? this.activeQuickItem : carried;
|
||||
+ if (org.purpurmc.purpur.event.inventory.AnvilTakeResultEvent.getHandlerList().getRegisteredListeners().length > 0) new org.purpurmc.purpur.event.inventory.AnvilTakeResultEvent(player.getBukkitEntity(), getBukkitView(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)).callEvent();
|
||||
+ // Purpur end - Anvil API
|
||||
if (!player.hasInfiniteMaterials()) {
|
||||
+ if (this.bypassCost) ((ServerPlayer) player).lastSentExp = -1; else // Purpur - Anvil API
|
||||
player.giveExperienceLevels(-this.cost.get());
|
||||
}
|
||||
|
||||
@@ -134,13 +_,19 @@
|
||||
|
||||
@Override
|
||||
public void createResult() {
|
||||
+ // Purpur start - Anvil API
|
||||
+ this.bypassCost = false;
|
||||
+ this.canDoUnsafeEnchants = false;
|
||||
+ if (org.purpurmc.purpur.event.inventory.AnvilUpdateResultEvent.getHandlerList().getRegisteredListeners().length > 0) new org.purpurmc.purpur.event.inventory.AnvilUpdateResultEvent(getBukkitView()).callEvent();
|
||||
+ // Purpur end - Anvil API
|
||||
+
|
||||
ItemStack input = this.inputSlots.getItem(0);
|
||||
this.onlyRenaming = false;
|
||||
this.cost.set(1);
|
||||
int price = 0;
|
||||
long tax = 0L;
|
||||
int namingCost = 0;
|
||||
- if (!input.isEmpty() && EnchantmentHelper.canStoreEnchantments(input)) {
|
||||
+ if (!input.isEmpty() && this.canDoUnsafeEnchants || EnchantmentHelper.canStoreEnchantments(input)) { // Purpur - Anvil API
|
||||
ItemStack result = input.copy();
|
||||
ItemStack addition = this.inputSlots.getItem(1);
|
||||
ItemEnchantments.Mutable enchantments = new ItemEnchantments.Mutable(EnchantmentHelper.getEnchantmentsForCrafting(result));
|
||||
@@ -198,23 +_,34 @@
|
||||
int level = entry.getIntValue();
|
||||
level = current == level ? level + 1 : Math.max(level, current);
|
||||
Enchantment enchantment = enchantmentHolder.value();
|
||||
- boolean compatible = enchantment.canEnchant(input);
|
||||
+ // Purpur start - Config to allow unsafe enchants
|
||||
+ boolean compatible = this.canDoUnsafeEnchants || org.purpurmc.purpur.PurpurConfig.allowInapplicableEnchants || enchantment.canEnchant(input); // whether the enchantment can be applied on specific item type
|
||||
+ boolean canEnchant1 = true; // whether two incompatible enchantments can be applied on a single item
|
||||
+ // Purpur end - Config to allow unsafe enchants
|
||||
if (this.player.hasInfiniteMaterials() || input.is(Items.ENCHANTED_BOOK)) {
|
||||
compatible = true;
|
||||
}
|
||||
|
||||
+ java.util.Set<Holder<Enchantment>> removedEnchantments = new java.util.HashSet<>(); // Purpur - Config to allow unsafe enchants
|
||||
for (Holder<Enchantment> other : enchantments.keySet()) {
|
||||
if (!other.equals(enchantmentHolder) && !Enchantment.areCompatible(enchantmentHolder, other)) {
|
||||
- compatible = false;
|
||||
+ canEnchant1 = this.canDoUnsafeEnchants || org.purpurmc.purpur.PurpurConfig.allowIncompatibleEnchants; // Purpur - Anvil API // Purpur - canEnchant -> canEnchant1 - Config to allow unsafe enchants
|
||||
+ // Purpur start - Config to allow unsafe enchants
|
||||
+ if (!canEnchant1 && org.purpurmc.purpur.PurpurConfig.replaceIncompatibleEnchants) {
|
||||
+ removedEnchantments.add(other);
|
||||
+ canEnchant1 = true;
|
||||
+ }
|
||||
+ // Purpur end - Config to allow unsafe enchants
|
||||
price++;
|
||||
}
|
||||
}
|
||||
+ mutable.removeIf(removedEnchantments::contains); // Purpur - Config to allow unsafe enchants
|
||||
|
||||
- if (!compatible) {
|
||||
+ if (!compatible || !canEnchant1) { // Purpur - Config to allow unsafe enchants
|
||||
isAnyEnchantmentNotCompatible = true;
|
||||
} else {
|
||||
isAnyEnchantmentCompatible = true;
|
||||
- if (level > enchantment.getMaxLevel() && !this.bypassEnchantmentLevelRestriction) { // Paper - bypass anvil level restrictions
|
||||
+ if (!org.purpurmc.purpur.PurpurConfig.allowHigherEnchantsLevels && level > enchantment.getMaxLevel() && !this.bypassEnchantmentLevelRestriction) { // Paper - bypass anvil level restrictions // Purpur - Config to allow unsafe enchants
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
|
||||
@@ -243,6 +_,54 @@
|
||||
if (!this.itemName.equals(input.getHoverName().getString())) {
|
||||
namingCost = 1;
|
||||
price += namingCost;
|
||||
+ // Purpur start - Allow anvil colors
|
||||
+ if (this.player != null) {
|
||||
+ org.bukkit.craftbukkit.entity.CraftHumanEntity player = this.player.getBukkitEntity();
|
||||
+ String name = this.itemName;
|
||||
+ boolean removeItalics = false;
|
||||
+ if (player.hasPermission("purpur.anvil.remove_italics")) {
|
||||
+ if (name.startsWith("&r")) {
|
||||
+ name = name.substring(2);
|
||||
+ removeItalics = true;
|
||||
+ } else if (name.startsWith("<r>")) {
|
||||
+ name = name.substring(3);
|
||||
+ removeItalics = true;
|
||||
+ } else if (name.startsWith("<reset>")) {
|
||||
+ name = name.substring(7);
|
||||
+ removeItalics = true;
|
||||
+ }
|
||||
+ }
|
||||
+ if (this.player.level().purpurConfig.anvilAllowColors) {
|
||||
+ if (player.hasPermission("purpur.anvil.color")) {
|
||||
+ java.util.regex.Matcher matcher = java.util.regex.Pattern.compile("(?i)&([0-9a-fr])").matcher(name);
|
||||
+ while (matcher.find()) {
|
||||
+ String match = matcher.group(1);
|
||||
+ name = name.replace("&" + match, "\u00a7" + match.toLowerCase(java.util.Locale.ROOT));
|
||||
+ }
|
||||
+ //name = name.replaceAll("(?i)&([0-9a-fr])", "\u00a7$1");
|
||||
+ }
|
||||
+ if (player.hasPermission("purpur.anvil.format")) {
|
||||
+ java.util.regex.Matcher matcher = java.util.regex.Pattern.compile("(?i)&([k-or])").matcher(name);
|
||||
+ while (matcher.find()) {
|
||||
+ String match = matcher.group(1);
|
||||
+ name = name.replace("&" + match, "\u00a7" + match.toLowerCase(java.util.Locale.ROOT));
|
||||
+ }
|
||||
+ //name = name.replaceAll("(?i)&([l-or])", "\u00a7$1");
|
||||
+ }
|
||||
+ }
|
||||
+ net.kyori.adventure.text.Component component;
|
||||
+ if (this.player.level().purpurConfig.anvilColorsUseMiniMessage && player.hasPermission("purpur.anvil.minimessage")) {
|
||||
+ component = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.bukkit.ChatColor.stripColor(name));
|
||||
+ } else {
|
||||
+ component = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(name);
|
||||
+ }
|
||||
+ if (removeItalics) {
|
||||
+ component = component.decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, false);
|
||||
+ }
|
||||
+ result.set(DataComponents.CUSTOM_NAME, io.papermc.paper.adventure.PaperAdventure.asVanilla(component));
|
||||
+ }
|
||||
+ else
|
||||
+ // Purpur end - Allow anvil colors
|
||||
result.set(DataComponents.CUSTOM_NAME, Component.literal(this.itemName));
|
||||
}
|
||||
} else if (input.has(DataComponents.CUSTOM_NAME)) {
|
||||
@@ -267,6 +_,12 @@
|
||||
this.onlyRenaming = true;
|
||||
}
|
||||
|
||||
+ // Purpur start - Anvil API
|
||||
+ if (this.bypassCost && this.cost.get() >= this.maximumRepairCost) {
|
||||
+ this.cost.set(this.maximumRepairCost - 1);
|
||||
+ }
|
||||
+ // Purpur end - Anvil API
|
||||
+
|
||||
if (this.cost.get() >= this.maximumRepairCost && !this.player.hasInfiniteMaterials()) { // CraftBukkit
|
||||
result = ItemStack.EMPTY;
|
||||
}
|
||||
@@ -287,6 +_,13 @@
|
||||
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(this.getBukkitView(), result); // CraftBukkit
|
||||
this.broadcastChanges();
|
||||
+
|
||||
+ // Purpur start - Anvil API
|
||||
+ if ((this.canDoUnsafeEnchants || org.purpurmc.purpur.PurpurConfig.allowInapplicableEnchants || org.purpurmc.purpur.PurpurConfig.allowIncompatibleEnchants) && itemStack != ItemStack.EMPTY) { // Purpur - Config to allow unsafe enchants
|
||||
+ ((ServerPlayer) this.player).connection.send(new ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), 2, itemStack));
|
||||
+ ((ServerPlayer) this.player).connection.send(new ClientboundContainerSetDataPacket(this.containerId, 0, this.cost.get()));
|
||||
+ }
|
||||
+ // Purpur end - Anvil API
|
||||
} else {
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(this.getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
this.cost.set(AnvilMenu.DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
|
||||
@@ -295,7 +_,7 @@
|
||||
}
|
||||
|
||||
public static int calculateIncreasedRepairCost(final int baseCost) {
|
||||
- return (int)Math.min(baseCost * 2L + 1L, 2147483647L);
|
||||
+ return org.purpurmc.purpur.PurpurConfig.anvilCumulativeCost ? (int)Math.min(baseCost * 2L + 1L, 2147483647L) : 0; // Purpur - Make anvil cumulative cost configurable
|
||||
}
|
||||
|
||||
public boolean setItemName(final String name) {
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/inventory/ArmorSlot.java
|
||||
+++ b/net/minecraft/world/inventory/ArmorSlot.java
|
||||
@@ -54,7 +_,7 @@
|
||||
@Override
|
||||
public boolean mayPickup(final Player player) {
|
||||
ItemStack itemStack = this.getItem();
|
||||
- return (itemStack.isEmpty() || player.isCreative() || !EnchantmentHelper.has(itemStack, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE))
|
||||
+ return (itemStack.isEmpty() || player.isCreative() || (!EnchantmentHelper.has(itemStack, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) || player.level().purpurConfig.playerRemoveBindingWithWeakness && player.hasEffect(net.minecraft.world.effect.MobEffects.WEAKNESS))) // Purpur - Config to remove curse of binding with weakness
|
||||
&& super.mayPickup(player);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/world/inventory/EnchantmentMenu.java
|
||||
+++ b/net/minecraft/world/inventory/EnchantmentMenu.java
|
||||
@@ -64,6 +_,22 @@
|
||||
return access.getLocation();
|
||||
}
|
||||
// CraftBukkit end
|
||||
+
|
||||
+ // Purpur start - Enchantment Table Persists Lapis
|
||||
+ @Override
|
||||
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity who) {
|
||||
+ super.onClose(who);
|
||||
+
|
||||
+ if (who.getHandle().level().purpurConfig.enchantmentTableLapisPersists) {
|
||||
+ access.execute((level, pos) -> {
|
||||
+ net.minecraft.world.level.block.entity.BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
+ if (blockEntity instanceof net.minecraft.world.level.block.entity.EnchantingTableBlockEntity enchantmentTable) {
|
||||
+ enchantmentTable.setLapis(this.getItem(1).getCount());
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Enchantment Table Persists Lapis
|
||||
};
|
||||
// Paper end - Add missing InventoryHolders
|
||||
this.access = access;
|
||||
@@ -92,6 +_,16 @@
|
||||
return EnchantmentMenu.EMPTY_SLOT_LAPIS_LAZULI;
|
||||
}
|
||||
});
|
||||
+ // Purpur start - Enchantment Table Persists Lapis
|
||||
+ access.execute((level, pos) -> {
|
||||
+ if (level.purpurConfig.enchantmentTableLapisPersists) {
|
||||
+ net.minecraft.world.level.block.entity.BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
+ if (blockEntity instanceof net.minecraft.world.level.block.entity.EnchantingTableBlockEntity enchantmentTable) {
|
||||
+ this.getSlot(1).set(new ItemStack(Items.LAPIS_LAZULI, enchantmentTable.getLapis()));
|
||||
+ }
|
||||
+ }
|
||||
+ });
|
||||
+ // Purpur end - Enchantment Table Persists Lapis
|
||||
this.addStandardInventorySlots(inventory, 8, 84);
|
||||
this.addDataSlot(DataSlot.shared(this.costs, 0));
|
||||
this.addDataSlot(DataSlot.shared(this.costs, 1));
|
||||
@@ -308,7 +_,7 @@
|
||||
@Override
|
||||
public void removed(final Player player) {
|
||||
super.removed(player);
|
||||
- this.access.execute((level, pos) -> this.clearContainer(player, this.enchantSlots));
|
||||
+ this.access.execute((level, pos) -> {if (level.purpurConfig.enchantmentTableLapisPersists) this.getSlot(1).set(ItemStack.EMPTY);this.clearContainer(player, this.enchantSlots);}); // Purpur - Enchantment Table Persists Lapis
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,138 @@
|
||||
--- a/net/minecraft/world/inventory/GrindstoneMenu.java
|
||||
+++ b/net/minecraft/world/inventory/GrindstoneMenu.java
|
||||
@@ -105,11 +_,13 @@
|
||||
@Override
|
||||
public void onTake(final Player player, final ItemStack carried) {
|
||||
access.execute((level, pos) -> {
|
||||
+ ItemStack itemstack = activeQuickItem == null ? stack : activeQuickItem; // Purpur - Grindstone API
|
||||
if (level instanceof ServerLevel) {
|
||||
// Paper start - Fire BlockExpEvent on grindstone use
|
||||
org.bukkit.event.block.BlockExpEvent event = new org.bukkit.event.block.BlockExpEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), this.getExperienceAmount(level));
|
||||
event.callEvent();
|
||||
- ExperienceOrb.awardWithDirection((ServerLevel) level, Vec3.atCenterOf(pos), Vec3.ZERO, event.getExpToDrop(), org.bukkit.entity.ExperienceOrb.SpawnReason.GRINDSTONE, player, null);
|
||||
+ org.purpurmc.purpur.event.inventory.GrindstoneTakeResultEvent grindstoneTakeResultEvent = new org.purpurmc.purpur.event.inventory.GrindstoneTakeResultEvent(player.getBukkitEntity(), getBukkitView(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), event.getExpToDrop()); grindstoneTakeResultEvent.callEvent(); // Purpur - Grindstone API
|
||||
+ ExperienceOrb.awardWithDirection((ServerLevel) level, Vec3.atCenterOf(pos), Vec3.ZERO, grindstoneTakeResultEvent.getExperienceAmount(), org.bukkit.entity.ExperienceOrb.SpawnReason.GRINDSTONE, player, null); // Purpur - Grindstone API
|
||||
// Paper end - Fire BlockExpEvent on grindstone use
|
||||
}
|
||||
|
||||
@@ -138,7 +_,7 @@
|
||||
for (Entry<Holder<Enchantment>> entry : enchantments.entrySet()) {
|
||||
Holder<Enchantment> enchant = entry.getKey();
|
||||
int lvl = entry.getIntValue();
|
||||
- if (!enchant.is(EnchantmentTags.CURSE)) {
|
||||
+ if (!org.purpurmc.purpur.PurpurConfig.grindstoneIgnoredEnchants.contains(holder.value())) { // Purpur - Config for grindstones
|
||||
amount += enchant.value().getMinCost(lvl);
|
||||
}
|
||||
}
|
||||
@@ -216,16 +_,76 @@
|
||||
|
||||
for (Entry<Holder<Enchantment>> entry : enchantments.entrySet()) {
|
||||
Holder<Enchantment> enchant = entry.getKey();
|
||||
- if (!enchant.is(EnchantmentTags.CURSE) || newEnchantments.getLevel(enchant) == 0) {
|
||||
+ if (!org.purpurmc.purpur.PurpurConfig.grindstoneIgnoredEnchants.contains(enchant.value()) || newEnchantments.getLevel(enchant) == 0) { // Purpur - Config for grindstones
|
||||
newEnchantments.upgrade(enchant, entry.getIntValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+ // Purpur start - Config for grindstones
|
||||
+ private java.util.List<net.minecraft.core.component.DataComponentType<?>> GRINDSTONE_REMOVE_ATTRIBUTES_REMOVAL_LIST = java.util.List.of(
|
||||
+ // DataComponents.MAX_STACK_SIZE,
|
||||
+ // DataComponents.DAMAGE,
|
||||
+ // DataComponents.BLOCK_STATE,
|
||||
+ DataComponents.CUSTOM_DATA,
|
||||
+ // DataComponents.MAX_DAMAGE,
|
||||
+ // DataComponents.UNBREAKABLE,
|
||||
+ // DataComponents.CUSTOM_NAME,
|
||||
+ // DataComponents.ITEM_NAME,
|
||||
+ // DataComponents.LORE,
|
||||
+ // DataComponents.RARITY,
|
||||
+ // DataComponents.ENCHANTMENTS,
|
||||
+ // DataComponents.CAN_PLACE_ON,
|
||||
+ // DataComponents.CAN_BREAK,
|
||||
+ DataComponents.ATTRIBUTE_MODIFIERS,
|
||||
+ DataComponents.CUSTOM_MODEL_DATA,
|
||||
+ // DataComponents.HIDE_ADDITIONAL_TOOLTIP,
|
||||
+ // DataComponents.HIDE_TOOLTIP,
|
||||
+ // DataComponents.REPAIR_COST,
|
||||
+ // DataComponents.CREATIVE_SLOT_LOCK,
|
||||
+ // DataComponents.ENCHANTMENT_GLINT_OVERRIDE,
|
||||
+ // DataComponents.INTANGIBLE_PROJECTILE,
|
||||
+ // DataComponents.FOOD,
|
||||
+ // DataComponents.FIRE_RESISTANT,
|
||||
+ // DataComponents.TOOL,
|
||||
+ // DataComponents.STORED_ENCHANTMENTS,
|
||||
+ DataComponents.DYED_COLOR,
|
||||
+ // DataComponents.MAP_COLOR,
|
||||
+ // DataComponents.MAP_ID,
|
||||
+ // DataComponents.MAP_DECORATIONS,
|
||||
+ // DataComponents.MAP_POST_PROCESSING,
|
||||
+ // DataComponents.CHARGED_PROJECTILES,
|
||||
+ // DataComponents.BUNDLE_CONTENTS,
|
||||
+ // DataComponents.POTION_CONTENTS,
|
||||
+ DataComponents.SUSPICIOUS_STEW_EFFECTS
|
||||
+ // DataComponents.WRITABLE_BOOK_CONTENT,
|
||||
+ // DataComponents.WRITTEN_BOOK_CONTENT,
|
||||
+ // DataComponents.TRIM,
|
||||
+ // DataComponents.DEBUG_STICK_STATE,
|
||||
+ // DataComponents.ENTITY_DATA,
|
||||
+ // DataComponents.BUCKET_ENTITY_DATA,
|
||||
+ // DataComponents.BLOCK_ENTITY_DATA,
|
||||
+ // DataComponents.INSTRUMENT,
|
||||
+ // DataComponents.OMINOUS_BOTTLE_AMPLIFIER,
|
||||
+ // DataComponents.RECIPES,
|
||||
+ // DataComponents.LODESTONE_TRACKER,
|
||||
+ // DataComponents.FIREWORK_EXPLOSION,
|
||||
+ // DataComponents.FIREWORKS,
|
||||
+ // DataComponents.PROFILE,
|
||||
+ // DataComponents.NOTE_BLOCK_SOUND,
|
||||
+ // DataComponents.BANNER_PATTERNS,
|
||||
+ // DataComponents.BASE_COLOR,
|
||||
+ // DataComponents.POT_DECORATIONS,
|
||||
+ // DataComponents.CONTAINER,
|
||||
+ // DataComponents.BEES,
|
||||
+ // DataComponents.LOCK,
|
||||
+ // DataComponents.CONTAINER_LOOT,
|
||||
+ );
|
||||
+ // Purpur end - Config for grindstones
|
||||
private ItemStack removeNonCursesFrom(ItemStack item) {
|
||||
ItemEnchantments newEnchantments = EnchantmentHelper.updateEnchantments(
|
||||
- item, enchantments -> enchantments.removeIf(enchantment -> !enchantment.is(EnchantmentTags.CURSE))
|
||||
+ item, enchantments -> enchantments.removeIf(enchantment -> !org.purpurmc.purpur.PurpurConfig.grindstoneIgnoredEnchants.contains(enchantment.value())) // Purpur - Config for grindstones
|
||||
);
|
||||
if (item.is(Items.ENCHANTED_BOOK) && newEnchantments.isEmpty()) {
|
||||
item = item.transmuteCopy(Items.BOOK);
|
||||
@@ -238,6 +_,22 @@
|
||||
}
|
||||
|
||||
item.set(DataComponents.REPAIR_COST, repairCost);
|
||||
+
|
||||
+ // Purpur start - Config for grindstones
|
||||
+ net.minecraft.core.component.DataComponentPatch.Builder builder = net.minecraft.core.component.DataComponentPatch.builder();
|
||||
+ if (org.purpurmc.purpur.PurpurConfig.grindstoneRemoveAttributes) {
|
||||
+ item.getComponents().forEach(typedDataComponent -> {
|
||||
+ if (GRINDSTONE_REMOVE_ATTRIBUTES_REMOVAL_LIST.contains(typedDataComponent.type())) {
|
||||
+ builder.remove(typedDataComponent.type());
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+ if (org.purpurmc.purpur.PurpurConfig.grindstoneRemoveDisplay) {
|
||||
+ builder.remove(DataComponents.CUSTOM_NAME);
|
||||
+ builder.remove(DataComponents.LORE);
|
||||
+ }
|
||||
+ item.applyComponents(builder.build());
|
||||
+ // Purpur end - Config for grindstones
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -294,7 +_,9 @@
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
+ this.activeQuickItem = itemStack; // Purpur - Grindstone API
|
||||
slot.onTake(player, item);
|
||||
+ this.activeQuickItem = null; // Purpur - Grindstone API
|
||||
}
|
||||
|
||||
return clicked;
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/world/inventory/ItemCombinerMenu.java
|
||||
+++ b/net/minecraft/world/inventory/ItemCombinerMenu.java
|
||||
@@ -177,7 +_,9 @@
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
+ this.activeQuickItem = clicked; // Purpur - Anvil API
|
||||
slot.onTake(player, stack);
|
||||
+ this.activeQuickItem = null; // Purpur - Anvil API
|
||||
}
|
||||
|
||||
return clicked;
|
||||
@@ -0,0 +1,49 @@
|
||||
--- a/net/minecraft/world/level/block/FarmlandBlock.java
|
||||
+++ b/net/minecraft/world/level/block/FarmlandBlock.java
|
||||
@@ -111,7 +_,7 @@
|
||||
public void fallOn(final Level level, final BlockState state, final BlockPos pos, final Entity entity, final double fallDistance) {
|
||||
super.fallOn(level, state, pos, entity, fallDistance); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage.
|
||||
if (level instanceof ServerLevel serverLevel
|
||||
- && level.getRandom().nextFloat() < fallDistance - 0.5
|
||||
+ && (serverLevel.purpurConfig.farmlandTrampleHeight >= 0D ? fallDistance >= serverLevel.purpurConfig.farmlandTrampleHeight : level.getRandom().nextFloat() < fallDistance - 0.5) // Purpur - Configurable farmland trample height
|
||||
&& entity instanceof LivingEntity
|
||||
&& (entity instanceof Player || serverLevel.getGameRules().get(GameRules.MOB_GRIEFING))
|
||||
&& entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) {
|
||||
@@ -128,6 +_,28 @@
|
||||
return;
|
||||
}
|
||||
|
||||
+ if (level.purpurConfig.farmlandTramplingDisabled) return; // Purpur - Farmland trampling changes
|
||||
+ if (level.purpurConfig.farmlandTramplingOnlyPlayers && !(entity instanceof Player)) return; // Purpur - Farmland trampling changes
|
||||
+
|
||||
+ // Purpur start - Ability to re-add farmland mechanics from Alpha
|
||||
+ if (level.purpurConfig.farmlandAlpha) {
|
||||
+ Block block = level.getBlockState(pos.below()).getBlock();
|
||||
+ if (block instanceof FenceBlock || block instanceof WallBlock) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Ability to re-add farmland mechanics from Alpha
|
||||
+
|
||||
+ // Purpur start - Farmland trampling changes
|
||||
+ if (level.purpurConfig.farmlandTramplingFeatherFalling) {
|
||||
+ net.minecraft.world.item.ItemStack bootsItem = ((net.minecraft.world.entity.LivingEntity) entity).getItemBySlot(net.minecraft.world.entity.EquipmentSlot.FEET);
|
||||
+
|
||||
+ if (bootsItem != net.minecraft.world.item.ItemStack.EMPTY && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.FEATHER_FALLING, bootsItem) >= (int) entity.fallDistance) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Farmland trampling changes
|
||||
+
|
||||
if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.DIRT.defaultBlockState())) {
|
||||
return;
|
||||
}
|
||||
@@ -176,7 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- return false;
|
||||
+ return ((ServerLevel) level).purpurConfig.farmlandGetsMoistFromBelow && level.getFluidState(pos.relative(Direction.DOWN)).is(FluidTags.WATER); // Purpur - Allow soil to moisten from water directly under it
|
||||
// Paper end - Perf: remove abstract block iteration
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
@@ -195,6 +_,21 @@
|
||||
}
|
||||
|
||||
ItemStack fuel = entity.items.get(1);
|
||||
+ // Purpur start - Furnace uses lava from underneath
|
||||
+ boolean usedLavaFromUnderneath = false;
|
||||
+ if (level.purpurConfig.furnaceUseLavaFromUnderneath && !entity.isLit() && fuel.isEmpty() && !entity.items.get(0).isEmpty() && level.getGameTime() % 20 == 0) {
|
||||
+ BlockPos below = entity.getBlockPos().below();
|
||||
+ BlockState belowState = level.getBlockStateIfLoaded(below);
|
||||
+ if (belowState != null && belowState.is(net.minecraft.world.level.block.Blocks.LAVA)) {
|
||||
+ net.minecraft.world.level.material.FluidState fluidState = belowState.getFluidState();
|
||||
+ if (fluidState != null && fluidState.isSource()) {
|
||||
+ level.setBlock(below, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(), 3);
|
||||
+ fuel = Items.LAVA_BUCKET.getDefaultInstance();
|
||||
+ usedLavaFromUnderneath = true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Furnace uses lava from underneath
|
||||
ItemStack ingredient = entity.items.get(0);
|
||||
boolean hasIngredient = !ingredient.isEmpty();
|
||||
boolean hasFuel = !fuel.isEmpty();
|
||||
@@ -273,6 +_,8 @@
|
||||
if (changed) {
|
||||
setChanged(level, pos, state);
|
||||
}
|
||||
+
|
||||
+ if (usedLavaFromUnderneath) furnace.items.set(1, ItemStack.EMPTY); // Purpur - Furnace uses lava from underneath
|
||||
}
|
||||
|
||||
private static void consumeFuel(final NonNullList<ItemStack> items, final ItemStack fuel) {
|
||||
@@ -0,0 +1,58 @@
|
||||
--- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
@@ -142,6 +_,16 @@
|
||||
|
||||
public double getEffectRange() {
|
||||
if (this.effectRange < 0) {
|
||||
+ // Purpur start - Beacon Activation Range Configurable
|
||||
+ if (this.level != null) {
|
||||
+ switch (this.levels) {
|
||||
+ case 1: return this.level.purpurConfig.beaconLevelOne;
|
||||
+ case 2: return this.level.purpurConfig.beaconLevelTwo;
|
||||
+ case 3: return this.level.purpurConfig.beaconLevelThree;
|
||||
+ case 4: return this.level.purpurConfig.beaconLevelFour;
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Beacon Activation Range Configurable
|
||||
return this.levels * 10 + 10;
|
||||
} else {
|
||||
return effectRange;
|
||||
@@ -170,6 +_,7 @@
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
BlockPos checkPos;
|
||||
+ boolean isTintedGlass = false; // Purpur - allow beacon effects when covered by tinted glass
|
||||
if (entity.lastCheckY < y) {
|
||||
checkPos = pos;
|
||||
entity.checkingBeamSections = Lists.newArrayList();
|
||||
@@ -199,11 +_,15 @@
|
||||
}
|
||||
}
|
||||
} else {
|
||||
- if (lastBeamSection == null || state.getLightDampening() >= 15 && !state.is(Blocks.BEDROCK)) {
|
||||
+ if (level.purpurConfig.beaconAllowEffectsWithTintedGlass && blockState.getBlock().equals(Blocks.TINTED_GLASS)) {isTintedGlass = true;} // Purpur - allow beacon effects when covered by tinted glass
|
||||
+ // Purpur start - fix effects being applied when tinted glass is covered
|
||||
+ if (lastBeamSection == null || state.getLightDampening() >= 15 && !state.is(Blocks.BEDROCK) && !(blockState.getBlock().equals(Blocks.TINTED_GLASS) && level.purpurConfig.beaconAllowEffectsWithTintedGlass)) {
|
||||
entity.checkingBeamSections.clear();
|
||||
entity.lastCheckY = lastSetBlock;
|
||||
+ isTintedGlass = false;
|
||||
break;
|
||||
}
|
||||
+ // Purpur end - fix effects being applied when tinted glass is covered
|
||||
|
||||
lastBeamSection.increaseHeight();
|
||||
}
|
||||
@@ -214,11 +_,11 @@
|
||||
|
||||
int previousLevels = entity.levels;
|
||||
if (level.getGameTime() % 80L == 0L) {
|
||||
- if (!entity.beamSections.isEmpty()) {
|
||||
+ if (!entity.beamSections.isEmpty() || (level.purpurConfig.beaconAllowEffectsWithTintedGlass && isTintedGlass)) { // Purpur - fix beacon effects persisting with broken base while tinted glass is used
|
||||
entity.levels = updateBase(level, x, y, z);
|
||||
}
|
||||
|
||||
- if (entity.levels > 0 && !entity.beamSections.isEmpty()) {
|
||||
+ if (entity.levels > 0 && (!entity.beamSections.isEmpty() || (level.purpurConfig.beaconAllowEffectsWithTintedGlass && isTintedGlass))) { // Purpur - allow beacon effects when covered by tinted glass
|
||||
applyEffects(level, pos, entity.levels, entity.primaryPower, entity.secondaryPower, entity); // Paper - Custom beacon ranges
|
||||
playSound(level, pos, SoundEvents.BEACON_AMBIENT);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
--- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
@@ -80,7 +_,7 @@
|
||||
"leash",
|
||||
"UUID"
|
||||
);
|
||||
- public static final int MAX_OCCUPANTS = 3;
|
||||
+ public static final int MAX_OCCUPANTS = org.purpurmc.purpur.PurpurConfig.beeInsideBeeHive; // Purpur - Config to change max number of bees
|
||||
private static final int MIN_TICKS_BEFORE_REENTERING_HIVE = 400;
|
||||
private static final int MIN_OCCUPATION_TICKS_NECTAR = 2400;
|
||||
public static final int MIN_OCCUPATION_TICKS_NECTARLESS = 600;
|
||||
@@ -156,11 +_,33 @@
|
||||
return spawned;
|
||||
}
|
||||
|
||||
+ // Purpur start - Stored Bee API
|
||||
+ public List<Entity> releaseBee(BlockState iblockdata, BeehiveBlockEntity.BeeData data, BeehiveBlockEntity.BeeReleaseStatus tileentitybeehive_releasestatus, boolean force) {
|
||||
+ List<Entity> list = Lists.newArrayList();
|
||||
+
|
||||
+ BeehiveBlockEntity.releaseOccupant(this.level, this.worldPosition, iblockdata, data.occupant, list, tileentitybeehive_releasestatus, this.savedFlowerPos, force);
|
||||
+
|
||||
+ if (!list.isEmpty()) {
|
||||
+ stored.remove(data);
|
||||
+
|
||||
+ super.setChanged();
|
||||
+ }
|
||||
+
|
||||
+ return list;
|
||||
+ }
|
||||
+ // Purpur end - Stored Bee API
|
||||
+
|
||||
@VisibleForDebug
|
||||
public int getOccupantCount() {
|
||||
return this.stored.size();
|
||||
}
|
||||
|
||||
+ // Purpur start - Stored Bee API
|
||||
+ public List<BeeData> getStored() {
|
||||
+ return stored;
|
||||
+ }
|
||||
+ // Purpur end - Stored Bee API
|
||||
+
|
||||
// Paper start - Add EntityBlockStorage clearEntities
|
||||
public void clearBees() {
|
||||
this.stored.clear();
|
||||
@@ -399,8 +_,8 @@
|
||||
registration.register(DebugSubscriptions.BEE_HIVES, () -> DebugHiveInfo.pack(this));
|
||||
}
|
||||
|
||||
- private static class BeeData {
|
||||
- private final BeehiveBlockEntity.Occupant occupant;
|
||||
+ public static class BeeData { // Purpur - make public - Stored Bee API
|
||||
+ public final BeehiveBlockEntity.Occupant occupant; // Purpur - make public - Stored Bee API
|
||||
private int exitTickCounter; // Paper - Fix bees aging inside hives; separate counter for checking if bee should exit to reduce exit attempts
|
||||
private int ticksInHive;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
--- a/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||
@@ -107,6 +_,10 @@
|
||||
input.read("PublicBukkitValues", CompoundTag.CODEC)
|
||||
.ifPresent(this.persistentDataContainer::putAll);
|
||||
// Paper end - read persistent data container
|
||||
+
|
||||
+
|
||||
+ this.persistentLore = input.read("Purpur.persistentLore", net.minecraft.world.item.component.ItemLore.CODEC).orElse(null); // Purpur - Persistent BlockEntity Lore and DisplayName
|
||||
+
|
||||
}
|
||||
|
||||
public final void loadWithComponents(final ValueInput input) {
|
||||
@@ -119,6 +_,11 @@
|
||||
}
|
||||
|
||||
protected void saveAdditional(final ValueOutput output) {
|
||||
+ // Purpur start - Persistent BlockEntity Lore and DisplayName
|
||||
+ if (this.persistentLore != null) {
|
||||
+ output.store("Purpur.persistentLore", net.minecraft.world.item.component.ItemLore.CODEC, this.persistentLore);
|
||||
+ }
|
||||
+ // Purpur end - Persistent BlockEntity Lore and DisplayName
|
||||
}
|
||||
|
||||
public final CompoundTag saveWithFullMetadata(final HolderLookup.Provider registries) {
|
||||
@@ -412,4 +_,16 @@
|
||||
return this.blockEntity.getNameForReporting() + "@" + this.blockEntity.getBlockPos();
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Purpur start - Persistent BlockEntity Lore and DisplayName
|
||||
+ private net.minecraft.world.item.component.@Nullable ItemLore persistentLore = null;
|
||||
+
|
||||
+ public void setPersistentLore(net.minecraft.world.item.component.ItemLore lore) {
|
||||
+ this.persistentLore = lore;
|
||||
+ }
|
||||
+
|
||||
+ public @org.jetbrains.annotations.Nullable net.minecraft.world.item.component.ItemLore getPersistentLore() {
|
||||
+ return this.persistentLore;
|
||||
+ }
|
||||
+ // Purpur end - Persistent BlockEntity Lore and DisplayName
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
--- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
@@ -150,7 +_,7 @@
|
||||
BlockPos testPos = worldPosition.offset(ox, oy, ozx);
|
||||
BlockState testBlock = level.getBlockState(testPos);
|
||||
|
||||
- for (Block type : VALID_BLOCKS) {
|
||||
+ for (Block type : level.purpurConfig.conduitBlocks) { // Purpur - Conduit behavior configuration
|
||||
if (testBlock.is(type)) {
|
||||
effectBlocks.add(testPos);
|
||||
}
|
||||
@@ -165,13 +_,13 @@
|
||||
|
||||
private static void applyEffects(final Level level, final BlockPos worldPosition, final List<BlockPos> effectBlocks) {
|
||||
// CraftBukkit start
|
||||
- ConduitBlockEntity.applyEffects(level, worldPosition, ConduitBlockEntity.getRange(effectBlocks));
|
||||
+ ConduitBlockEntity.applyEffects(level, worldPosition, ConduitBlockEntity.getRange(effectBlocks, level)); // Purpur - Conduit behavior configuration
|
||||
}
|
||||
|
||||
- public static int getRange(List<BlockPos> effectBlocks) {
|
||||
+ public static int getRange(List<BlockPos> effectBlocks, Level level) { // Purpur - Conduit behavior configuration
|
||||
// CraftBukkit end
|
||||
int activeSize = effectBlocks.size();
|
||||
- int effectRange = activeSize / 7 * 16;
|
||||
+ int effectRange = activeSize / 7 * level.purpurConfig.conduitDistance; // Purpur - Conduit behavior configuration
|
||||
// CraftBukkit start
|
||||
return effectRange;
|
||||
}
|
||||
@@ -204,7 +_,7 @@
|
||||
EntityReference<LivingEntity> newDestroyTarget = updateDestroyTarget(entity.destroyTarget, level, worldPosition, isActive);
|
||||
LivingEntity targetEntity = EntityReference.getLivingEntity(newDestroyTarget, level);
|
||||
if (damageTarget && targetEntity != null) { // CraftBukkit
|
||||
- if (targetEntity.hurtServer(level, level.damageSources().magic().eventBlockDamager(level, worldPosition), 4.0F)) // CraftBukkit - move up
|
||||
+ if (targetEntity.hurtServer(level, level.damageSources().magic().eventBlockDamager(level, worldPosition), level.purpurConfig.conduitDamageAmount)) // CraftBukkit - move up // Purpur - Conduit behavior configuration
|
||||
level.playSound(
|
||||
null, targetEntity.getX(), targetEntity.getY(), targetEntity.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F
|
||||
);
|
||||
@@ -225,19 +_,25 @@
|
||||
return selectNewTarget(level, pos);
|
||||
} else {
|
||||
LivingEntity targetEntity = EntityReference.getLivingEntity(target, level);
|
||||
- return targetEntity != null && targetEntity.isAlive() && pos.closerThan(targetEntity.blockPosition(), 8.0) ? target : null;
|
||||
+ return targetEntity != null && targetEntity.isAlive() && pos.closerThan(targetEntity.blockPosition(), level.purpurConfig.conduitDamageDistance) ? target : null; // Purpur - Conduit behavior configuration
|
||||
}
|
||||
}
|
||||
|
||||
private static @Nullable EntityReference<LivingEntity> selectNewTarget(final ServerLevel level, final BlockPos pos) {
|
||||
List<LivingEntity> candidates = level.getEntitiesOfClass(
|
||||
- LivingEntity.class, getDestroyRangeAABB(pos), input -> input instanceof Enemy && input.isInWaterOrRain()
|
||||
+ LivingEntity.class, getDestroyRangeAABB(pos, level), input -> input instanceof Enemy && input.isInWaterOrRain() // Purpur - Conduit behavior configuration
|
||||
);
|
||||
return candidates.isEmpty() ? null : EntityReference.of(Util.getRandom(candidates, level.getRandom()));
|
||||
}
|
||||
|
||||
public static AABB getDestroyRangeAABB(final BlockPos worldPosition) {
|
||||
- return new AABB(worldPosition).inflate(8.0);
|
||||
+ // Purpur start - Conduit behavior configuration
|
||||
+ return getDestroyRangeAABB(worldPosition, null);
|
||||
+ }
|
||||
+
|
||||
+ private static AABB getDestroyRangeAABB(final BlockPos worldPosition, final Level level) {
|
||||
+ // Purpur end - Conduit behavior configuration
|
||||
+ return new AABB(worldPosition).inflate(level == null ? 8.0 : level.purpurConfig.conduitDamageDistance); // Purpur - Conduit behavior configuration
|
||||
}
|
||||
|
||||
private static void animationTick(
|
||||
@@ -0,0 +1,65 @@
|
||||
--- a/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
@@ -149,16 +_,32 @@
|
||||
return this.setText(function.apply(text), isFrontText);
|
||||
}
|
||||
|
||||
+ // Purpur start - Signs allow color codes
|
||||
+ private Component translateColors(org.bukkit.entity.Player player, String line, Style style) {
|
||||
+ if (level.purpurConfig.signAllowColors) {
|
||||
+ if (player.hasPermission("purpur.sign.color")) line = line.replaceAll("(?i)&([0-9a-fr])", "\u00a7$1");
|
||||
+ if (player.hasPermission("purpur.sign.style")) line = line.replaceAll("(?i)&([l-or])", "\u00a7$1");
|
||||
+ if (player.hasPermission("purpur.sign.magic")) line = line.replaceAll("(?i)&([kr])", "\u00a7$1");
|
||||
+
|
||||
+ return io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line));
|
||||
+ } else {
|
||||
+ return Component.literal(line).setStyle(style);
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Signs allow color codes
|
||||
+
|
||||
private SignText setMessages(final Player player, final List<FilteredText> lines, SignText text, final boolean front) { // CraftBukkit
|
||||
SignText originalText = text; // CraftBukkit
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
FilteredText line = lines.get(i);
|
||||
Style currentTextStyle = text.getMessage(i, player.isTextFilteringEnabled()).getStyle();
|
||||
+
|
||||
+ org.bukkit.entity.Player craftPlayer = (org.bukkit.craftbukkit.entity.CraftPlayer) player.getBukkitEntity(); // Purpur - Signs allow color codes
|
||||
if (player.isTextFilteringEnabled()) {
|
||||
- text = text.setMessage(i, Component.literal(net.minecraft.util.StringUtil.filterText(line.filteredOrEmpty())).setStyle(currentTextStyle)); // Paper - filter sign text to chat only
|
||||
+ text = text.setMessage(i, translateColors(craftPlayer, net.minecraft.util.StringUtil.filterText(line.filteredOrEmpty()), currentTextStyle)); // Paper - filter sign text to chat only // Purpur - Signs allow color codes
|
||||
} else {
|
||||
text = text.setMessage(
|
||||
- i, Component.literal(line.raw()).setStyle(currentTextStyle), Component.literal(net.minecraft.util.StringUtil.filterText(line.filteredOrEmpty())).setStyle(currentTextStyle) // Paper - filter sign text to chat only
|
||||
+ i, translateColors(craftPlayer, net.minecraft.util.StringUtil.filterText(line.raw()), currentTextStyle), translateColors(craftPlayer, net.minecraft.util.StringUtil.filterText(line.filteredOrEmpty()), currentTextStyle) // Paper - filter sign text to chat only // Purpur - Signs allow color codes
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -308,6 +_,27 @@
|
||||
commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, level, LevelBasedPermissionSet.GAMEMASTER, textName, displayName, level.getServer(), player // Paper - Fix commands from signs not firing command events
|
||||
);
|
||||
}
|
||||
+
|
||||
+ // Purpur start - Signs allow color codes
|
||||
+ public ClientboundBlockEntityDataPacket getTranslatedUpdatePacket(boolean filtered, boolean front) {
|
||||
+ try (net.minecraft.util.ProblemReporter.ScopedCollector scopedCollector = new net.minecraft.util.ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) {
|
||||
+ net.minecraft.world.level.storage.TagValueOutput tagValueOutput = net.minecraft.world.level.storage.TagValueOutput.createWithContext(scopedCollector, this.getLevel().registryAccess());
|
||||
+ this.saveAdditional(tagValueOutput);
|
||||
+
|
||||
+ final Component[] lines = front ? frontText.getMessages(filtered) : backText.getMessages(filtered);
|
||||
+ final String side = front ? "front_text" : "back_text";
|
||||
+ net.minecraft.world.level.storage.ValueOutput sideNbt = tagValueOutput.child(side);
|
||||
+ net.minecraft.world.level.storage.ValueOutput.TypedOutputList<String> messagesNbt = sideNbt.list("messages", com.mojang.serialization.Codec.STRING);
|
||||
+ for (int i = 0; i < 4; i++) {
|
||||
+ final net.kyori.adventure.text.Component component = io.papermc.paper.adventure.PaperAdventure.asAdventure(lines[i]);
|
||||
+ final String line = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacyAmpersand().serialize(component);
|
||||
+ messagesNbt.add(line);
|
||||
+ }
|
||||
+ tagValueOutput.putString("PurpurEditor", "true");
|
||||
+ return ClientboundBlockEntityDataPacket.create(this, (blockEntity, registryAccess) -> tagValueOutput.buildResult());
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Signs allow color codes
|
||||
|
||||
@Override
|
||||
public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||
Reference in New Issue
Block a user