mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-29 14:15:43 +01:00
74c4554995
* Updated Upstream and Sidestream(s) (Paper/Tuinity/Airplane/Purpur/Origami) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 151457628 Fix Counter#decrement recursive call (#5665) 21ac7dc98 [Auto] Updated Upstream (CraftBukkit) 18ad2c9dd Add environment variable (PAPER_DISABLE_SERVER_GUI) to disable server gui 6ecbe5776 Rename leftover resource->datapack (#5662) ec90a7859 I give up on trying to teach people to avoid the incorrect ways. dc7b7a160 Fix missing username console death message (#5654) (#5658) c639a52a6 Add basic Datapack API (#5653) (#5653) 99c1d9da6 Updated Upstream (CraftBukkit) (#5652) 2d50c17e2 [CI-SKIP] Add PR rebasing steps (#5634) 2c5f8085e Remove boat interaction event (Fixes #5539) 96ee1fb8f fix WorldSaveEvent not firing with /save-all (#5650) e90e7829e remove unneeded patch (#5641) d875bacc2 Activate warning by default when people are doing silly things (#5642) cb896d471 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5643) ecbf5a38e Revert "Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5636)" 20fc4ab70 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5636) 20d8812ea Fix CraftPotionBrewer cache (#5632) cd6ae8816 Add a "Should Burn in Sunlight" API for Phantoms and Skeletons (#5608) 25edfe58b Remove unneeded component conversion for kick msg (#5626) cec386f66 Call PortalCreateEvent when players enter the end (#5618) 453c7f05c Add ItemStack#displayName to get the formatted display name of an ItemStack (#5628) 4efe8b498 Update Java version warning (#5621) e0a021ccc Add ItemStack#getTranslationKey() (#5616) 53d71b717 Add setPotionUseTimeLeft to Witch (#5597) 239935d18 Add Inventory#close (#5610) 29bf6cd41 Updated Upstream (CraftBukkit) ad45f316c Add raw address to AsyncPlayerPreLoginEvent (#5614) 28865335a [Auto] Updated Upstream (CraftBukkit) 750049fa2 Fix incorrect colors in some log messages (#5609) c5fa3f0d4 Add Adventure message to PlayerAdvancementDoneEvent (#5030) 69c09cdb0 Updated Upstream (CraftBukkit) (#5607) Tuinity Changes: 1222573 Fix incorrect status dataconverter for pre 1.13 chunks Airplane Changes: 3dce697 Fix gradle stuff 209bce3 Patches Purpur Changes: 72708f4 Option to disable dragon egg teleporting 5f87a45 Updated Upstream (Paper) 7bfc70d swap heavy logic to end bb9d72d Fix #338 - Phantoms always burning bug 8fa99b3 Configurable critical damage multiplier (#339) dc4a1cb Updated Upstream (Paper & Tuinity) c166841 Configurable powered rail boost modifier (closes #329) (#333) ab9b8ca Updated Upstream (Paper & Airplane) 44e72f7 Let parrots breed using any tempting item 09d98d3 this part is important, too :3 2015fe5 Breedable parrots 552d783 Iron golem poppy calms anger 1fa06a1 Optimize collisions (#328) 1112240 Extend Halloween Optimization (#321) 03f1aec Config for health to impact Creeper explosion radius (#304) 8f7bce4 Add config for hidden from entity selector patch 21906a2 Hide hidden players from entity selector 445496d [ci-skip] fix this too, now.. jfc 3ba8c81 Ya'll didn't see nothing.. 2d4611b Updated Upstream (Paper) beed258 Better offline mode warning (#330) c1efe3c It's meant to be double 🤦 3f9958b Implement the Mob Blindness mod 6e98c88 Add missing repo to settings.gradle.kts da5185b Update Gradle to 7.0.1 fbd28d8 Updated Upstream (Paper & Tuinity) cb42dec Updated Upstream (Paper) e883991 Fix compatibility with MyPet Origami Changes: 4c0616d Update Paper * Updated Upstream and Sidestream(s) (Paper) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 45e19ffb0 [Auto] Updated Upstream (CraftBukkit) * Updated Upstream and Sidestream(s) (Paper/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 7989028a5 More Enchantment API (#5588) c0cb5c129 Adds methods for checking item repairability (#5651) 22399b07f Actually use extended/ambient in BeaconEffectEvent (#5647) 979135878 Add cause and cancel message to PlayerGameModeChangeEvent (#5638) 51e1e58d2 Fix Adventure support in UnknownCommandEvent (#5664) Purpur Changes: ca9be56 Do not allow duplicate unsafe enchants * Updated Upstream and Sidestream(s) (Paper/Purpur/Paper) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 7989028a5 More Enchantment API (#5588) c0cb5c129 Adds methods for checking item repairability (#5651) 22399b07f Actually use extended/ambient in BeaconEffectEvent (#5647) 979135878 Add cause and cancel message to PlayerGameModeChangeEvent (#5638) 51e1e58d2 Fix Adventure support in UnknownCommandEvent (#5664) Purpur Changes: ca9be56 Do not allow duplicate unsafe enchants Paper Changes: 322886c86 Avoid NPE due to PlayerBedFailEnterEvent d3c9a195c removed duplicate ProjectileHitEvent for fireball (#5671) * Updated Upstream and Sidestream(s) (Paper/Airplane/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 2c6b1f048 Revert "Remove itneract event from boat" (Fixes #5677) aae1c54a9 Add command line option to load extra plugin jars not in the plugins folder Airplane Changes: 4a22184 Updated Upstream (Tuinity) Empirecraft Changes: d0aaf527 Updated Paper * Updated Upstream and Sidestream(s) (Airplane/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Airplane Changes: 046ae54 Improve hopper performance via bitset Purpur Changes: c333d3d Add config for the unverified username message (#348) 703b5da Fix invulnerable-while-accepting-resource-pack not being used * Updated Upstream and Sidestream(s) (Paper/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 6c183f1ae [Auto] Updated Upstream (CraftBukkit) Purpur Changes: e0991e0 allow using legacy section symbol in unverified username message 6bd246b Updated Upstream (Paper) * Updated Upstream and Sidestream(s) (Airplane) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Airplane Changes: 5fab6a2 Improvements to fluid & profiler patches * Updated Upstream and Sidestream(s) (Paper/Tuinity/Airplane/Purpur/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 41e6073ce [Auto] Updated Upstream (CraftBukkit) 6f93dc95d Add cause to Weather/ThunderChangeEvents (#4832) 507cf19b3 [CI-SKIP] [Auto] Rebuild Patches afe0785bf Added PlayerPurchaseEvent for standalone Merchant GUIs (#5583) 615df3d8a Fix entity motion tag from mob spawners (#5718) 2d34898b5 Add methods for getting default item attributes (#5593) d9766433e Add EntityInsideBlockEvent (#5596) 47d48790d Change return type of ItemStack#editMeta to allow checking for successful vs non-successful edits 7aabe7d56 [CI-SKIP] fix minecart vs minecraft typos (#5713) f775e87b4 [CI-SKIP] ci: update setup-java action (#5710) c58b3b277 ci: replace Java 11 with Java 16 in GH Actions build flow (#5709) 4b72327a6 ItemStack#editMeta 68984b664 Add Unix domain socket support (#5611) 68c67e680 Add Mob#lookAt API (#5633) 4bacecd16 [Auto] Updated Upstream (Bukkit/CraftBukkit) 1f28e6eeb Fix default ChatRenderer when no plugins are installed (#5702) ecb0d32ca Enhance (Async)ChatEvent with per-viewer rendering API (#5684) f3e541ca1 Actually list all missing hard depends (#5701) 11f83fe8e [CI-SKIP] [Auto] Rebuild Patches a36e5d65f MC-148809: Fix incorrect structure block data length 3dcbdc73b Fix force upgrade patch (#5699) dab6ec6cd List all missing hard depends not just first (#5673) aed5031e3 Fix/Optimize world and light datafixes (#5693) 719040d92 [Auto] Updated Upstream (CraftBukkit) Tuinity Changes: f0e91a4 Updated Upstream (Paper) f88659c Fix and optimise world force upgrading Airplane Changes: 636dbff [ci skip] Cleanup mcdev import files c579320 [ci skip] Remove icons 7ada9a4 [skip ci] Need to specify 1.16.5 in the README of course 813df1a Update README daf3f0b Optimize air case for raytracing 1c252a5 Update Tuinity URL 50babee Updated Upstream (Tuinity) 85e0c63 Revert "Allow plugins to stupidly replace server internals" db3fe2c Remove auto import 6b32e01 Allow plugins to stupidly replace server internals f849f00 Flare Update ac10e43 Flare Update 7f3b091 Move check 040fa19 Better checking for useless move packets Purpur Changes: adb0cafe Updated Upstream (Paper) f9ccf6dd Updated Upstream (Paper & Airplane) 1343a050 Updated Upstream (Paper, Tuinity, & Airplane) af2dd61a Updated Upstream (Paper, Tuinity, & Airplane) 1808888a Expand gamemode extra perms some more Empirecraft Changes: 9e2881e6 Don't dismount on teleports... 7ed16bf3 Updated Paper c3d0a1b2 Re-add missing line in Vehicle teleporting patch * drop Improved-oversized-chunk-data-packet-handling.patch
1218 lines
49 KiB
Diff
1218 lines
49 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: 2No2Name <50278648+2No2Name@users.noreply.github.com>
|
|
Date: Sun, 21 Feb 2021 21:34:18 -0500
|
|
Subject: [PATCH] lithium: skip ticking block entities that are doing nothing
|
|
|
|
|
|
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/collections/ListeningList.java b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/ListeningList.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..edcc9ec27cc7d8dc5bf04e1f70362b505742570c
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/ListeningList.java
|
|
@@ -0,0 +1,255 @@
|
|
+package me.jellysquid.mods.lithium.common.util.collections;
|
|
+
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+import java.util.*;
|
|
+import java.util.function.Consumer;
|
|
+import java.util.function.Predicate;
|
|
+import java.util.function.UnaryOperator;
|
|
+import java.util.stream.Stream;
|
|
+
|
|
+public class ListeningList<T> implements List<T> {
|
|
+ private final List<T> delegate;
|
|
+ private final Runnable changeCallback;
|
|
+
|
|
+ public ListeningList(List<T> delegate, Runnable changeCallback) {
|
|
+ this.delegate = delegate;
|
|
+ this.changeCallback = changeCallback;
|
|
+ }
|
|
+
|
|
+ private void onChange() {
|
|
+ this.changeCallback.run();
|
|
+ }
|
|
+
|
|
+
|
|
+ @Override
|
|
+ public int size() {
|
|
+ return this.delegate.size();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isEmpty() {
|
|
+ return this.delegate.isEmpty();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean contains(Object o) {
|
|
+ return this.delegate.contains(o);
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public Iterator<T> iterator() {
|
|
+ return this.listIterator();
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public Object[] toArray() {
|
|
+ return this.delegate.toArray();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void forEach(Consumer<? super T> consumer) {
|
|
+ this.delegate.forEach(consumer);
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public <T1> T1[] toArray(@NotNull T1[] t1s) {
|
|
+ //noinspection SuspiciousToArrayCall
|
|
+ return this.delegate.toArray(t1s);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean add(T t) {
|
|
+ boolean add = this.delegate.add(t);
|
|
+ this.onChange();
|
|
+ //noinspection ConstantConditions
|
|
+ return add;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean remove(Object o) {
|
|
+ boolean remove = this.delegate.remove(o);
|
|
+ this.onChange();
|
|
+ return remove;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean containsAll(@NotNull Collection<?> collection) {
|
|
+ return this.delegate.containsAll(collection);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean addAll(@NotNull Collection<? extends T> collection) {
|
|
+ boolean addAll = this.delegate.addAll(collection);
|
|
+ this.onChange();
|
|
+ return addAll;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean addAll(int i, @NotNull Collection<? extends T> collection) {
|
|
+ boolean addAll = this.delegate.addAll(i, collection);
|
|
+ this.onChange();
|
|
+ return addAll;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean removeAll(@NotNull Collection<?> collection) {
|
|
+ boolean b = this.delegate.removeAll(collection);
|
|
+ this.onChange();
|
|
+ return b;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean removeIf(Predicate<? super T> predicate) {
|
|
+ boolean b = this.delegate.removeIf(predicate);
|
|
+ this.onChange();
|
|
+ return b;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean retainAll(@NotNull Collection<?> collection) {
|
|
+ boolean b = this.delegate.retainAll(collection);
|
|
+ this.onChange();
|
|
+ return b;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void replaceAll(UnaryOperator<T> unaryOperator) {
|
|
+ this.delegate.replaceAll( unaryOperator);
|
|
+ this.onChange();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sort(Comparator<? super T> comparator) {
|
|
+ this.delegate.sort(comparator);
|
|
+ this.onChange();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void clear() {
|
|
+ this.delegate.clear();
|
|
+ this.onChange();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T get(int i) {
|
|
+ return this.delegate.get(i);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T set(int i, T t) {
|
|
+ T set = this.delegate.set(i, t);
|
|
+ this.onChange();
|
|
+ return set;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void add(int i, T t) {
|
|
+ this.delegate.add(i, t);
|
|
+ this.onChange();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T remove(int i) {
|
|
+ T remove = this.delegate.remove(i);
|
|
+ this.onChange();
|
|
+ return remove;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int indexOf(Object o) {
|
|
+ return this.delegate.indexOf(o);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int lastIndexOf(Object o) {
|
|
+ return this.delegate.lastIndexOf(o);
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public ListIterator<T> listIterator() {
|
|
+ return this.listIterator(0);
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public ListIterator<T> listIterator(int i) {
|
|
+ return new ListIterator<T>() {
|
|
+ final ListIterator<T> itDelegate = ListeningList.this.delegate.listIterator(i);
|
|
+
|
|
+ @Override
|
|
+ public boolean hasNext() {
|
|
+ return this.itDelegate.hasNext();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T next() {
|
|
+ return this.itDelegate.next();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean hasPrevious() {
|
|
+ return this.itDelegate.hasPrevious();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T previous() {
|
|
+ return this.itDelegate.previous();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int nextIndex() {
|
|
+ return this.itDelegate.nextIndex();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int previousIndex() {
|
|
+ return this.itDelegate.previousIndex();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void remove() {
|
|
+ this.itDelegate.remove();
|
|
+ ListeningList.this.onChange();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void set(T t) {
|
|
+ this.itDelegate.set(t);
|
|
+ ListeningList.this.onChange();
|
|
+
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void add(T t) {
|
|
+ this.itDelegate.add(t);
|
|
+ ListeningList.this.onChange();
|
|
+ }
|
|
+ };
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public List<T> subList(int i, int i1) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Spliterator<T> spliterator() {
|
|
+ return this.delegate.spliterator();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Stream<T> stream() {
|
|
+ return this.delegate.stream();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Stream<T> parallelStream() {
|
|
+ return this.delegate.parallelStream();
|
|
+ }
|
|
+}
|
|
\ No newline at end of file
|
|
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/collections/MaskedTickingBlockEntityList.java b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/MaskedTickingBlockEntityList.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..7f7e4810a9aca382d75862e56b0cf93157b54b92
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/MaskedTickingBlockEntityList.java
|
|
@@ -0,0 +1,320 @@
|
|
+package me.jellysquid.mods.lithium.common.util.collections;
|
|
+
|
|
+import com.google.common.collect.Iterators;
|
|
+import it.unimi.dsi.fastutil.ints.IntArrayList;
|
|
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
|
|
+import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+import java.util.*;
|
|
+import java.util.function.Predicate;
|
|
+
|
|
+public class MaskedTickingBlockEntityList<T> implements List<T> {
|
|
+ private final Predicate<T> mayContain;
|
|
+
|
|
+ private final Reference2IntOpenHashMap<T> allElements2Index;
|
|
+ private final ReferenceArrayList<T> allElements;
|
|
+
|
|
+ private final IntArrayList filteredSuccessor;
|
|
+ private final BitSet filteredElementsMask;
|
|
+
|
|
+ private int firstRemovedIndex;
|
|
+
|
|
+ //Visualization of the internal datastructures
|
|
+ //indices: 0 1 2 3 4 5 6 7 8 9
|
|
+ //allElements: A B C D - F G H I J //E was fully removed, C,F,G,I were filtered away
|
|
+ //filteredMask: 1 1 0 1 0 0 0 1 0 1
|
|
+ //successor: 0 1 3 - 7 - - - 9 - - (index offset by 1, due to the first successor having to point to the first element)
|
|
+ //Removals from the allElements ArrayList are done by setting the value to null
|
|
+ //The successor list is used to iterate through the allElements ArrayList with an increasing index, but skipping long chains of null elements.
|
|
+ //The BitSet mask is used to find the predecessor and successor quickly (not asymptotically fast, but fast enough)
|
|
+
|
|
+ public MaskedTickingBlockEntityList(List<T> list, Predicate<T> mayContain) {
|
|
+ this.mayContain = mayContain;
|
|
+ this.allElements = new ReferenceArrayList<>();
|
|
+ this.allElements2Index = new Reference2IntOpenHashMap<>();
|
|
+ this.allElements2Index.defaultReturnValue(-1);
|
|
+ this.filteredSuccessor = new IntArrayList();
|
|
+ this.filteredElementsMask = new BitSet();
|
|
+ this.firstRemovedIndex = Integer.MAX_VALUE;
|
|
+
|
|
+ for (T t : list) {
|
|
+ if (this.mayContain.test(t)) {
|
|
+ int index = this.allElements.size();
|
|
+ this.allElements.add(t);
|
|
+ this.filteredElementsMask.set(index);
|
|
+ this.filteredSuccessor.add(index);
|
|
+ this.allElements2Index.put(t, index);
|
|
+ }
|
|
+ }
|
|
+ this.filteredSuccessor.add(-1);
|
|
+ }
|
|
+
|
|
+ public void setEntryVisible(T t, boolean value) {
|
|
+ this.setEntryVisible(this.allElements2Index.getOrDefault(t, -1), value);
|
|
+ }
|
|
+
|
|
+ public void setEntryVisible(int index, boolean value) {
|
|
+ //Visualization of the operations possible
|
|
+ //All: A B C D - F G H I J (- for null)
|
|
+ //filteredMask:1 1 0 1 0 0 0 1 0 1
|
|
+ //indices: 0 1 2 3 4 5 6 7 8 9
|
|
+ //successor: 0 1 3 - 7 - - - 9 - - (- for no successor)
|
|
+ //Set F visible:
|
|
+ //All: A B C D - F G H I J
|
|
+ //filteredMask:1 1 0 1 0 1 0 1 0 1 //set mask at F to 1
|
|
+ //indices: 0 1 2 3 4 5 6 7 8 9
|
|
+ //successor: 0 1 3 - 5 - 7 - 9 - - //update successor of predecessor to F and set F's successor to old successor of predecessor
|
|
+ //Set D filtered:
|
|
+ //All: A B C D - F G H I J
|
|
+ //Mask: 1 1 0 0 0 1 0 1 0 1 //set mask at D to 0
|
|
+ //indices: 0 1 2 3 4 5 6 7 8 9
|
|
+ //successor: 0 1 5 - - - 7 - 9 - - //update successor of predecessor to old successor of D and remove D's successor value
|
|
+
|
|
+ //These calls do not modify the size, they can't cause rehashing, they are safe to use during iteration
|
|
+ if (index == -1 || value == this.filteredElementsMask.get(index)) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ this.filteredElementsMask.set(index, value);
|
|
+ int predecessor = this.filteredElementsMask.previousSetBit(index - 1);
|
|
+ if (value) {
|
|
+ int successor = this.filteredSuccessor.getInt(predecessor + 1);
|
|
+ this.filteredSuccessor.set(predecessor + 1, index);
|
|
+ this.filteredSuccessor.set(index + 1, successor);
|
|
+ } else {
|
|
+ int successor = this.filteredSuccessor.getInt(index + 1);
|
|
+ this.filteredSuccessor.set(predecessor + 1, successor);
|
|
+ this.filteredSuccessor.set(index + 1, -2); //no successor as this element cannot be reached
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private void compact() {
|
|
+ int targetSize = this.size();
|
|
+ int newIndex = this.firstRemovedIndex - 1;
|
|
+ int lastVisible = this.filteredElementsMask.previousSetBit(newIndex);
|
|
+
|
|
+
|
|
+ for (int i = newIndex + 1; i < this.allElements.size(); i++) {
|
|
+ T t = this.allElements.get(i);
|
|
+ if (t == null) {
|
|
+ continue;
|
|
+ }
|
|
+ boolean visible = this.filteredElementsMask.get(i);
|
|
+ //shift all entries to the lower indices (filling the gaps created by remove() setting null)
|
|
+ newIndex++;
|
|
+ //i is guaranteed to not be smaller than newIndex, therefore we can write to the same collections
|
|
+
|
|
+ this.allElements.set(newIndex, t);
|
|
+ this.allElements2Index.put(t, newIndex);
|
|
+ this.filteredElementsMask.set(newIndex, visible);
|
|
+
|
|
+ //update the successor links
|
|
+ this.filteredSuccessor.set(newIndex + 1, -2); //no successor as there is no next entry yet
|
|
+ if (visible) {
|
|
+ this.filteredSuccessor.set(lastVisible + 1, newIndex);
|
|
+ lastVisible = newIndex;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (newIndex + 1 != targetSize) {
|
|
+ throw new IllegalStateException("Compaction ended up with incorrect size: Should be: " + targetSize + " but is: " + (newIndex + 1));
|
|
+ }
|
|
+
|
|
+ this.filteredSuccessor.set(lastVisible + 1, -1); //-1 means this was the last element
|
|
+ this.firstRemovedIndex = Integer.MAX_VALUE;
|
|
+
|
|
+ this.filteredSuccessor.removeElements(targetSize + 1, this.filteredSuccessor.size());
|
|
+ this.allElements.removeElements(targetSize, this.allElements.size());
|
|
+ this.filteredElementsMask.clear(targetSize, this.filteredElementsMask.size());
|
|
+
|
|
+ this.filteredSuccessor.trim(targetSize * 4);
|
|
+ this.allElements.trim(targetSize * 4);
|
|
+ this.allElements2Index.trim(targetSize * 4);
|
|
+ }
|
|
+
|
|
+ public Iterator<T> filteredIterator() {
|
|
+ return new Iterator<T>() {
|
|
+ int next = MaskedTickingBlockEntityList.this.filteredSuccessor.getInt(0);
|
|
+ T prev;
|
|
+
|
|
+ @Override
|
|
+ public boolean hasNext() {
|
|
+ return this.next != -1;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T next() {
|
|
+ int next = this.next;
|
|
+ T prev = MaskedTickingBlockEntityList.this.allElements.get(next);
|
|
+ this.prev = prev;
|
|
+ this.next = MaskedTickingBlockEntityList.this.filteredSuccessor.getInt(next + 1);
|
|
+ return prev;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void remove() {
|
|
+ MaskedTickingBlockEntityList.this.remove(this.prev);
|
|
+ }
|
|
+ };
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int size() {
|
|
+ return this.allElements2Index.size();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isEmpty() {
|
|
+ return this.size() == 0;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean contains(Object o) {
|
|
+ //noinspection SuspiciousMethodCalls
|
|
+ return this.allElements2Index.containsKey(o);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public @NotNull Iterator<T> iterator() {
|
|
+ return Iterators.unmodifiableIterator(this.allElements2Index.keySet().iterator());
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Object[] toArray() {
|
|
+ return this.allElements2Index.keySet().toArray();
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public <T1> T1[] toArray(@NotNull T1[] t1s) {
|
|
+ //noinspection SuspiciousToArrayCall
|
|
+ return this.allElements2Index.keySet().toArray(t1s);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean add(T t) {
|
|
+ int arraySize = this.allElements.size();
|
|
+ int invalidEntries = arraySize - this.size();
|
|
+ //Compaction is done during the add operation as it is guaranteed to not happen during iteration
|
|
+ if ((arraySize > 2048 && invalidEntries > (arraySize >> 1)) || arraySize >= Integer.MAX_VALUE - 1 && invalidEntries != 0) {
|
|
+ this.compact();
|
|
+ }
|
|
+
|
|
+ if (!this.mayContain.test(t)) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ int index = this.allElements.size();
|
|
+ int i = this.allElements2Index.putIfAbsent(t, index);
|
|
+ if (i != -1) {
|
|
+ return false;
|
|
+ }
|
|
+ this.allElements.add(t);
|
|
+ this.filteredSuccessor.add(0);//increase size so setEntryVisible doesn't crash with indexOutOfBounds
|
|
+ this.setEntryVisible(index, true);
|
|
+
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean remove(Object o) {
|
|
+ int index = this.allElements2Index.removeInt(o);
|
|
+ if (index == -1) {
|
|
+ return false;
|
|
+ }
|
|
+ this.setEntryVisible(index, false);
|
|
+ this.allElements.set(index, null);
|
|
+ this.firstRemovedIndex = Math.min(this.firstRemovedIndex, index);
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean containsAll(@NotNull Collection<?> c) {
|
|
+ return this.allElements2Index.keySet().containsAll(c);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean addAll(@NotNull Collection<? extends T> c) {
|
|
+ boolean b = false;
|
|
+ for (T t : c) {
|
|
+ this.add(t);
|
|
+ b = true;
|
|
+ }
|
|
+ return b;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean addAll(int index, @NotNull Collection<? extends T> c) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean removeAll(@NotNull Collection<?> c) {
|
|
+ boolean b = false;
|
|
+ for (Object t : c) {
|
|
+ b |= this.remove(t);
|
|
+ }
|
|
+ return b;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean retainAll(@NotNull Collection<?> c) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void clear() {
|
|
+ this.allElements2Index.clear();
|
|
+ this.allElements.clear();
|
|
+ this.filteredSuccessor.clear();
|
|
+ this.filteredElementsMask.clear();
|
|
+ this.firstRemovedIndex = Integer.MAX_VALUE;
|
|
+ this.filteredSuccessor.add(-1);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T get(int index) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T set(int index, T element) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void add(int index, T element) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T remove(int index) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int indexOf(Object o) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int lastIndexOf(Object o) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public @NotNull ListIterator<T> listIterator() {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public @NotNull ListIterator<T> listIterator(int index) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public @NotNull List<T> subList(int fromIndex, int toIndex) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/world/blockentity/BlockEntitySleepTracker.java b/src/main/java/me/jellysquid/mods/lithium/common/world/blockentity/BlockEntitySleepTracker.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..c54e1e1f9c6b09022c0f20d5ea4d552bd3ceed55
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/jellysquid/mods/lithium/common/world/blockentity/BlockEntitySleepTracker.java
|
|
@@ -0,0 +1,7 @@
|
|
+package me.jellysquid.mods.lithium.common.world.blockentity;
|
|
+
|
|
+import net.minecraft.world.level.block.entity.TileEntity;
|
|
+
|
|
+public interface BlockEntitySleepTracker {
|
|
+ void setAwake(TileEntity tileEntity, boolean needsTicking);
|
|
+}
|
|
\ No newline at end of file
|
|
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/world/blockentity/SleepingBlockEntity.java b/src/main/java/me/jellysquid/mods/lithium/common/world/blockentity/SleepingBlockEntity.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..4e765ab19ffb300b6c810333b2dc797637ae5c1b
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/jellysquid/mods/lithium/common/world/blockentity/SleepingBlockEntity.java
|
|
@@ -0,0 +1,7 @@
|
|
+package me.jellysquid.mods.lithium.common.world.blockentity;
|
|
+
|
|
+public interface SleepingBlockEntity {
|
|
+ default boolean canTickOnSide(boolean isClient) {
|
|
+ return true;
|
|
+ }
|
|
+}
|
|
\ No newline at end of file
|
|
diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
|
|
index b058c1fa8637b947e8e4a5009258cbee75f536c3..6dce1577a42585a415ea137336c7aa9be6e6a7ed 100644
|
|
--- a/src/main/java/net/minecraft/world/level/World.java
|
|
+++ b/src/main/java/net/minecraft/world/level/World.java
|
|
@@ -98,8 +98,11 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
|
// CraftBukkit end
|
|
|
|
import net.gegy1000.tictacs.NonBlockingWorldAccess; // Yatopia
|
|
+import me.jellysquid.mods.lithium.common.util.collections.MaskedTickingBlockEntityList; // Yatopia
|
|
+import me.jellysquid.mods.lithium.common.world.blockentity.BlockEntitySleepTracker; // Yatopia
|
|
+import me.jellysquid.mods.lithium.common.world.blockentity.SleepingBlockEntity; // Yatopia
|
|
|
|
-public abstract class World implements GeneratorAccess, AutoCloseable, NonBlockingWorldAccess { // Yatopia
|
|
+public abstract class World implements GeneratorAccess, AutoCloseable, NonBlockingWorldAccess, BlockEntitySleepTracker { // Yatopia
|
|
|
|
protected static final Logger LOGGER = LogManager.getLogger();
|
|
public static final Codec<ResourceKey<World>> f = MinecraftKey.a.xmap(ResourceKey.b(IRegistry.L), ResourceKey::a);
|
|
@@ -108,9 +111,17 @@ public abstract class World implements GeneratorAccess, AutoCloseable, NonBlocki
|
|
public static final ResourceKey<World> THE_END = ResourceKey.a(IRegistry.L, new MinecraftKey("the_end"));
|
|
private static final EnumDirection[] a = EnumDirection.values();
|
|
//public final List<TileEntity> tileEntityList = Lists.newArrayList(); // Paper - remove unused list
|
|
- public final List<TileEntity> tileEntityListTick = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); // Yatopia
|
|
+ public List<TileEntity> tileEntityListTick = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); // Yatopia
|
|
protected final List<TileEntity> tileEntityListPending = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); // Yatopia
|
|
protected final java.util.Set<TileEntity> tileEntityListUnload = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>()); // Airplane - use set with faster contains
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ private MaskedTickingBlockEntityList<TileEntity> tileEntityListTick$lithium;
|
|
+
|
|
+ @Override
|
|
+ public void setAwake(TileEntity tileEntity, boolean needsTicking) {
|
|
+ this.tileEntityListTick$lithium.setEntryVisible(tileEntity, needsTicking);
|
|
+ }
|
|
+ // Yatopia end
|
|
public final Thread serverThread;
|
|
private final boolean debugWorld;
|
|
private int d;
|
|
@@ -378,6 +389,8 @@ public abstract class World implements GeneratorAccess, AutoCloseable, NonBlocki
|
|
this.keepSpawnInMemory = this.paperConfig.keepSpawnInMemory; // Paper
|
|
this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
|
|
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
|
|
+ this.tileEntityListTick$lithium = new MaskedTickingBlockEntityList<>(this.tileEntityListTick, blockEntity -> ((SleepingBlockEntity) blockEntity).canTickOnSide(false)); // Yatopia
|
|
+ this.tileEntityListTick = tileEntityListTick$lithium; // Yatopia
|
|
}
|
|
|
|
// Paper start
|
|
@@ -1042,6 +1055,15 @@ public abstract class World implements GeneratorAccess, AutoCloseable, NonBlocki
|
|
|
|
}
|
|
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ public Iterator<TileEntity> getAwakeBlockEntities(List<TileEntity> list) {
|
|
+ if (list == this.tileEntityListTick && list instanceof MaskedTickingBlockEntityList) {
|
|
+ return ((MaskedTickingBlockEntityList<TileEntity>) list).filteredIterator();
|
|
+ }
|
|
+ return list.iterator();
|
|
+ }
|
|
+ // Yatopia end
|
|
+
|
|
public void tickBlockEntities() {
|
|
GameProfilerFiller gameprofilerfiller = this.getMethodProfiler();
|
|
|
|
@@ -1064,11 +1086,19 @@ public abstract class World implements GeneratorAccess, AutoCloseable, NonBlocki
|
|
|
|
this.tickingTileEntities = true;
|
|
// Spigot start
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
// Iterator iterator = this.tileEntityListTick.iterator();
|
|
+ Iterator iterator = getAwakeBlockEntities(this.tileEntityListTick);
|
|
+
|
|
int tilesThisCycle = 0;
|
|
+ while (iterator.hasNext()) {
|
|
+ TileEntity tileentity = (TileEntity) iterator.next();
|
|
+ /*
|
|
for (tileTickPosition = 0; tileTickPosition < tileEntityListTick.size(); tileTickPosition++) { // Paper - Disable tick limiters
|
|
tileTickPosition = (tileTickPosition < tileEntityListTick.size()) ? tileTickPosition : 0;
|
|
TileEntity tileentity = (TileEntity) this.tileEntityListTick.get(tileTickPosition);
|
|
+ */
|
|
+ // Yatopia end
|
|
// Spigot start
|
|
if (tileentity == null) {
|
|
getServer().getLogger().severe("Spigot has detected a null entity and has removed it, preventing a crash");
|
|
@@ -1106,8 +1136,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable, NonBlocki
|
|
throwable.printStackTrace();
|
|
getServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable)));
|
|
// Paper end
|
|
- tilesThisCycle--;
|
|
- this.tileEntityListTick.remove(tileTickPosition--);
|
|
+ iterator.remove(); // Yatopia
|
|
continue;
|
|
// Paper end
|
|
// Spigot start
|
|
@@ -1120,8 +1149,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable, NonBlocki
|
|
|
|
if (tileentity.isRemoved()) {
|
|
// Spigot start
|
|
- tilesThisCycle--;
|
|
- this.tileEntityListTick.remove(tileTickPosition--);
|
|
+ iterator.remove(); // Yatopia
|
|
// Spigot end
|
|
//this.tileEntityList.remove(tileentity); // Paper - remove unused list
|
|
// Paper - prevent double chunk lookups
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntity.java
|
|
index 35c4d5414db66b977a354ac50d35a6aa0fcd4cf8..35aef3647c025eaa763e2b9a5a4e266d556725f5 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntity.java
|
|
@@ -28,8 +28,9 @@ import org.bukkit.inventory.InventoryHolder;
|
|
import org.spigotmc.CustomTimingsHandler; // Spigot
|
|
import co.aikar.timings.MinecraftTimings; // Paper
|
|
import co.aikar.timings.Timing; // Paper
|
|
+import me.jellysquid.mods.lithium.common.world.blockentity.SleepingBlockEntity;
|
|
|
|
-public abstract class TileEntity implements net.minecraft.server.KeyedObject { // Paper
|
|
+public abstract class TileEntity implements net.minecraft.server.KeyedObject, SleepingBlockEntity { // Paper // Yatopia
|
|
|
|
public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper
|
|
// CraftBukkit start - data containers
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeehive.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeehive.java
|
|
index cbee856aec7f1c220dc188d224fe9d60e17c2134..9565ca741ae6608f66ac9d9de384a1ad4de7d338 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeehive.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeehive.java
|
|
@@ -23,6 +23,9 @@ import net.minecraft.world.level.block.BlockBeehive;
|
|
import net.minecraft.world.level.block.BlockCampfire;
|
|
import net.minecraft.world.level.block.BlockFire;
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
+import me.jellysquid.mods.lithium.common.util.collections.ListeningList;
|
|
+import me.jellysquid.mods.lithium.common.world.blockentity.BlockEntitySleepTracker;
|
|
+import java.util.ArrayList;
|
|
|
|
public class TileEntityBeehive extends TileEntity implements ITickable {
|
|
|
|
@@ -30,11 +33,24 @@ public class TileEntityBeehive extends TileEntity implements ITickable {
|
|
@Nullable
|
|
public BlockPosition flowerPos = null;
|
|
public int maxBees = net.pl3x.purpur.PurpurConfig.beeInsideBeeHive; // CraftBukkit - allow setting max amount of bees a hive can hold // Purpur - Change max bees inside beehive and bee_nest
|
|
+ public boolean doInit = true; // Yatopia
|
|
+ public boolean isTicking = true; // Yatopia
|
|
|
|
public TileEntityBeehive() {
|
|
super(TileEntityTypes.BEEHIVE);
|
|
}
|
|
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ public void checkSleepState() {
|
|
+ if (this.world != null ) {
|
|
+ if ((this.bees.size() == 0) == this.isTicking) {
|
|
+ this.isTicking = !this.isTicking;
|
|
+ ((BlockEntitySleepTracker) this.world).setAwake(this, this.isTicking);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Yatopia end
|
|
+
|
|
@Override
|
|
public void update() {
|
|
if (this.d()) {
|
|
@@ -309,6 +325,12 @@ public class TileEntityBeehive extends TileEntity implements ITickable {
|
|
|
|
@Override
|
|
public void tick() {
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (this.doInit) {
|
|
+ this.doInit = false;
|
|
+ this.checkSleepState();
|
|
+ }
|
|
+ // Yatopia end
|
|
if (this.bees.size() == 0) { return; } // Yatopia - TE optimizations
|
|
if (!this.world.isClientSide) {
|
|
this.y();
|
|
@@ -329,6 +351,7 @@ public class TileEntityBeehive extends TileEntity implements ITickable {
|
|
@Override
|
|
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
|
|
super.load(iblockdata, nbttagcompound);
|
|
+ this.checkSleepState(); // Yatopia
|
|
this.bees.clear();
|
|
NBTTagList nbttaglist = nbttagcompound.getList("Bees", 10);
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBell.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBell.java
|
|
index 84f9f52c5b632621b509448ac1c760f64de6b062..c4c983b15c28db856be7335e53637a21af2c1b2f 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBell.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBell.java
|
|
@@ -20,6 +20,7 @@ import net.minecraft.world.entity.player.EntityHuman;
|
|
import net.minecraft.world.level.World;
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
|
import org.apache.commons.lang3.mutable.MutableInt;
|
|
+import me.jellysquid.mods.lithium.common.world.blockentity.BlockEntitySleepTracker;
|
|
|
|
public class TileEntityBell extends TileEntity implements ITickable {
|
|
|
|
@@ -30,6 +31,8 @@ public class TileEntityBell extends TileEntity implements ITickable {
|
|
private List<EntityLiving> h; private List<EntityLiving> getEntitiesAtRing() { return this.h; } // Paper - OBFHELPER
|
|
private boolean i; private boolean getShouldReveal() { return this.i; } // Paper - OBFHELPER
|
|
private int j;
|
|
+ public boolean ringing; // Yatopia
|
|
+ public boolean resonating; // Yatopia
|
|
|
|
public TileEntityBell() {
|
|
super(TileEntityTypes.BELL);
|
|
@@ -37,6 +40,11 @@ public class TileEntityBell extends TileEntity implements ITickable {
|
|
|
|
@Override
|
|
public boolean setProperty(int i, int j) {
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (!this.ringing && i == 1 && this.world != null) {
|
|
+ ((BlockEntitySleepTracker) this.world).setAwake(this, true);
|
|
+ }
|
|
+ // Yatopia end
|
|
if (i == 1) {
|
|
this.f();
|
|
this.j = 0;
|
|
@@ -81,6 +89,11 @@ public class TileEntityBell extends TileEntity implements ITickable {
|
|
}
|
|
}
|
|
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (!this.ringing && !this.resonating && this.world != null) {
|
|
+ ((BlockEntitySleepTracker)this.world).setAwake(this, false);
|
|
+ }
|
|
+ // Yatopia end
|
|
}
|
|
|
|
private void d() {
|
|
@@ -88,6 +101,11 @@ public class TileEntityBell extends TileEntity implements ITickable {
|
|
}
|
|
|
|
public void a(EnumDirection enumdirection) {
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (!this.ringing && this.world != null) {
|
|
+ ((BlockEntitySleepTracker)this.world).setAwake(this, true);
|
|
+ }
|
|
+ // Yatopia end
|
|
BlockPosition blockposition = this.getPosition();
|
|
|
|
this.c = enumdirection;
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
|
|
index 95ca7d9e1eadbe5cc5674ed7352c1ed4d707363d..b5d5f38e520bb5d7912cc86d8ee25858bbd0786b 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
|
|
@@ -34,6 +34,7 @@ import org.bukkit.event.inventory.BrewEvent;
|
|
import org.bukkit.event.inventory.BrewingStandFuelEvent;
|
|
import org.bukkit.inventory.InventoryHolder;
|
|
// CraftBukkit end
|
|
+import me.jellysquid.mods.lithium.common.world.blockentity.BlockEntitySleepTracker;
|
|
|
|
public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory, ITickable {
|
|
|
|
@@ -50,6 +51,7 @@ public class TileEntityBrewingStand extends TileEntityContainer implements IWorl
|
|
private int lastTick = MinecraftServer.currentTick;
|
|
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
private int maxStack = 64;
|
|
+ public boolean isTicking = true; // Yatopia
|
|
|
|
public void onOpen(CraftHumanEntity who) {
|
|
transaction.add(who);
|
|
@@ -72,6 +74,17 @@ public class TileEntityBrewingStand extends TileEntityContainer implements IWorl
|
|
return maxStack;
|
|
}
|
|
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ @Override
|
|
+ public void update() {
|
|
+ super.update();
|
|
+ if (!this.isTicking && this.world != null) {
|
|
+ this.isTicking = true;
|
|
+ ((BlockEntitySleepTracker)this.world).setAwake(this, true);
|
|
+ }
|
|
+ }
|
|
+ // Yatopia end
|
|
+
|
|
public void setMaxStackSize(int size) {
|
|
maxStack = size;
|
|
}
|
|
@@ -141,6 +154,12 @@ public class TileEntityBrewingStand extends TileEntityContainer implements IWorl
|
|
|
|
@Override
|
|
public void tick() {
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (this.brewTime == 0 && this.world != null) {
|
|
+ this.isTicking = false;
|
|
+ ((BlockEntitySleepTracker)this.world).setAwake(this, false);
|
|
+ }
|
|
+ // Yatopia end
|
|
ItemStack itemstack = (ItemStack) this.items.get(4);
|
|
|
|
if (this.fuelLevel <= 0 && itemstack.getItem() == Items.BLAZE_POWDER) {
|
|
@@ -280,6 +299,12 @@ public class TileEntityBrewingStand extends TileEntityContainer implements IWorl
|
|
@Override
|
|
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
|
|
super.load(iblockdata, nbttagcompound);
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (!this.isTicking && this.world != null) {
|
|
+ this.isTicking = true;
|
|
+ ((BlockEntitySleepTracker) this.world).setAwake(this, true);
|
|
+ }
|
|
+ // Yatopia end
|
|
this.items = NonNullList.a(this.getSize(), ItemStack.b);
|
|
ContainerUtil.b(nbttagcompound, this.items);
|
|
this.brewTime = nbttagcompound.getShort("BrewTime");
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityCampfire.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityCampfire.java
|
|
index 08759f461ec947c0d5655557f49d8717afee6f00..cdff01d4da417ef1be6238d3faaf464ee7884bd5 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityCampfire.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityCampfire.java
|
|
@@ -27,12 +27,18 @@ import org.bukkit.craftbukkit.block.CraftBlock;
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
import org.bukkit.event.block.BlockCookEvent;
|
|
// CraftBukkit end
|
|
+import net.minecraft.core.NonNullList;
|
|
+import me.jellysquid.mods.lithium.common.world.blockentity.BlockEntitySleepTracker;
|
|
|
|
public class TileEntityCampfire extends TileEntity implements Clearable, ITickable {
|
|
|
|
private final NonNullList<ItemStack> items;
|
|
public final int[] cookingTimes;
|
|
public final int[] cookingTotalTimes;
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ public boolean isTicking = true;
|
|
+ public boolean doInit = true;
|
|
+ // Yatopia end
|
|
|
|
public TileEntityCampfire() {
|
|
super(TileEntityTypes.CAMPFIRE);
|
|
@@ -41,8 +47,50 @@ public class TileEntityCampfire extends TileEntity implements Clearable, ITickab
|
|
this.cookingTotalTimes = new int[4];
|
|
}
|
|
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ @Override
|
|
+ public void update() {
|
|
+ super.update();
|
|
+ this.checkSleepState();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void invalidateBlockCache() {
|
|
+ super.invalidateBlockCache();
|
|
+ this.checkSleepState();
|
|
+ }
|
|
+
|
|
+ public void checkSleepState() {
|
|
+ if (this.world == null) {
|
|
+ return;
|
|
+ }
|
|
+ boolean shouldTick = false;
|
|
+ NonNullList<ItemStack> beingCooked = this.items;
|
|
+ for (int i = 0; i < beingCooked.size(); i++) {
|
|
+ ItemStack stack = beingCooked.get(i);
|
|
+ if (!stack.isEmpty()) {
|
|
+ if (this.cookingTimes[i] > 0 || this.getBlock().get(BlockCampfire.LIT)) {
|
|
+ shouldTick = true;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (shouldTick != this.isTicking) {
|
|
+ this.isTicking = shouldTick;
|
|
+ ((BlockEntitySleepTracker)this.world).setAwake(this, shouldTick);
|
|
+ }
|
|
+ }
|
|
+ // Yatopia end
|
|
+
|
|
@Override
|
|
public void tick() {
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (this.doInit) {
|
|
+ this.doInit = false;
|
|
+ this.checkSleepState();
|
|
+ }
|
|
+ // Yatopia end
|
|
boolean flag = (Boolean) this.getBlock().get(BlockCampfire.LIT);
|
|
boolean flag1 = this.world.isClientSide;
|
|
|
|
@@ -149,6 +197,7 @@ public class TileEntityCampfire extends TileEntity implements Clearable, ITickab
|
|
@Override
|
|
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
|
|
super.load(iblockdata, nbttagcompound);
|
|
+ this.checkSleepState(); // Yatopia - lithium: skip ticking block entities that are doing nothing
|
|
this.items.clear();
|
|
ContainerUtil.b(nbttagcompound, this.items);
|
|
int[] aint;
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityChest.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityChest.java
|
|
index cfabc9047cd3e972af84700725355d0fe149b221..4f5f050a947cd708ab375565192fde03ba79d7c4 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityChest.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityChest.java
|
|
@@ -33,14 +33,27 @@ import net.minecraft.world.level.block.Blocks;
|
|
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
import org.bukkit.entity.HumanEntity;
|
|
// CraftBukkit end
|
|
+ import me.jellysquid.mods.lithium.common.world.blockentity.BlockEntitySleepTracker; // Yatopia
|
|
|
|
public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITickable
|
|
|
|
private gg.airplane.structs.ItemListWithBitset items; // Airplane
|
|
protected float a;
|
|
+ private float getAnimationAngle() { return a; } // Yatopia - OBFHELPER
|
|
protected float b;
|
|
+ private float getLastAnimationAngle() { return b; } // Yatopia - OBFHELPER
|
|
public int viewingCount;
|
|
private int j;
|
|
+ private int ticksOpen = j; // Yatopia - OBFHELPER
|
|
+ private int lastTime; // Yatopia
|
|
+
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ public void checkWakeUp() {
|
|
+ if ((this.viewingCount != 0 || this.getAnimationAngle() != 0.0F || this.getLastAnimationAngle() != 0) && this.world != null) {
|
|
+ ((BlockEntitySleepTracker) this.world).setAwake(this, true);
|
|
+ }
|
|
+ }
|
|
+ // Yatopia end
|
|
|
|
// CraftBukkit start - add fields and methods
|
|
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
@@ -135,11 +148,27 @@ public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITic
|
|
}
|
|
|
|
public void tick() {
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ // noinspection ConstantConditions
|
|
+ int time = (int) this.world.getTime();
|
|
+ // ticksOpen == 0 implies most likely that this is the first tick. We don't want to update the value then.
|
|
+ // overflow case is handled by not going to sleep when this.ticksOpen == 0
|
|
+ if (this.ticksOpen != 0) {
|
|
+ this.ticksOpen += time - this.lastTime - 1;
|
|
+ }
|
|
+ this.lastTime = time;
|
|
+ // Yatopia end
|
|
+
|
|
int i = this.position.getX();
|
|
int j = this.position.getY();
|
|
int k = this.position.getZ();
|
|
|
|
++this.j;
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (this.viewingCount == 0 && this.getAnimationAngle() == 0.0F && this.getLastAnimationAngle() == 0 && this.ticksOpen != 0 && this.world != null) {
|
|
+ ((BlockEntitySleepTracker) this.world).setAwake(this, false);
|
|
+ }
|
|
+ // Yatopia end
|
|
}
|
|
|
|
public void doOpenLogic() {
|
|
@@ -245,6 +274,7 @@ public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITic
|
|
|
|
@Override
|
|
public boolean setProperty(int i, int j) {
|
|
+ this.checkWakeUp(); // Yatopia - lithium: skip ticking block entities that are doing nothing
|
|
if (i == 1) {
|
|
this.viewingCount = j;
|
|
return true;
|
|
@@ -276,7 +306,7 @@ public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITic
|
|
// CraftBukkit end
|
|
this.onOpen();
|
|
}
|
|
-
|
|
+ this.checkWakeUp(); // Yatopia - lithium: skip ticking block entities that are doing nothing
|
|
}
|
|
|
|
@Override
|
|
@@ -297,6 +327,7 @@ public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITic
|
|
// CraftBukkit end
|
|
this.onOpen();
|
|
}
|
|
+ this.checkWakeUp(); // Yatopia - lithium: skip ticking block entities that are doing nothing
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityEnchantTable.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityEnchantTable.java
|
|
index 4b1cb089355b455c6210f2df1af797cc363997cf..0049a675557cbc05e361c12e9fb84a38a3a21160 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityEnchantTable.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityEnchantTable.java
|
|
@@ -9,6 +9,7 @@ import net.minecraft.util.MathHelper;
|
|
import net.minecraft.world.INamableTileEntity;
|
|
import net.minecraft.world.entity.player.EntityHuman;
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
+import me.jellysquid.mods.lithium.common.world.blockentity.BlockEntitySleepTracker;
|
|
|
|
public class TileEntityEnchantTable extends TileEntity implements INamableTileEntity, ITickable {
|
|
|
|
@@ -51,6 +52,7 @@ public class TileEntityEnchantTable extends TileEntity implements INamableTileEn
|
|
@Override
|
|
public void tick() {
|
|
if (!org.yatopiamc.yatopia.server.YatopiaConfig.shouldTickEnchantingTables) { return; } // Yatopia - TE optimizations
|
|
+ ((BlockEntitySleepTracker) this.world).setAwake(this, false); // Yatopia
|
|
this.j = this.i;
|
|
this.l = this.k;
|
|
EntityHuman entityhuman = this.world.a((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D, 3.0D, false);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityFurnace.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityFurnace.java
|
|
index 8ec9ed518a3b5f70c5a5d74605a1f17d0f47b300..d8ef6d464ed32fe61dd9d1d5ff7c70994998f934 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityFurnace.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityFurnace.java
|
|
@@ -53,9 +53,11 @@ import org.bukkit.event.inventory.FurnaceBurnEvent;
|
|
import org.bukkit.event.inventory.FurnaceExtractEvent;
|
|
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
|
// CraftBukkit end
|
|
+import me.jellysquid.mods.lithium.common.world.blockentity.BlockEntitySleepTracker;
|
|
|
|
public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput, ITickable {
|
|
|
|
+ private boolean isTicking = true; // Yatopia
|
|
private static final int[] g = new int[]{0};
|
|
private static final int[] h = new int[]{2, 1};
|
|
private static final int[] i = new int[]{1};
|
|
@@ -197,6 +199,17 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
|
private int maxStack = MAX_STACK;
|
|
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ @Override
|
|
+ public void update() {
|
|
+ super.update();
|
|
+ if (!this.isTicking && this.world != null) {
|
|
+ this.isTicking = true;
|
|
+ ((BlockEntitySleepTracker) this.world).setAwake(this, true);
|
|
+ }
|
|
+ }
|
|
+ // Yatopia end
|
|
+
|
|
public List<ItemStack> getContents() {
|
|
return this.items;
|
|
}
|
|
@@ -259,6 +272,12 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
|
@Override
|
|
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
|
|
super.load(iblockdata, nbttagcompound);
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (!this.isTicking && this.world != null) {
|
|
+ this.isTicking = true;
|
|
+ ((BlockEntitySleepTracker)this.world).setAwake(this, true);
|
|
+ }
|
|
+ // Yatopia end
|
|
this.items = NonNullList.a(this.getSize(), ItemStack.b);
|
|
ContainerUtil.b(nbttagcompound, this.items);
|
|
this.burnTime = nbttagcompound.getShort("BurnTime");
|
|
@@ -389,7 +408,12 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
|
if (flag1) {
|
|
this.update();
|
|
}
|
|
-
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (!this.isTicking && this.world != null) {
|
|
+ this.isTicking = true;
|
|
+ ((BlockEntitySleepTracker)this.world).setAwake(this, true);
|
|
+ }
|
|
+ // Yatopia end
|
|
}
|
|
|
|
protected boolean canBurn(@Nullable IRecipe<?> irecipe) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java
|
|
index c1a90eb01689b8b91200ba49d58360d5ea2004c4..8095740f1848443e87fd52c14d19dabb00a3ecd4 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java
|
|
@@ -33,6 +33,7 @@ import net.minecraft.world.phys.shapes.VoxelShapes;
|
|
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
import org.bukkit.entity.HumanEntity;
|
|
// CraftBukkit end
|
|
+import me.jellysquid.mods.lithium.common.world.blockentity.BlockEntitySleepTracker;
|
|
|
|
public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory, ITickable {
|
|
|
|
@@ -41,7 +42,9 @@ public class TileEntityShulkerBox extends TileEntityLootable implements IWorldIn
|
|
public int viewingCount;
|
|
private TileEntityShulkerBox.AnimationPhase i;
|
|
private float j;
|
|
+ public float animationProgress = j; // Yatopia - OBFHELPER
|
|
private float k;
|
|
+ public float prevAnimationProgress = k; // Yatopia - OBFHELPER
|
|
@Nullable
|
|
private EnumColor l;
|
|
private boolean m;
|
|
@@ -96,6 +99,11 @@ public class TileEntityShulkerBox extends TileEntityLootable implements IWorldIn
|
|
this.m();
|
|
}
|
|
|
|
+ // Yatopia start - lithium: skip ticking block entities that are doing nothing
|
|
+ if (this.getAnimationPhase() == TileEntityShulkerBox.AnimationPhase.CLOSED && this.prevAnimationProgress == 0f && this.animationProgress == 0f && this.world != null) {
|
|
+ ((BlockEntitySleepTracker) this.world).setAwake(this, false);
|
|
+ }
|
|
+ // Yatopia end
|
|
}
|
|
|
|
protected void h() {
|
|
@@ -127,6 +135,7 @@ public class TileEntityShulkerBox extends TileEntityLootable implements IWorldIn
|
|
|
|
}
|
|
|
|
+ public TileEntityShulkerBox.AnimationPhase getAnimationPhase() {return this.j(); } // Yatopia - OBFHELPER
|
|
public TileEntityShulkerBox.AnimationPhase j() {
|
|
return this.i;
|
|
}
|
|
@@ -209,6 +218,7 @@ public class TileEntityShulkerBox extends TileEntityLootable implements IWorldIn
|
|
|
|
@Override
|
|
public boolean setProperty(int i, int j) {
|
|
+ if (this.world != null && i == 1) ((BlockEntitySleepTracker) this.world).setAwake(this, true); // Yatopia
|
|
if (i == 1) {
|
|
this.viewingCount = j;
|
|
if (j == 0) {
|