Skip to content

Commit

Permalink
fix bugs, improve ModifyBlockRenderPowerType, cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dueris committed Nov 15, 2024
1 parent 2c74eba commit 8e962c7
Show file tree
Hide file tree
Showing 373 changed files with 9,428 additions and 10,379 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ public interface MovingEntity {
boolean apoli$isMoving();

boolean apoli$isMovingVertically();

boolean apoli$isMovingHorizontally();

double apoli$getVerticalMovementValue();

double apoli$getHorizontalMovementValue();

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import java.util.function.Function;
import java.util.function.Supplier;

public record ActionConfiguration<T extends AbstractActionType<?, ?>>(ResourceLocation id, TypedDataObjectFactory<T> dataFactory) implements TypeConfiguration<T> {
public record ActionConfiguration<T extends AbstractActionType<?, ?>>(ResourceLocation id,
TypedDataObjectFactory<T> dataFactory) implements TypeConfiguration<T> {

public static <T extends AbstractActionType<?, ?>> ActionConfiguration<T> of(ResourceLocation id, SerializableData serializableData, Function<SerializableData.Instance, T> fromData, BiFunction<T, SerializableData, SerializableData.Instance> toData) {
TypedDataObjectFactory<T> dataFactory = TypedDataObjectFactory.simple(serializableData, fromData, toData);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.github.dueris.originspaper.action;

import java.util.Optional;

import io.github.dueris.calio.data.SerializableDataType;
import io.github.dueris.originspaper.action.context.BlockActionContext;
import io.github.dueris.originspaper.action.type.BlockActionType;
Expand All @@ -12,6 +10,8 @@
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;

import java.util.Optional;

public final class BlockAction extends AbstractAction<BlockActionContext, BlockActionType> {

public static final SerializableDataType<BlockAction> DATA_TYPE = SerializableDataType.lazy(() -> ApoliDataTypes.actions("type", BlockActionTypes.DATA_TYPE, AndBlockActionType::new, BlockAction::new));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import io.github.dueris.originspaper.util.context.TypeActionContext;
import net.minecraft.world.entity.Entity;

public record BiEntityActionContext(Entity actor, Entity target) implements TypeActionContext<BiEntityConditionContext> {
public record BiEntityActionContext(Entity actor,
Entity target) implements TypeActionContext<BiEntityConditionContext> {

@Override
public BiEntityConditionContext forCondition() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import java.util.Optional;

public record BlockActionContext(Level world, BlockPos pos, Optional<Direction> direction) implements TypeActionContext<BlockConditionContext> {
public record BlockActionContext(Level world, BlockPos pos,
Optional<Direction> direction) implements TypeActionContext<BlockConditionContext> {

@Override
public BlockConditionContext forCondition() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import net.minecraft.world.entity.SlotAccess;
import net.minecraft.world.level.Level;

public record ItemActionContext(Level world, SlotAccess stackReference) implements TypeActionContext<ItemConditionContext> {
public record ItemActionContext(Level world,
SlotAccess stackReference) implements TypeActionContext<ItemConditionContext> {

@Override
public ItemConditionContext forCondition() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public final void init(A action) {
@Override
public void validate() throws Exception {

TypedDataObjectFactory<AbstractActionType<T, A>> dataFactory = (TypedDataObjectFactory<AbstractActionType<T,A>>) getConfig().dataFactory();
TypedDataObjectFactory<AbstractActionType<T, A>> dataFactory = (TypedDataObjectFactory<AbstractActionType<T, A>>) getConfig().dataFactory();
SerializableData.Instance data = dataFactory.toData(this);

data.validate();
Expand All @@ -50,9 +50,7 @@ public final A getAction() {

if (initialized) {
return Objects.requireNonNull(action, "Action of initialized action type \"" + getConfig().id() + "\" was null!");
}

else {
} else {
throw new IllegalStateException("Action type \"" + getConfig().id() + "\" wasn't initialized yet!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,43 @@

public class BiEntityActionTypes {

public static final IdentifierAlias ALIASES = new IdentifierAlias();
public static final SerializableDataType<ActionConfiguration<BiEntityActionType>> DATA_TYPE = SerializableDataType.registry(ApoliRegistries.BIENTITY_ACTION_TYPE, "apoli", ALIASES, (configurations, id) -> "Bi-entity action type \"" + id + "\" is undefined!");

public static final ActionConfiguration<AndBiEntityActionType> AND = register(AndMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, AndBiEntityActionType::new));
public static final ActionConfiguration<ChanceBiEntityActionType> CHANCE = register(ChanceMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, ChanceBiEntityActionType::new));
public static final ActionConfiguration<ChoiceBiEntityActionType> CHOICE = register(ChoiceMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, ChoiceBiEntityActionType::new));
public static final ActionConfiguration<DelayBiEntityActionType> DELAY = register(DelayMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, DelayBiEntityActionType::new));
public static final ActionConfiguration<IfElseListBiEntityActionType> IF_ELSE_LIST = register(IfElseListMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, BiEntityCondition.DATA_TYPE, IfElseListBiEntityActionType::new));
public static final ActionConfiguration<IfElseBiEntityActionType> IF_ELSE = register(IfElseMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, BiEntityCondition.DATA_TYPE, IfElseBiEntityActionType::new));
public static final ActionConfiguration<NothingBiEntityActionType> NOTHING = register(NothingMetaActionType.createConfiguration(NothingBiEntityActionType::new));
public static final ActionConfiguration<SideBiEntityActionType> SIDE = register(SideMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, SideBiEntityActionType::new));

public static final ActionConfiguration<ActorActionBiEntityActionType> ACTOR_ACTION = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("actor_action"), ActorActionBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<InvertBiEntityActionType> INVERT = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("invert"), InvertBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<TargetActionBiEntityActionType> TARGET_ACTION = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("target_action"), TargetActionBiEntityActionType.DATA_FACTORY));

public static final ActionConfiguration<AddToEntitySetBiEntityActionType> ADD_TO_ENTITY_SET = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("add_to_entity_set"), AddToEntitySetBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<AddVelocityBiEntityActionType> ADD_VELOCITY = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("add_velocity"), AddVelocityBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<DamageBiEntityActionType> DAMAGE = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("damage"), DamageBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<LeashBiEntityActionType> LEASH = register(ActionConfiguration.simple(OriginsPaper.apoliIdentifier("leash"), LeashBiEntityActionType::new));
public static final ActionConfiguration<MountBiEntityActionType> MOUNT = register(ActionConfiguration.simple(OriginsPaper.apoliIdentifier("mount"), MountBiEntityActionType::new));
public static final ActionConfiguration<RemoveFromEntitySetBiEntityActionType> REMOVE_FROM_ENTITY_SET = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("remove_from_entity_set"), RemoveFromEntitySetBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<TameBiEntityActionType> TAME = ActionConfiguration.simple(OriginsPaper.apoliIdentifier("tame"), TameBiEntityActionType::new);
public static final ActionConfiguration<SetInLoveBiEntityActionType> SET_IN_LOVE = register(ActionConfiguration.simple(OriginsPaper.apoliIdentifier("set_in_love"), SetInLoveBiEntityActionType::new));

public static void register() {

}

@SuppressWarnings("unchecked")
public static final IdentifierAlias ALIASES = new IdentifierAlias();
public static final SerializableDataType<ActionConfiguration<BiEntityActionType>> DATA_TYPE = SerializableDataType.registry(ApoliRegistries.BIENTITY_ACTION_TYPE, "apoli", ALIASES, (configurations, id) -> "Bi-entity action type \"" + id + "\" is undefined!");

public static final ActionConfiguration<AndBiEntityActionType> AND = register(AndMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, AndBiEntityActionType::new));
public static final ActionConfiguration<ChanceBiEntityActionType> CHANCE = register(ChanceMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, ChanceBiEntityActionType::new));
public static final ActionConfiguration<ChoiceBiEntityActionType> CHOICE = register(ChoiceMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, ChoiceBiEntityActionType::new));
public static final ActionConfiguration<DelayBiEntityActionType> DELAY = register(DelayMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, DelayBiEntityActionType::new));
public static final ActionConfiguration<IfElseListBiEntityActionType> IF_ELSE_LIST = register(IfElseListMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, BiEntityCondition.DATA_TYPE, IfElseListBiEntityActionType::new));
public static final ActionConfiguration<IfElseBiEntityActionType> IF_ELSE = register(IfElseMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, BiEntityCondition.DATA_TYPE, IfElseBiEntityActionType::new));
public static final ActionConfiguration<NothingBiEntityActionType> NOTHING = register(NothingMetaActionType.createConfiguration(NothingBiEntityActionType::new));
public static final ActionConfiguration<SideBiEntityActionType> SIDE = register(SideMetaActionType.createConfiguration(BiEntityAction.DATA_TYPE, SideBiEntityActionType::new));

public static final ActionConfiguration<ActorActionBiEntityActionType> ACTOR_ACTION = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("actor_action"), ActorActionBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<InvertBiEntityActionType> INVERT = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("invert"), InvertBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<TargetActionBiEntityActionType> TARGET_ACTION = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("target_action"), TargetActionBiEntityActionType.DATA_FACTORY));

public static final ActionConfiguration<AddToEntitySetBiEntityActionType> ADD_TO_ENTITY_SET = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("add_to_entity_set"), AddToEntitySetBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<AddVelocityBiEntityActionType> ADD_VELOCITY = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("add_velocity"), AddVelocityBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<DamageBiEntityActionType> DAMAGE = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("damage"), DamageBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<LeashBiEntityActionType> LEASH = register(ActionConfiguration.simple(OriginsPaper.apoliIdentifier("leash"), LeashBiEntityActionType::new));
public static final ActionConfiguration<MountBiEntityActionType> MOUNT = register(ActionConfiguration.simple(OriginsPaper.apoliIdentifier("mount"), MountBiEntityActionType::new));
public static final ActionConfiguration<RemoveFromEntitySetBiEntityActionType> REMOVE_FROM_ENTITY_SET = register(ActionConfiguration.of(OriginsPaper.apoliIdentifier("remove_from_entity_set"), RemoveFromEntitySetBiEntityActionType.DATA_FACTORY));
public static final ActionConfiguration<TameBiEntityActionType> TAME = ActionConfiguration.simple(OriginsPaper.apoliIdentifier("tame"), TameBiEntityActionType::new);
public static final ActionConfiguration<SetInLoveBiEntityActionType> SET_IN_LOVE = register(ActionConfiguration.simple(OriginsPaper.apoliIdentifier("set_in_love"), SetInLoveBiEntityActionType::new));

public static void register() {

}

@SuppressWarnings("unchecked")
public static <T extends BiEntityActionType> ActionConfiguration<T> register(ActionConfiguration<T> configuration) {

ActionConfiguration<BiEntityActionType> casted = (ActionConfiguration<BiEntityActionType>) configuration;
Registry.register(ApoliRegistries.BIENTITY_ACTION_TYPE, casted.id(), casted);
ActionConfiguration<BiEntityActionType> casted = (ActionConfiguration<BiEntityActionType>) configuration;
Registry.register(ApoliRegistries.BIENTITY_ACTION_TYPE, casted.id(), casted);

return configuration;
return configuration;

}
}

}
Loading

0 comments on commit 8e962c7

Please sign in to comment.