Skip to content

Commit

Permalink
i give up on trying to make this recipe thing
Browse files Browse the repository at this point in the history
also i changed data.BangbooData to data.entity.BangbooEntityData as it only includes entity data
  • Loading branch information
vanillyn committed Aug 26, 2024
1 parent e4ff45c commit 3944635
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 101 deletions.
33 changes: 1 addition & 32 deletions src/main/java/world/vanillyn/data/BangbooData.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
package world.vanillyn.data;

import net.minecraft.component.ComponentType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import org.ladysnake.cca.api.v3.component.ComponentKey;
import org.ladysnake.cca.api.v3.component.ComponentRegistry;
import org.ladysnake.cca.api.v3.entity.EntityComponentFactoryRegistry;
import org.ladysnake.cca.api.v3.entity.EntityComponentInitializer;
import org.ladysnake.cca.api.v3.entity.RespawnCopyStrategy;
import world.vanillyn.BangbooMod;
import world.vanillyn.data.entity.Bangboo.BangbooComponents;
import world.vanillyn.data.player.Dennies;

import java.util.function.UnaryOperator;

public class BangbooData implements EntityComponentInitializer {

public static final ComponentKey<Dennies> DENNIES =
ComponentRegistry.getOrCreate(BangbooMod.id("dennies"), Dennies.class);

public static final ComponentType<BangbooComponents> ENTITY_STORAGE =
register("entity_storage", builder -> builder
.codec(BangbooComponents.CODEC)
.cache());

private static <T> ComponentType<T> register(String id, UnaryOperator<ComponentType.Builder<T>> builderOperator) {
return Registry.register(Registries.DATA_COMPONENT_TYPE, BangbooMod.id(id), (builderOperator.apply(ComponentType.builder())).build());
}

@Override
public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
registry.registerForPlayers(DENNIES, Dennies::new, RespawnCopyStrategy.LOSSLESS_ONLY);
}
public class BangbooData {
}
35 changes: 35 additions & 0 deletions src/main/java/world/vanillyn/data/entity/BangbooEntityData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package world.vanillyn.data.entity;

import net.minecraft.component.ComponentType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import org.ladysnake.cca.api.v3.component.ComponentKey;
import org.ladysnake.cca.api.v3.component.ComponentRegistry;
import org.ladysnake.cca.api.v3.entity.EntityComponentFactoryRegistry;
import org.ladysnake.cca.api.v3.entity.EntityComponentInitializer;
import org.ladysnake.cca.api.v3.entity.RespawnCopyStrategy;
import world.vanillyn.BangbooMod;
import world.vanillyn.data.entity.Bangboo.BangbooComponents;
import world.vanillyn.data.player.Dennies;

import java.util.function.UnaryOperator;

public class BangbooEntityData implements EntityComponentInitializer {

public static final ComponentKey<Dennies> DENNIES =
ComponentRegistry.getOrCreate(BangbooMod.id("dennies"), Dennies.class);

public static final ComponentType<BangbooComponents> ENTITY_STORAGE =
register("entity_storage", builder -> builder
.codec(BangbooComponents.CODEC)
.cache());

private static <T> ComponentType<T> register(String id, UnaryOperator<ComponentType.Builder<T>> builderOperator) {
return Registry.register(Registries.DATA_COMPONENT_TYPE, BangbooMod.id(id), (builderOperator.apply(ComponentType.builder())).build());
}

@Override
public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
registry.registerForPlayers(DENNIES, Dennies::new, RespawnCopyStrategy.LOSSLESS_ONLY);
}
}

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/world/vanillyn/data/player/Reward.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import world.vanillyn.data.BangbooData;
import world.vanillyn.data.entity.BangbooEntityData;

import java.util.Random;

Expand All @@ -24,7 +24,7 @@ public Reward(PlayerEntity user, boolean isCrtReward, boolean shouldRewardDennie
Random rewardDennies = new Random();
if (shouldRewardDennies) {
int count = rewardDennies.nextInt(maxDennies - minDennies) + minDennies;
BangbooData.DENNIES.get(user).add(count);
BangbooEntityData.DENNIES.get(user).add(count);
}
for (Item item : rewards) {
int count;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"world.vanillyn.BangbooClient"
],
"cardinal-components": [
"world.vanillyn.data.BangbooData"
"world.vanillyn.data.entity.BangbooEntityData"
]
},
"custom": {
Expand Down

0 comments on commit 3944635

Please sign in to comment.