mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-23 17:09:19 +00:00
improve waterlogged
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
package net.momirealms.craftengine.core.block;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import net.momirealms.craftengine.core.pack.model.generation.AbstractModelGenerator;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class AbstractBlockManager extends AbstractModelGenerator implements BlockManager {
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ public class BlockSettings {
|
||||
float hardness = 2f;
|
||||
float resistance = 2f;
|
||||
boolean canOcclude;
|
||||
boolean fluidState;
|
||||
Tristate isRedstoneConductor = Tristate.UNDEFINED;
|
||||
Tristate isSuffocating = Tristate.UNDEFINED;
|
||||
Tristate isViewBlocking = Tristate.UNDEFINED;
|
||||
@@ -75,6 +76,7 @@ public class BlockSettings {
|
||||
newSettings.isSuffocating = settings.isSuffocating;
|
||||
newSettings.isViewBlocking = settings.isViewBlocking;
|
||||
newSettings.correctTools = settings.correctTools;
|
||||
newSettings.fluidState = settings.fluidState;
|
||||
return newSettings;
|
||||
}
|
||||
|
||||
@@ -94,6 +96,10 @@ public class BlockSettings {
|
||||
return resistance;
|
||||
}
|
||||
|
||||
public boolean fluidState() {
|
||||
return fluidState;
|
||||
}
|
||||
|
||||
public boolean isRandomlyTicking() {
|
||||
return isRandomlyTicking;
|
||||
}
|
||||
@@ -250,6 +256,11 @@ public class BlockSettings {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockSettings fluidState(boolean state) {
|
||||
this.fluidState = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface Modifier {
|
||||
|
||||
void apply(BlockSettings settings);
|
||||
@@ -332,6 +343,10 @@ public class BlockSettings {
|
||||
Map<String, Object> soundMap = MiscUtils.castToMap(value, false);
|
||||
return settings -> settings.sounds(BlockSounds.fromMap(soundMap));
|
||||
}));
|
||||
registerFactory("fluid-state", (value -> {
|
||||
String state = (String) value;
|
||||
return settings -> settings.fluidState(state.equals("water"));
|
||||
}));
|
||||
registerFactory("can-occlude", (value -> {
|
||||
boolean booleanValue = (boolean) value;
|
||||
return settings -> settings.canOcclude(booleanValue);
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.momirealms.craftengine.core.plugin;
|
||||
import net.momirealms.craftengine.core.block.BlockManager;
|
||||
import net.momirealms.craftengine.core.entity.furniture.FurnitureManager;
|
||||
import net.momirealms.craftengine.core.font.ImageManager;
|
||||
import net.momirealms.craftengine.core.font.AbstractImageManager;
|
||||
import net.momirealms.craftengine.core.item.ItemManager;
|
||||
import net.momirealms.craftengine.core.item.recipe.RecipeManager;
|
||||
import net.momirealms.craftengine.core.loot.VanillaLootManager;
|
||||
|
||||
@@ -249,7 +249,7 @@ public class ConfigManager implements Reloadable {
|
||||
|
||||
Class<?> modClazz = ReflectionUtils.getClazz(CraftEngine.MOD_CLASS);
|
||||
if (modClazz != null) {
|
||||
Method setMaxChainMethod = ReflectionUtils.getStaticMethod(modClazz, new String[] {"setMaxChainUpdate"}, void.class, int.class);
|
||||
Method setMaxChainMethod = ReflectionUtils.getStaticMethod(modClazz, void.class, new String[] {"setMaxChainUpdate"}, int.class);
|
||||
try {
|
||||
assert setMaxChainMethod != null;
|
||||
setMaxChainMethod.invoke(null, performance$max_block_chain_update_limit);
|
||||
|
||||
@@ -321,7 +321,7 @@ public class ReflectionUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Method getStaticMethod(final Class<?> clazz, String[] possibleNames, Class<?> returnType, final Class<?>... parameterTypes) {
|
||||
public static Method getStaticMethod(final Class<?> clazz, Class<?> returnType, String[] possibleNames, final Class<?>... parameterTypes) {
|
||||
outer:
|
||||
for (Method method : clazz.getMethods()) {
|
||||
if (method.getParameterCount() != parameterTypes.length) {
|
||||
|
||||
Reference in New Issue
Block a user