Skip to content

Commit

Permalink
Update to 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Mar 14, 2023
1 parent 105dbc0 commit 9fe3999
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 73 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
name: Artifacts
path: |
EntityCulling-Fabric/build/libs/*
EntityCulling-Forge/build/libs/*
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,6 @@ jobs:
with:
files: |
EntityCulling-Fabric/build/libs/*
EntityCulling-Forge/build/libs/*
- name: Publish-Forge-Curseforge
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 448233
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: forge
name: ${{github.ref_name}} - Forge
version-type: beta
files: '*Forge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
- name: Publish-Forge-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: NNAgCjsB
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: forge
name: ${{github.ref_name}} - Forge
files: '*Forge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
- name: Publish-Fabric
uses: Kir-Antipov/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion EntityCulling-Fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@

"depends": {
"fabric-api": "*",
"minecraft": ">=1.19.3"
"minecraft": ">=1.19.4"
}
}
4 changes: 2 additions & 2 deletions EntityCulling-Forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ loaderVersion="[35,)"
license="tr7zw Protective License"
[[mods]]
modId="entityculling"
version="1.6.1"
version="1.6.2"
displayName="EntityCulling"
authors="tr7zw"
description='''
Expand All @@ -19,6 +19,6 @@ Using async raytracing to hide Tile-/Entities that are hidden behind solid block
[[dependencies.entityculling]]
modId="minecraft"
mandatory=true
versionRange="[1.19.3,)"
versionRange="[1.19.4,)"
ordering="NONE"
side="CLIENT"
2 changes: 1 addition & 1 deletion Shared/src/main/java/dev/tr7zw/entityculling/CullTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CullTask(OcclusionCullingInstance culling, Set<BlockEntityType<?>> blockE

@Override
public void run() {
while (client.getGame() != null) { // client.isRunning() returns false at the start?!?
while (client.isRunning()) { // client.isRunning() returns false at the start?!?
try {
Thread.sleep(sleepDelay);
if (EntityCullingModBase.enabled && client.level != null && client.player != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ public abstract class EntityCullingModBase {
private Thread cullThread;
protected KeyMapping keybind = new KeyMapping("key.entityculling.toggle", -1, "EntityCulling");
protected boolean pressed = false;
private boolean configKeysLoaded = false;
private boolean lateInit = false;
private Set<Function<BlockEntity, Boolean>> dynamicBlockEntityWhitelist = new HashSet<>();
private Set<Function<Entity, Boolean>> dynamicEntityWhitelist = new HashSet<>();

public Config config;
private final File settingsFile = new File("config", "entityculling.json");
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
//stats
public int renderedBlockEntities = 0;
public int skippedBlockEntities = 0;
public int renderedEntities = 0;
public int skippedEntities = 0;
public int tickedEntities = 0;
public int skippedEntityTicks = 0;

public void onInitialize() {
instance = this;

// stats
public int renderedBlockEntities = 0;
public int skippedBlockEntities = 0;
public int renderedEntities = 0;
public int skippedEntities = 0;
public int tickedEntities = 0;
public int skippedEntityTicks = 0;

public void onInitialize() {
instance = this;
if (settingsFile.exists()) {
try {
config = gson.fromJson(new String(Files.readAllBytes(settingsFile.toPath()), StandardCharsets.UTF_8),
Expand All @@ -71,22 +71,22 @@ public void onInitialize() {
config = new Config();
writeConfig();
} else {
if(ConfigUpgrader.upgradeConfig(config)) {
if (ConfigUpgrader.upgradeConfig(config)) {
writeConfig(); // Config got modified
}
}
culling = new OcclusionCullingInstance(config.tracingDistance, new Provider());
cullTask = new CullTask(culling, blockEntityWhitelist, entityWhistelist);

cullThread = new Thread(cullTask, "CullThread");
cullThread.setUncaughtExceptionHandler((thread, ex) -> {
System.out.println("The CullingThread has crashed! Please report the following stacktrace!");
ex.printStackTrace();
});
cullThread.start();
initModloader();
}
cullThread = new Thread(cullTask, "CullThread");
cullThread.setUncaughtExceptionHandler((thread, ex) -> {
System.out.println("The CullingThread has crashed! Please report the following stacktrace!");
ex.printStackTrace();
});
initModloader();
}

public void writeConfig() {
if (settingsFile.exists())
settingsFile.delete();
Expand All @@ -96,28 +96,33 @@ public void writeConfig() {
e1.printStackTrace();
}
}

public void worldTick() {
cullTask.requestCull = true;
}

@SuppressWarnings("resource")
public void clientTick() {
if(!configKeysLoaded) {
for(String blockId : config.blockEntityWhitelist) {
Optional<BlockEntityType<?>> block = BuiltInRegistries.BLOCK_ENTITY_TYPE.getOptional(new ResourceLocation(blockId));
if (!lateInit) {
lateInit = true;
cullThread.start();
for (String blockId : config.blockEntityWhitelist) {
Optional<BlockEntityType<?>> block = BuiltInRegistries.BLOCK_ENTITY_TYPE
.getOptional(new ResourceLocation(blockId));
block.ifPresent(b -> {
blockEntityWhitelist.add(b);
});
}
for(String entityType : config.tickCullingWhitelist) {
Optional<EntityType<?>> entity = BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(entityType));
for (String entityType : config.tickCullingWhitelist) {
Optional<EntityType<?>> entity = BuiltInRegistries.ENTITY_TYPE
.getOptional(new ResourceLocation(entityType));
entity.ifPresent(e -> {
entityWhistelist.add(e);
});
}
for(String entityType : config.entityWhitelist) {
Optional<EntityType<?>> entity = BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(entityType));
for (String entityType : config.entityWhitelist) {
Optional<EntityType<?>> entity = BuiltInRegistries.ENTITY_TYPE
.getOptional(new ResourceLocation(entityType));
entity.ifPresent(e -> {
entityWhistelist.add(e);
});
Expand All @@ -129,7 +134,7 @@ public void clientTick() {
pressed = true;
enabled = !enabled;
LocalPlayer player = Minecraft.getInstance().player;
if(enabled) {
if (enabled) {
if (player != null) {
player.sendSystemMessage(Component.literal("Culling on").withStyle(ChatFormatting.GREEN));
}
Expand All @@ -145,43 +150,45 @@ public void clientTick() {
}

public abstract void initModloader();

public abstract AABB setupAABB(BlockEntity entity, BlockPos pos);

public boolean isDynamicWhitelisted(BlockEntity entity) {
for(Function<BlockEntity, Boolean> fun : dynamicBlockEntityWhitelist) {
if(fun.apply(entity)) {
for (Function<BlockEntity, Boolean> fun : dynamicBlockEntityWhitelist) {
if (fun.apply(entity)) {
return true;
}
}
return false;
}

public boolean isDynamicWhitelisted(Entity entity) {
for(Function<Entity, Boolean> fun : dynamicEntityWhitelist) {
if(fun.apply(entity)) {
for (Function<Entity, Boolean> fun : dynamicEntityWhitelist) {
if (fun.apply(entity)) {
return true;
}
}
return false;
}

/**
* Add a dynamic function that can return true to disable culling for a BlockEntity temporarly.
* Add a dynamic function that can return true to disable culling for a
* BlockEntity temporarly.
*
* @param function
*/
public void addDynamicBlockEntityWhitelist(Function<BlockEntity, Boolean> function) {
this.dynamicBlockEntityWhitelist.add(function);
}

/**
* Add a dynamic function that can return true to disable culling for an entity temporarly.
* Add a dynamic function that can return true to disable culling for an entity
* temporarly.
*
* @param function
*/
public void addDynamicEntityWhitelist(Function<Entity, Boolean> function) {
this.dynamicEntityWhitelist.add(function);
}

}
10 changes: 5 additions & 5 deletions gradle-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: '0.0.2'
source: "https://github.com/tr7zw/ModComposeTemplate/tree/1.19.3"
source: "https://github.com/tr7zw/ModComposeTemplate/tree/1.19.4"
replacements:
group: "dev.tr7zw"
name: "EntityCulling"
id: "entityculling"
version: "1.6.1"
version: "1.6.2"
author: "tr7zw"
relocationpackage: "dev.tr7zw.entityculling"
dependencies: '
Expand All @@ -16,13 +16,13 @@ replacements:
enabledFlags:
- autopublish
- publishFabric
- publishForge
# - publishForge
- modrinth
- curseforge
rootProject:
template: "."
subProjects:
EntityCulling-Fabric:
template: "Fabric"
EntityCulling-Forge:
template: "Forge"
# EntityCulling-Forge:
# template: "Forge"

0 comments on commit 9fe3999

Please sign in to comment.