Refactor and rename to Thresholds

This commit is contained in:
zontreck 2024-01-15 22:23:44 -07:00
parent 32a61e7925
commit cd9d548806
568 changed files with 214858 additions and 215029 deletions

View file

@ -1,11 +0,0 @@
package dev.zontreck.otemod.items;
import net.minecraft.world.item.Item;
public class IhanCrystal extends Item{
public IhanCrystal(Properties p_41383_) {
super(p_41383_);
}
}

View file

@ -1,79 +0,0 @@
package dev.zontreck.otemod.items;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.blocks.FoiledBlockItem;
import dev.zontreck.otemod.entities.ModEntityTypes;
import dev.zontreck.otemod.implementation.CreativeModeTabs;
import net.minecraft.world.item.*;
import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModItems {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, OTEMod.MOD_ID);
public static final RegistryObject<Item> ETERNIUM_FRAGMENT = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_fragment", () -> new Item(new Item.Properties())));
public static final RegistryObject<Item> IHAN_CRYSTAL = CreativeModeTabs.addToOTEModTab(ITEMS.register("ihan_crystal", () -> new Item(new Item.Properties())));
public static final RegistryObject<Item> AURORA_COMPOUND = CreativeModeTabs.addToOTEModTab(ITEMS.register("aurora_compound", () -> new Item(new Item.Properties())));
public static final RegistryObject<Item> ETERNIUM_RAW_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_ore", () -> new Item(new Item.Properties())));
public static final RegistryObject<Item> ETERNIUM_INGOT = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_ingot", ()-> new SimpleFoiledItem(new Item.Properties())));
public static final RegistryObject<Item> MELTED_ENDER_PEARL = CreativeModeTabs.addToOTEModTab(ITEMS.register("melted_ender_pearl", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> SINGULARITY = CreativeModeTabs.addToOTEModTab(ITEMS.register("singularity", () -> new UnstableSingularity(new Item.Properties().stacksTo(1))));
public static final RegistryObject<Item> COMPRESSED_OBSIDIAN_SHEET = CreativeModeTabs.addToOTEModTab(ITEMS.register("compressed_obsidian_sheet", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> LAYERED_COMPRESSED_OBSIDIAN_SHEET = CreativeModeTabs.addToOTEModTab(ITEMS.register("layered_compressed_obsidian_sheet", ()->new SimpleFoiledItem(new Item.Properties())));
public static final RegistryObject<Item> ENCASED_SINGULARITY = CreativeModeTabs.addToOTEModTab(ITEMS.register("encased_singularity", ()->new SimpleFoiledItem(new Item.Properties())));
public static final RegistryObject<Item> ETERNIUM_ROD = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_rod", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> SCRUBBER_FRAME_PIECE = CreativeModeTabs.addToOTEModTab(ITEMS.register("scrubber_frame_piece", () -> new Item(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> SCRUBBER_FRAME = CreativeModeTabs.addToOTEModTab(ITEMS.register("scrubber_frame", () -> new Item(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULTSTEEL_INGOT = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_steel_ingot", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT_FRAG_BL = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_lower_left", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT_FRAG_LC = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_lower", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT_FRAG_BR = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_lower_right", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT_FRAG_L = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_left", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT_FRAG_R = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_right", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT_FRAG_UR = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_upper_right", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT_FRAG_UL = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_upper_left", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT_FRAG_U = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_upper", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT_FRAG_C = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_center", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault", () -> new VaultItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> VAULT_RAW_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("raw_vault_steel_ore", () -> new Item(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> POSS_BALL = CreativeModeTabs.addToOTEModTab(ITEMS.register("poss_ball", () -> new PossBallItem(new Item.Properties())));
public static final RegistryObject<Item> ILUSIUM_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_ore", () -> new Item(new Item.Properties().fireResistant())));
public static final RegistryObject<Item> ILUSIUM_ROD = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_rod", () -> new Item(new Item.Properties().fireResistant())));
//public static final RegistryObject<Item> ILUSIUM_DUST = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_dust", () -> new Item(new Item.Properties().fireResistant())));
public static final RegistryObject<Item> ILUSIUM_INGOT = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_ingot", () -> new Item(new Item.Properties().fireResistant())));
public static final RegistryObject<Item> EMPTY_SPAWN_EGG = CreativeModeTabs.addToOTEModTab(ITEMS.register("empty_spawn_egg", () -> new Item(new Item.Properties())));
//public static final RegistryObject<Item> POSSUM_SPAWN_EGG = ITEMS.register("possum_spawn_egg", () -> new ForgeSpawnEggItem(ModEntityTypes.POSSUM, 0x938686, 0xc68787, new Item.Properties())));
public static void register(IEventBus bus){
ITEMS.register(bus);
}
}

View file

@ -1,67 +0,0 @@
package dev.zontreck.otemod.items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.stats.Stats;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.monster.Guardian;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.Arrow;
import net.minecraft.world.item.EggItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
public class PossBallItem extends Item
{
public PossBallItem(Properties pProperties) {
super(pProperties);
}
@Override
public boolean isFoil(ItemStack pStack) {
if(!pStack.hasTag())
{
pStack.setTag(new CompoundTag());
}
if(pStack.getTag().contains("entity"))
{
return true;
} else return false;
}
@Override
public boolean isDamageable(ItemStack stack) {
return true;
}
@Override
public int getMaxDamage(ItemStack stack) {
return 2;
}
@Override
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) {
ItemStack stack = pPlayer.getItemInHand(pUsedHand);
pLevel.playSound((Player) null, pPlayer.getX(), pPlayer.getY(), pPlayer.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (pLevel.random.nextFloat() * 0.4f + 0.8f));
if(!pLevel.isClientSide)
{
ThrownPossBall TPB = new ThrownPossBall(pLevel, pPlayer);
if(pPlayer.getAbilities().instabuild) TPB.setItem(stack.copy());
else
TPB.setItem(stack);
TPB.shootFromRotation(pPlayer, pPlayer.getXRot(), pPlayer.getYRot(), 0.0F, 1.5F, 1.0F);
pLevel.addFreshEntity(TPB);
}
pPlayer.awardStat(Stats.ITEM_USED.get(this));
if(!pPlayer.getAbilities().instabuild)
{
stack.shrink(1);
}else {
}
return super.use(pLevel, pPlayer, pUsedHand);
}
}

View file

@ -1,183 +0,0 @@
package dev.zontreck.otemod.items;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.lore.ExtraLore;
import dev.zontreck.libzontreck.lore.LoreContainer;
import dev.zontreck.libzontreck.lore.LoreEntry;
import dev.zontreck.libzontreck.util.ChatHelpers;
import net.minecraft.core.particles.ItemParticleOption;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.DropperBlock;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
import java.util.Optional;
import java.util.UUID;
public class ThrownPossBall extends ThrowableItemProjectile
{
boolean captured = false;
LivingEntity shooter;
public ThrownPossBall(EntityType<? extends ThrownPossBall> entity, Level level)
{
super(entity, level);
}
public ThrownPossBall(Level level, LivingEntity shooter)
{
super(EntityType.SNOWBALL, shooter, level);
this.shooter = shooter;
}
public ThrownPossBall(Level pLevel, double pX, double pY, double pZ)
{
super(EntityType.SNOWBALL, pX, pY, pZ, pLevel);
}
@Override
protected Item getDefaultItem()
{
return ModItems.POSS_BALL.get();
}
@Override
public void handleEntityEvent(byte pId) {
if(pId == 3)
{
double size = 0.08;
for (int i = 0; i < 8; ++i)
{
this.level().addParticle(new ItemParticleOption(ParticleTypes.ITEM, this.getItem()), this.getX(), this.getY(), this.getZ(), ((double)this.random.nextFloat() - 0.5) * 0.08, ((double)this.random.nextFloat() - 0.5) * 0.08, ((double)this.random.nextFloat() - 0.5) * 0.08);
}
}
}
@Override
protected void onHitEntity(EntityHitResult pResult) {
super.onHitEntity(pResult);
if(getItem().getTag().contains("entity"))
{
// Don't capture the entity
pResult.getEntity().hurt(this.damageSources().thrown(this, this.getOwner()), 0.1F);
} else {
if(pResult.getEntity() instanceof LivingEntity le && !(le instanceof Player))
{
// We don't want to capture players
// Store the entity in the entity tag, then kill the entity
CompoundTag tag = new CompoundTag();
String entityName = le.getName().getString();
le.save(tag);
getItem().getTag().put("entity", tag);
captured=true;
LoreContainer cont = new LoreContainer(getItem());
cont.miscData.loreData.clear();
LoreEntry entry = new LoreEntry.Builder().bold(true).text(ChatColor.doColors("!Dark_Green!Captured Mob: !Dark_Purple!" + entityName)).build();
cont.miscData.loreData.add(entry);
cont.commitLore();
le.remove(RemovalReason.DISCARDED);
}
}
}
@Override
protected void onHit(HitResult pResult) {
super.onHit(pResult);
if(!this.level().isClientSide)
{
// We do two things here
// 1. If we contain an entity, spawn it
// 2. If no entity, and none was captured, decrease the durability a little
// 3. Drop the PossBall with entity, or without
ItemStack item = getItem();
CompoundTag tag = item.getTag();
if(tag.contains("entity"))
{
if(captured)
{
// Spawn poss ball item with the entity NBT
ItemEntity entity;
if(shooter != null)
entity = new ItemEntity(level(), shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
else
entity = new ItemEntity(level(), shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
level().addFreshEntity(entity);
} else {
// Spawn the real entity
Optional<Entity> entity = EntityType.create(tag.getCompound("entity"), level());
if(entity.isPresent())
{
Entity xEntity = entity.get();
xEntity.setUUID(UUID.randomUUID());
xEntity.setPos(position());
level().addFreshEntity(xEntity);
}
LoreContainer cont = new LoreContainer(item);
cont.miscData.loreData.clear();
cont.commitLore();
if(item.getDamageValue() == 0)
{
item.setTag(new CompoundTag());
}else {
tag.remove("entity");
}
ItemEntity x;
if(shooter!=null)
x = new ItemEntity(level(), shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
else
x = new ItemEntity(level(), position().x, position().y, position().z, item, 0, 0, 0);
level().addFreshEntity(x);
}
} else {
// No capture
// Decrease the durability
//int damage = item.getDamageValue();
//damage++;
//item.setDamageValue(damage);
// Ensure no entity tag!
tag.remove("entity");
//if(item.getDamageValue() >= item.getMaxDamage())
// return;
ItemEntity entity;
if(shooter!= null)
entity = new ItemEntity(level(),shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
else
entity = new ItemEntity(level(), position().x, position().y, position().z, item, 0, 0, 0);
level().addFreshEntity(entity);
}
this.level().broadcastEntityEvent(this, (byte)3);
this.discard();
}
}
}

View file

@ -1,38 +0,0 @@
package dev.zontreck.otemod.items;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.SimpleFoiledItem;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
public class UnstableSingularity extends SimpleFoiledItem
{
public UnstableSingularity(Properties pProperties) {
super(pProperties);
}
@Override
public InteractionResult useOn(UseOnContext pContext) {
BlockState block = pContext.getLevel().getBlockState(pContext.getClickedPos());
if(block.getBlock().defaultDestroyTime() < 0)
{
pContext.getLevel().explode(pContext.getPlayer(), pContext.getClickedPos().getX(), pContext.getClickedPos().getY(), pContext.getClickedPos().getZ(), 16, true, Level.ExplosionInteraction.TNT);
pContext.getLevel().setBlock(pContext.getClickedPos(), Blocks.AIR.defaultBlockState(), 0, 0);
pContext.getItemInHand().shrink(1);
}
return InteractionResult.CONSUME;
}
}

View file

@ -1,83 +0,0 @@
package dev.zontreck.otemod.items;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.profiles.Profile;
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.chat.ChatServerOverride;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.otemod.events.LoreHandlers;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.SimpleFoiledItem;
import net.minecraft.world.level.Level;
public class VaultItem extends Item
{
@Override
public boolean isFoil(ItemStack pStack) {
return true;
}
@Override
public Item asItem()
{
return this;
}
public VaultItem(Properties pProperties) {
super(pProperties);
//TODO Auto-generated constructor stub
}
@Override
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand)
{
OTEMod.LOGGER.info("Vault item is being used");
if(!pLevel.isClientSide && pUsedHand == InteractionHand.MAIN_HAND)
{
ItemStack is = pPlayer.getItemInHand(pUsedHand);
Profile p;
try {
p = Profile.get_profile_of(pPlayer.getStringUUID());
if(OTEServerConfig.MAX_VAULTS.get()>0)
{
if(p.available_vaults >= OTEServerConfig.MAX_VAULTS.get())
{
ChatHelpers.broadcastTo(pPlayer.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You cannot activate anymore vaults due to the maximum set by the server admin"), OTEMod.THE_SERVER);
return InteractionResultHolder.pass(is);
} else {
p.available_vaults++;
p.commit();
ChatHelpers.broadcastTo(pPlayer.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!You now have "+String.valueOf(p.available_vaults)+" available vaults"), OTEMod.THE_SERVER);
pPlayer.setItemInHand(pUsedHand, new ItemStack(Items.AIR));
return InteractionResultHolder.consume(is);
}
}else {
p.available_vaults++;
p.commit();
ChatHelpers.broadcastTo(pPlayer.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!You now have "+String.valueOf(p.available_vaults)+" available vaults"), OTEMod.THE_SERVER);
pPlayer.setItemInHand(pUsedHand, new ItemStack(Items.AIR));
return InteractionResultHolder.consume(is);
}
} catch (UserProfileNotYetExistsException e) {
e.printStackTrace();
return super.use(pLevel, pPlayer, pUsedHand);
}
}
return super.use(pLevel, pPlayer, pUsedHand);
}
}

View file

@ -1,28 +0,0 @@
package dev.zontreck.otemod.items.tags;
import net.minecraft.nbt.CompoundTag;
public class ItemStatTag {
public static final String STATS_TAG = "stat";
public ItemStatType type;
public int value;
public ItemStatTag(ItemStatType t, int tag)
{
type = t;
value = tag;
}
public void increment(){
value++;
}
public void decrement()
{
value--;
}
public void save(CompoundTag tag)
{
tag.putInt(STATS_TAG+"_"+type.name().toLowerCase(), value);
}
}

View file

@ -1,13 +0,0 @@
package dev.zontreck.otemod.items.tags;
public enum ItemStatType {
SWORD,
ARMOR,
PICK,
AXE,
SHOVEL,
SHOVELPATH,
HOE,
SHEARS,
EGGING
}

View file

@ -1,47 +0,0 @@
package dev.zontreck.otemod.items.tags;
import dev.zontreck.libzontreck.chat.ChatColor;
public class ItemStatistics {
public static String makeText(ItemStatTag tag)
{
return makeText(tag.type, tag.value);
}
public static String makeText(ItemStatType type, int val)
{
String lore = ChatColor.doColors("!White!");
switch(type)
{
case SWORD -> {
lore += "Mobs Killed: ";
}
case PICK -> {
lore += "Blocks Mined: ";
}
case ARMOR -> {
lore += "Damage Taken: ";
}
case SHOVEL -> {
lore += "Blocks Dug Up: ";
}
case SHOVELPATH -> {
lore += "Paths Made: ";
}
case AXE -> {
lore += "Wood Chopped: ";
}
case HOE -> {
lore += "Blocks Hoed: ";
}
case SHEARS -> {
lore += "Sheep Shaved: ";
}
case EGGING -> {
lore += "Mobs Egged: ";
}
}
lore += ChatColor.doColors("!Green!"+val);
return lore;
}
}

View file

@ -1,22 +0,0 @@
package dev.zontreck.otemod.items.tags;
import java.util.UUID;
public enum ModIDs {
NULL(0,0),
ZNI(0x9f, 0x9f),
OTE(5292022,1182023), // The date range of mod creation, then the day when this feature was added
ITEM_STATS(154301182023L, 0x9f);
private UUID ID;
ModIDs(long A, long B)
{
ID=new UUID(A,B);
}
public UUID get()
{
return ID;
}
}