Skip to content

Commit

Permalink
sort tags into separate classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckscor3 committed Feb 21, 2023
1 parent 05a4edf commit da9829b
Show file tree
Hide file tree
Showing 37 changed files with 116 additions and 104 deletions.
49 changes: 30 additions & 19 deletions src/main/java/me/juancarloscp52/entropy/EntropyTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,34 @@
import net.minecraft.util.Identifier;

public class EntropyTags {
public static final TagKey<EntityType<?>> IGNORED_BY_FORCEFIELD_AND_ENTITY_MAGNET = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "ignored_by_forcefield_and_entity_magnet"));
public static final TagKey<EntityType<?>> DO_NOT_LEVITATE = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_levitate"));
public static final TagKey<EntityType<?>> NOT_INVISIBLE = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "not_invisible"));
public static final TagKey<EntityType<?>> DO_NOT_IGNITE = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_ignite"));
public static final TagKey<EntityType<?>> DO_NOT_HIGHLIGHT = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_highlight"));
public static final TagKey<EntityType<?>> DO_NOT_FLING = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_fling"));
public static final TagKey<EntityType<?>> DO_NOT_EXPLODE = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_explode"));
public static final TagKey<EntityType<?>> DO_NOT_DAMAGE = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_damage"));
public static final TagKey<Block> NOT_REPLACED_BY_EVENTS = TagKey.of(Registries.BLOCK.getKey(), new Identifier("entropy", "not_replaced_by_events"));
public static final TagKey<Block> IGNORED_BY_MIDAS_TOUCH = TagKey.of(Registries.BLOCK.getKey(), new Identifier("entropy", "ignored_by_midas_touch"));
public static final TagKey<Block> VOID_SIGHT_BREAKS = TagKey.of(Registries.BLOCK.getKey(), new Identifier("entropy", "void_sight_breaks"));
public static final TagKey<Block> SHOWN_DURING_XRAY = TagKey.of(Registries.BLOCK.getKey(), new Identifier("entropy", "shown_during_xray"));
public static final TagKey<Enchantment> DO_NOT_ENCHANT_WITH = TagKey.of(Registries.ENCHANTMENT.getKey(), new Identifier("entropy", "do_not_enchant_with"));
public static final TagKey<Enchantment> DO_NOT_REMOVE = TagKey.of(Registries.ENCHANTMENT.getKey(), new Identifier("entropy", "do_not_remove"));
public static final TagKey<Item> DOES_NOT_DROP_RANDOMLY = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "does_not_drop_randomly"));
public static final TagKey<Item> DOES_NOT_RAIN = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "does_not_rain"));
public static final TagKey<Item> BANNED = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "banned"));
public static final TagKey<Item> UNFIXABLE = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "unfixable"));
public static final TagKey<Item> DO_NOT_CURSE = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "do_not_curse"));
public static class BlockTags {
public static final TagKey<Block> IGNORED_BY_MIDAS_TOUCH = TagKey.of(Registries.BLOCK.getKey(), new Identifier("entropy", "ignored_by_midas_touch"));
public static final TagKey<Block> NOT_REPLACED_BY_EVENTS = TagKey.of(Registries.BLOCK.getKey(), new Identifier("entropy", "not_replaced_by_events"));
public static final TagKey<Block> SHOWN_DURING_XRAY = TagKey.of(Registries.BLOCK.getKey(), new Identifier("entropy", "shown_during_xray"));
public static final TagKey<Block> VOID_SIGHT_BREAKS = TagKey.of(Registries.BLOCK.getKey(), new Identifier("entropy", "void_sight_breaks"));
}

public static class EnchantmentTags {
public static final TagKey<Enchantment> DO_NOT_ENCHANT_WITH = TagKey.of(Registries.ENCHANTMENT.getKey(), new Identifier("entropy", "do_not_enchant_with"));
public static final TagKey<Enchantment> DO_NOT_REMOVE = TagKey.of(Registries.ENCHANTMENT.getKey(), new Identifier("entropy", "do_not_remove"));
}

public static class EntityTypeTags {
public static final TagKey<EntityType<?>> DO_NOT_DAMAGE = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_damage"));
public static final TagKey<EntityType<?>> DO_NOT_EXPLODE = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_explode"));
public static final TagKey<EntityType<?>> DO_NOT_FLING = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_fling"));
public static final TagKey<EntityType<?>> DO_NOT_HIGHLIGHT = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_highlight"));
public static final TagKey<EntityType<?>> DO_NOT_IGNITE = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_ignite"));
public static final TagKey<EntityType<?>> DO_NOT_LEVITATE = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "do_not_levitate"));
public static final TagKey<EntityType<?>> IGNORED_BY_FORCEFIELD_AND_ENTITY_MAGNET = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "ignored_by_forcefield_and_entity_magnet"));
public static final TagKey<EntityType<?>> NOT_INVISIBLE = TagKey.of(Registries.ENTITY_TYPE.getKey(), new Identifier("entropy", "not_invisible"));
}

public static class ItemTags {
public static final TagKey<Item> BANNED = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "banned"));
public static final TagKey<Item> DOES_NOT_DROP_RANDOMLY = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "does_not_drop_randomly"));
public static final TagKey<Item> DOES_NOT_RAIN = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "does_not_rain"));
public static final TagKey<Item> DO_NOT_CURSE = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "do_not_curse"));
public static final TagKey<Item> UNFIXABLE = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "unfixable"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.concurrent.CompletableFuture;

import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.BlockTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider.BlockTagProvider;
import net.minecraft.block.Blocks;
Expand All @@ -15,19 +15,19 @@ public EntropyBlockTagProvider(FabricDataOutput output, CompletableFuture<Wrappe

@Override
protected void configure(WrapperLookup wrapperLookup) {
getOrCreateTagBuilder(EntropyTags.NOT_REPLACED_BY_EVENTS).add(Blocks.BEDROCK, Blocks.END_PORTAL, Blocks.END_PORTAL_FRAME);
getOrCreateTagBuilder(EntropyTags.IGNORED_BY_MIDAS_TOUCH).addTag(EntropyTags.NOT_REPLACED_BY_EVENTS).add(Blocks.AIR,
getOrCreateTagBuilder(BlockTags.NOT_REPLACED_BY_EVENTS).add(Blocks.BEDROCK, Blocks.END_PORTAL, Blocks.END_PORTAL_FRAME);
getOrCreateTagBuilder(BlockTags.IGNORED_BY_MIDAS_TOUCH).addTag(BlockTags.NOT_REPLACED_BY_EVENTS).add(Blocks.AIR,
Blocks.GOLD_BLOCK,
Blocks.GOLD_ORE,
Blocks.RAW_GOLD_BLOCK,
Blocks.NETHER_GOLD_ORE);
getOrCreateTagBuilder(EntropyTags.VOID_SIGHT_BREAKS).add(Blocks.CHEST,
getOrCreateTagBuilder(BlockTags.VOID_SIGHT_BREAKS).add(Blocks.CHEST,
Blocks.TRAPPED_CHEST,
Blocks.BARREL,
Blocks.FURNACE,
Blocks.BLAST_FURNACE,
Blocks.SMOKER);
getOrCreateTagBuilder(EntropyTags.SHOWN_DURING_XRAY).add(Blocks.COAL_ORE,
getOrCreateTagBuilder(BlockTags.SHOWN_DURING_XRAY).add(Blocks.COAL_ORE,
Blocks.COAL_BLOCK,
Blocks.DEEPSLATE_COAL_ORE,
Blocks.IRON_ORE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.concurrent.CompletableFuture;

import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.EnchantmentTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider.EnchantmentTagProvider;
import net.minecraft.enchantment.Enchantments;
Expand All @@ -15,6 +15,6 @@ public EntropyEnchantmentTagProvider(FabricDataOutput output, CompletableFuture<

@Override
protected void configure(WrapperLookup wrapperLookup) {
getOrCreateTagBuilder(EntropyTags.DO_NOT_ENCHANT_WITH).add(Enchantments.BINDING_CURSE, Enchantments.VANISHING_CURSE);
getOrCreateTagBuilder(EnchantmentTags.DO_NOT_ENCHANT_WITH).add(Enchantments.BINDING_CURSE, Enchantments.VANISHING_CURSE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.concurrent.CompletableFuture;

import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.EntityTypeTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider.EntityTypeTagProvider;
import net.minecraft.entity.EntityType;
Expand All @@ -15,7 +15,7 @@ public EntropyEntityTypeTagProvider(FabricDataOutput output, CompletableFuture<W

@Override
protected void configure(WrapperLookup wrapperLookup) {
getOrCreateTagBuilder(EntropyTags.IGNORED_BY_FORCEFIELD_AND_ENTITY_MAGNET).add(EntityType.AREA_EFFECT_CLOUD,
getOrCreateTagBuilder(EntityTypeTags.IGNORED_BY_FORCEFIELD_AND_ENTITY_MAGNET).add(EntityType.AREA_EFFECT_CLOUD,
EntityType.END_CRYSTAL,
EntityType.GLOW_ITEM_FRAME,
EntityType.ITEM_FRAME,
Expand All @@ -24,7 +24,7 @@ protected void configure(WrapperLookup wrapperLookup) {
EntityType.MARKER,
EntityType.PAINTING,
EntityType.PLAYER);
getOrCreateTagBuilder(EntropyTags.DO_NOT_IGNITE).add(EntityType.PLAYER);
getOrCreateTagBuilder(EntropyTags.DO_NOT_EXPLODE).add(EntityType.ENDER_DRAGON, EntityType.PLAYER);
getOrCreateTagBuilder(EntityTypeTags.DO_NOT_IGNITE).add(EntityType.PLAYER);
getOrCreateTagBuilder(EntityTypeTags.DO_NOT_EXPLODE).add(EntityType.ENDER_DRAGON, EntityType.PLAYER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.concurrent.CompletableFuture;

import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.ItemTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider.ItemTagProvider;
import net.minecraft.item.Item;
Expand All @@ -21,15 +21,15 @@ public EntropyItemTagProvider(FabricDataOutput output, CompletableFuture<Wrapper
protected void configure(WrapperLookup wrapperLookup) {
TagKey<Item> spawnEggsTag = TagKey.of(Registries.ITEM.getKey(), new Identifier("c", "spawn_eggs"));

getOrCreateTagBuilder(EntropyTags.BANNED).addTag(spawnEggsTag).add(Items.DEBUG_STICK,
getOrCreateTagBuilder(ItemTags.BANNED).addTag(spawnEggsTag).add(Items.DEBUG_STICK,
Items.COMMAND_BLOCK,
Items.CHAIN_COMMAND_BLOCK,
Items.REPEATING_COMMAND_BLOCK,
Items.BARRIER,
Items.STRUCTURE_BLOCK,
Items.STRUCTURE_VOID);
getOrCreateTagBuilder(EntropyTags.DOES_NOT_DROP_RANDOMLY).addTag(EntropyTags.BANNED);
getOrCreateTagBuilder(EntropyTags.DOES_NOT_RAIN).addTag(EntropyTags.BANNED);
getOrCreateTagBuilder(ItemTags.DOES_NOT_DROP_RANDOMLY).addTag(ItemTags.BANNED);
getOrCreateTagBuilder(ItemTags.DOES_NOT_RAIN).addTag(ItemTags.BANNED);
getOrCreateTagBuilder(spawnEggsTag).add(Items.ALLAY_SPAWN_EGG,
Items.AXOLOTL_SPAWN_EGG,
Items.BAT_SPAWN_EGG,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.juancarloscp52.entropy.events.db;

import me.juancarloscp52.entropy.Entropy;
import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.BlockTags;
import me.juancarloscp52.entropy.events.AbstractTimedEvent;
import net.minecraft.client.util.math.MatrixStack;

Expand All @@ -17,7 +17,7 @@ public void tick() {
for (int iz = -1; iz <= 1; iz++) {
var blockPos = playerBlockPos.add(ix, iy, iz);
var state = world.getBlockState(blockPos);
if (state.isIn(EntropyTags.NOT_REPLACED_BY_EVENTS))
if (state.isIn(BlockTags.NOT_REPLACED_BY_EVENTS))
continue;
world.breakBlock(blockPos, true);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.juancarloscp52.entropy.events.db;

import me.juancarloscp52.entropy.Entropy;
import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.ItemTags;
import me.juancarloscp52.entropy.events.AbstractInstantEvent;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
Expand Down Expand Up @@ -33,7 +33,7 @@ public void init() {
Collections.shuffle(_curses);

for (var itemStack : inventory) {
if(itemStack.isIn(EntropyTags.DO_NOT_CURSE))
if(itemStack.isIn(ItemTags.DO_NOT_CURSE))
continue;

for (var curse : _curses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package me.juancarloscp52.entropy.events.db;

import me.juancarloscp52.entropy.Entropy;
import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.EntityTypeTags;
import me.juancarloscp52.entropy.events.AbstractTimedEvent;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
Expand All @@ -29,7 +29,7 @@ public void tick() {
var difficulty = serverPlayerEntity.getWorld().getDifficulty();
var dmg = difficulty == Difficulty.HARD ? 3 : difficulty == Difficulty.NORMAL ? 5 : 7;
var entity = hitRes.getEntity();
if (entity instanceof LivingEntity && !entity.getType().isIn(EntropyTags.DO_NOT_DAMAGE))
if (entity instanceof LivingEntity && !entity.getType().isIn(EntityTypeTags.DO_NOT_DAMAGE))
entity.damage(DamageSource.player(serverPlayerEntity), dmg);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.juancarloscp52.entropy.events.db;

import me.juancarloscp52.entropy.Entropy;
import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.EnchantmentTags;
import me.juancarloscp52.entropy.events.AbstractInstantEvent;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
Expand Down Expand Up @@ -34,7 +34,7 @@ public void init() {

for (var itemStack : inventory) {
for (var enchantment : _enchantments) {
if (Registries.ENCHANTMENT.getEntry(enchantment).isIn(EntropyTags.DO_NOT_ENCHANT_WITH))
if (Registries.ENCHANTMENT.getEntry(enchantment).isIn(EnchantmentTags.DO_NOT_ENCHANT_WITH))
continue;

if (enchantment.isAcceptableItem(itemStack)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package me.juancarloscp52.entropy.events.db;

import me.juancarloscp52.entropy.Entropy;
import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.EntityTypeTags;
import me.juancarloscp52.entropy.events.AbstractInstantEvent;
import net.minecraft.util.math.Box;
import net.minecraft.world.World;
Expand All @@ -29,7 +29,7 @@ public class ExplodeNearbyEntitiesEvent extends AbstractInstantEvent {
public void init() {
Entropy.getInstance().eventHandler.getActivePlayers().forEach(serverPlayerEntity -> serverPlayerEntity.getEntityWorld().getOtherEntities(serverPlayerEntity, new Box(serverPlayerEntity.getBlockPos().add(70, 70, 70), serverPlayerEntity.getBlockPos().add(-70, -70, -70))).forEach(entity -> {
entity.getEntityWorld().createExplosion(entity, entity.getX(), entity.getY() + 1f, entity.getZ(), 2.1f, World.ExplosionSourceType.MOB);
if(!entity.getType().isIn(EntropyTags.DO_NOT_EXPLODE))
if(!entity.getType().isIn(EntityTypeTags.DO_NOT_EXPLODE))
entity.kill();
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package me.juancarloscp52.entropy.events.db;

import me.juancarloscp52.entropy.Entropy;
import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.ItemTags;
import me.juancarloscp52.entropy.events.AbstractInstantEvent;
import net.minecraft.advancement.criterion.Criteria;
import net.minecraft.item.ItemStack;
Expand All @@ -28,7 +28,7 @@ public class FixItemsEvent extends AbstractInstantEvent {


public void fixItem(ItemStack stack, ServerPlayerEntity player){
if(stack.isIn(EntropyTags.UNFIXABLE))
if(stack.isIn(ItemTags.UNFIXABLE))
return;

Criteria.ITEM_DURABILITY_CHANGED.trigger(player, stack, stack.getMaxDamage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;

import me.juancarloscp52.entropy.Entropy;
import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.EntityTypeTags;
import me.juancarloscp52.entropy.events.AbstractInstantEvent;
import me.juancarloscp52.entropy.server.ServerEventHandler;
import net.fabricmc.api.EnvType;
Expand Down Expand Up @@ -36,7 +36,7 @@ public void init() {
});
worlds.forEach(world -> {
world.iterateEntities().forEach(entity -> {
if(entity instanceof LivingEntity livingEntity && !livingEntity.getType().isIn(EntropyTags.DO_NOT_FLING)) {
if(entity instanceof LivingEntity livingEntity && !livingEntity.getType().isIn(EntityTypeTags.DO_NOT_FLING)) {
fling(livingEntity);
livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOW_FALLING, 140));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.function.Predicate;

import me.juancarloscp52.entropy.Entropy;
import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.EntityTypeTags;
import me.juancarloscp52.entropy.events.AbstractTimedEvent;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
Expand All @@ -13,7 +13,7 @@
import net.minecraft.util.math.Vec3d;

public class ForcefieldEvent extends AbstractTimedEvent {
private static final Predicate<Entity> ALLOWED_ENTITY = EntityPredicates.VALID_ENTITY.and(entity -> !entity.getType().isIn(EntropyTags.IGNORED_BY_FORCEFIELD_AND_ENTITY_MAGNET));
private static final Predicate<Entity> ALLOWED_ENTITY = EntityPredicates.VALID_ENTITY.and(entity -> !entity.getType().isIn(EntityTypeTags.IGNORED_BY_FORCEFIELD_AND_ENTITY_MAGNET));

@Override
public void tick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package me.juancarloscp52.entropy.events.db;

import me.juancarloscp52.entropy.Entropy;
import me.juancarloscp52.entropy.EntropyTags;
import me.juancarloscp52.entropy.EntropyTags.BlockTags;
import me.juancarloscp52.entropy.events.AbstractTimedEvent;
import net.minecraft.block.Blocks;
import net.minecraft.client.util.math.MatrixStack;
Expand All @@ -21,7 +21,7 @@ public void tick() {
var hitRes = serverPlayerEntity.raycast(64, 1, true);
if (hitRes.getType() == Type.BLOCK) {
var blockHitRes = (BlockHitResult) hitRes;
if(!serverPlayerEntity.getWorld().getBlockState(blockHitRes.getBlockPos()).isIn(EntropyTags.NOT_REPLACED_BY_EVENTS)){
if(!serverPlayerEntity.getWorld().getBlockState(blockHitRes.getBlockPos()).isIn(BlockTags.NOT_REPLACED_BY_EVENTS)){
serverPlayerEntity.getWorld().setBlockState(blockHitRes.getBlockPos(), Blocks.GLASS.getDefaultState());
}
}
Expand Down
Loading

0 comments on commit da9829b

Please sign in to comment.