-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from iron431/worldupdater
Worldupdater
- Loading branch information
Showing
4 changed files
with
193 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/io/redspace/ironsspellbooks/util/ByteHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package io.redspace.ironsspellbooks.util; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.IOException; | ||
|
||
public class ByteHelper { | ||
/** | ||
* Returns the start position of the first occurrence of the specified {@code target} within | ||
* {@code array}, or {@code -1} if there is no such occurrence. | ||
* | ||
* <p>More formally, returns the lowest index {@code i} such that {@code Arrays.copyOfRange(array, | ||
* i, i + target.length)} contains exactly the same elements as {@code target}. | ||
* | ||
* @param array the array to search for the sequence {@code target} | ||
* @param target the array to search for as a sub-sequence of {@code array} | ||
*/ | ||
public static int indexOf(byte[] array, int length, byte[] target) { | ||
if (array == null || target == null || target.length == 0 || length == 0) { | ||
return -1; | ||
} | ||
|
||
outer: | ||
for (int i = 0; i < length - target.length + 1; i++) { | ||
for (int j = 0; j < target.length; j++) { | ||
if (array[i + j] != target[j]) { | ||
continue outer; | ||
} | ||
} | ||
return i; | ||
} | ||
return -1; | ||
} | ||
|
||
public static int indexOf(DataInputStream dataInputStream, byte[] target) throws IOException { | ||
if (dataInputStream == null || target == null || target.length == 0) { | ||
return -1; | ||
} | ||
|
||
int index = -1; | ||
int data; | ||
|
||
outer: | ||
do { | ||
data = dataInputStream.read(); | ||
index++; | ||
|
||
int addlReadCount = 0; | ||
|
||
for (int j = 0; j < target.length; j++) { | ||
if (data != target[j]) { | ||
index += addlReadCount; | ||
continue outer; | ||
} else if (j < target.length - 1) { | ||
data = dataInputStream.read(); | ||
addlReadCount++; | ||
if (data == -1) { | ||
return -1; | ||
} | ||
} | ||
} | ||
return index; | ||
} while (data != -1); | ||
return -1; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/io/redspace/ironsspellbooks/util/CodeTimer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.redspace.ironsspellbooks.util; | ||
|
||
import net.minecraft.util.Tuple; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CodeTimer { | ||
private final List<Tuple<String, Long>> timing = new ArrayList<>(); | ||
|
||
public CodeTimer() { | ||
add("START"); | ||
} | ||
|
||
public void add(String name) { | ||
timing.add(new Tuple<>(name, System.nanoTime())); | ||
} | ||
|
||
public String getOutput(String delimiter) { | ||
StringBuilder sb = new StringBuilder(); | ||
|
||
long itemDelta = 0; | ||
long totalDelta = 0; | ||
|
||
for (int i = 0; i < timing.size(); i++) { | ||
var item = timing.get(i); | ||
|
||
if (i > 0) { | ||
var lastItem = timing.get(i - 1); | ||
itemDelta = item.getB() - lastItem.getB(); | ||
totalDelta += itemDelta; | ||
sb.append(String.format("%s%s%s%s%f%s%f\n", lastItem.getA(), delimiter, item.getA(), delimiter, (itemDelta / 1000000d), delimiter, totalDelta / 1000000d)); | ||
} | ||
} | ||
|
||
return sb.toString(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getOutput("\t"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
#Making Minecraft's UpgradeRecipe fields public for use in JEI integration | ||
public net.minecraft.world.item.crafting.UpgradeRecipe f_44518_ # base | ||
public net.minecraft.world.item.crafting.UpgradeRecipe f_44519_ # addition | ||
|
||
#Making Minecraft's structure gen pools public for adding houses to village generation | ||
public net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool f_210560_ # templates | ||
public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool f_210559_ # rawTemplates | ||
|
||
#Making the dispenser behavior map public so that we can save the old entry before overriding it | ||
public net.minecraft.world.level.block.DispenserBlock f_52661_ #DISPENSER_REGISTRY | ||
|
||
#Making PotionBrewing's addMix public so we can register our own recipes | ||
public net.minecraft.world.item.alchemy.PotionBrewing m_43513_(Lnet/minecraft/world/item/alchemy/Potion;Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/alchemy/Potion;)V #addMix(Potion, Item, Potion) | ||
public net.minecraft.world.item.alchemy.PotionBrewing f_43495_ | ||
|
||
#Making the loot table of a ranomized container public for debugging | ||
public net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity f_59605_ | ||
public net.minecraft.server.MinecraftServer f_129744_ | ||
|
||
#Making the falling block parmeters public for more control over custom falling blocks | ||
public net.minecraft.world.entity.item.FallingBlockEntity <init>(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/level/block/state/BlockState;)V #constructor | ||
public net.minecraft.world.entity.item.FallingBlockEntity f_31947_ #cancelDrop | ||
public net.minecraft.world.entity.item.FallingBlockEntity f_31946_ #blockstate | ||
|
||
#Making item particles (eating, tool breaking, etc) public so that the scroll can use the same particle code | ||
public net.minecraft.world.entity.LivingEntity m_21060_(Lnet/minecraft/world/item/ItemStack;I)V | ||
public net.minecraft.world.entity.LivingEntity m_21060_(Lnet/minecraft/world/item/ItemStack;I)V | ||
|
||
#Irons World Upgrader | ||
public net.minecraft.world.level.chunk.storage.ChunkStorage f_63495_ #worker | ||
public net.minecraft.world.level.chunk.storage.IOWorker f_63518_ #storage | ||
public net.minecraft.world.level.chunk.storage.RegionFileStorage m_63711_(Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/storage/RegionFile; #getRegionFile | ||
|
||
# Makes public the 'makeExecutor' method in Util, | ||
# accepting a String and returns an ExecutorService | ||
public net.minecraft.Util m_137477_(Ljava/lang/String;)Ljava/util/concurrent/ExecutorService; #makeExecutor |