Skip to content

Commit

Permalink
Add the default flasks not coming with an attached entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrbysco committed Aug 31, 2024
1 parent bc02cfb commit 41da469
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public EntityFlaskItem(Properties properties) {
super(properties);
}

public EntityFlaskItem(Properties properties, EntityType<?> type) {
this(properties.component(ForceComponents.FLASK_CONTENT, new FlaskContent(EntityType.getKey(type), new CompoundTag())));
}

@Override
public InteractionResult useOn(UseOnContext context) {
Level level = context.getLevel();
Expand Down Expand Up @@ -67,8 +71,8 @@ public InteractionResult useOn(UseOnContext context) {
@Override
public InteractionResultHolder<ItemStack> use(Level level, Player playerIn, InteractionHand handIn) {
ItemStack itemstack = playerIn.getItemInHand(handIn);
if (playerIn.isShiftKeyDown()) {
if (hasEntityStored(itemstack) && !level.isClientSide()) {
if (playerIn.isShiftKeyDown() && !level.isClientSide()) {
if (hasEntityStored(itemstack)) {
level.playSound((Player) null, playerIn.getX(), playerIn.getY(), playerIn.getZ(),
SoundEvents.SPLASH_POTION_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (level.random.nextFloat() * 0.4F + 0.8F));
if (!level.isClientSide) {
Expand Down
73 changes: 37 additions & 36 deletions src/main/java/com/mrbysco/forcecraft/registry/ForceRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.util.valueproviders.ConstantInt;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
Expand Down Expand Up @@ -310,42 +311,42 @@ public class ForceRegistry {
public static final DeferredItem<RedPotionItem> RED_POTION = ITEMS.register("red_potion", () -> new RedPotionItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> ENTITY_FLASK = ITEMS.register("entity_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));

public static final DeferredItem<EntityFlaskItem> BAT_FLASK = ITEMS.register("bat_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> BEE_FLASK = ITEMS.register("bee_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> CAT_FLASK = ITEMS.register("cat_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> CAVE_SPIDER_FLASK = ITEMS.register("cave_spider_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> CHICKEN_FLASK = ITEMS.register("chicken_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> COD_FLASK = ITEMS.register("cod_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> COW_FLASK = ITEMS.register("cow_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> DOLPHIN_FLASK = ITEMS.register("dolphin_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> DONKEY_FLASK = ITEMS.register("donkey_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> ENDERMAN_FLASK = ITEMS.register("enderman_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> FOX_FLASK = ITEMS.register("fox_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> HORSE_FLASK = ITEMS.register("horse_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> IRON_GOLEM_FLASK = ITEMS.register("iron_golem_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> LLAMA_FLASK = ITEMS.register("llama_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> MOOSHROOM_FLASK = ITEMS.register("mooshroom_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> MULE_FLASK = ITEMS.register("mule_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> PANDA_FLASK = ITEMS.register("panda_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> PARROT_FLASK = ITEMS.register("parrot_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> PIG_FLASK = ITEMS.register("pig_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> PIGLIN_FLASK = ITEMS.register("piglin_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> POLAR_BEAR_FLASK = ITEMS.register("polar_bear_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> PUFFERFISH_FLASK = ITEMS.register("pufferfish_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> RABBIT_FLASK = ITEMS.register("rabbit_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> SALMON_FLASK = ITEMS.register("salmon_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> SHEEP_FLASK = ITEMS.register("sheep_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> SKELETON_FLASK = ITEMS.register("skeleton_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> SNOW_GOLEM_FLASK = ITEMS.register("snow_golem_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> SPIDER_FLASK = ITEMS.register("spider_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> SQUID_FLASK = ITEMS.register("squid_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> STRIDER_FLASK = ITEMS.register("strider_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> TROPICAL_FISH_FLASK = ITEMS.register("tropical_fish_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> TURTLE_FLASK = ITEMS.register("turtle_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> VILLAGER_FLASK = ITEMS.register("villager_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> WANDERING_TRADER_FLASK = ITEMS.register("wandering_trader_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> WOLF_FLASK = ITEMS.register("wolf_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> ZOMBIFIED_PIGLIN_FLASK = ITEMS.register("zombified_piglin_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get())));
public static final DeferredItem<EntityFlaskItem> BAT_FLASK = ITEMS.register("bat_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.BAT));
public static final DeferredItem<EntityFlaskItem> BEE_FLASK = ITEMS.register("bee_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.BEE));
public static final DeferredItem<EntityFlaskItem> CAT_FLASK = ITEMS.register("cat_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.CAT));
public static final DeferredItem<EntityFlaskItem> CAVE_SPIDER_FLASK = ITEMS.register("cave_spider_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.CAVE_SPIDER));
public static final DeferredItem<EntityFlaskItem> CHICKEN_FLASK = ITEMS.register("chicken_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.CHICKEN));
public static final DeferredItem<EntityFlaskItem> COD_FLASK = ITEMS.register("cod_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.COD));
public static final DeferredItem<EntityFlaskItem> COW_FLASK = ITEMS.register("cow_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.COW));
public static final DeferredItem<EntityFlaskItem> DOLPHIN_FLASK = ITEMS.register("dolphin_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.DOLPHIN));
public static final DeferredItem<EntityFlaskItem> DONKEY_FLASK = ITEMS.register("donkey_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.DONKEY));
public static final DeferredItem<EntityFlaskItem> ENDERMAN_FLASK = ITEMS.register("enderman_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.ENDERMAN));
public static final DeferredItem<EntityFlaskItem> FOX_FLASK = ITEMS.register("fox_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.FOX));
public static final DeferredItem<EntityFlaskItem> HORSE_FLASK = ITEMS.register("horse_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.HORSE));
public static final DeferredItem<EntityFlaskItem> IRON_GOLEM_FLASK = ITEMS.register("iron_golem_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.IRON_GOLEM));
public static final DeferredItem<EntityFlaskItem> LLAMA_FLASK = ITEMS.register("llama_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.LLAMA));
public static final DeferredItem<EntityFlaskItem> MOOSHROOM_FLASK = ITEMS.register("mooshroom_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.MOOSHROOM));
public static final DeferredItem<EntityFlaskItem> MULE_FLASK = ITEMS.register("mule_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.MULE));
public static final DeferredItem<EntityFlaskItem> PANDA_FLASK = ITEMS.register("panda_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.PANDA));
public static final DeferredItem<EntityFlaskItem> PARROT_FLASK = ITEMS.register("parrot_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.PARROT));
public static final DeferredItem<EntityFlaskItem> PIG_FLASK = ITEMS.register("pig_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.PIG));
public static final DeferredItem<EntityFlaskItem> PIGLIN_FLASK = ITEMS.register("piglin_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.PIGLIN));
public static final DeferredItem<EntityFlaskItem> POLAR_BEAR_FLASK = ITEMS.register("polar_bear_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.POLAR_BEAR));
public static final DeferredItem<EntityFlaskItem> PUFFERFISH_FLASK = ITEMS.register("pufferfish_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.PUFFERFISH));
public static final DeferredItem<EntityFlaskItem> RABBIT_FLASK = ITEMS.register("rabbit_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.RABBIT));
public static final DeferredItem<EntityFlaskItem> SALMON_FLASK = ITEMS.register("salmon_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.SALMON));
public static final DeferredItem<EntityFlaskItem> SHEEP_FLASK = ITEMS.register("sheep_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.SHEEP));
public static final DeferredItem<EntityFlaskItem> SKELETON_FLASK = ITEMS.register("skeleton_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.SKELETON));
public static final DeferredItem<EntityFlaskItem> SNOW_GOLEM_FLASK = ITEMS.register("snow_golem_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.SNOW_GOLEM));
public static final DeferredItem<EntityFlaskItem> SPIDER_FLASK = ITEMS.register("spider_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.SPIDER));
public static final DeferredItem<EntityFlaskItem> SQUID_FLASK = ITEMS.register("squid_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.SQUID));
public static final DeferredItem<EntityFlaskItem> STRIDER_FLASK = ITEMS.register("strider_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.STRIDER));
public static final DeferredItem<EntityFlaskItem> TROPICAL_FISH_FLASK = ITEMS.register("tropical_fish_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.TROPICAL_FISH));
public static final DeferredItem<EntityFlaskItem> TURTLE_FLASK = ITEMS.register("turtle_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.TURTLE));
public static final DeferredItem<EntityFlaskItem> VILLAGER_FLASK = ITEMS.register("villager_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.VILLAGER));
public static final DeferredItem<EntityFlaskItem> WANDERING_TRADER_FLASK = ITEMS.register("wandering_trader_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.WANDERING_TRADER));
public static final DeferredItem<EntityFlaskItem> WOLF_FLASK = ITEMS.register("wolf_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.WOLF));
public static final DeferredItem<EntityFlaskItem> ZOMBIFIED_PIGLIN_FLASK = ITEMS.register("zombified_piglin_flask", () -> new EntityFlaskItem(itemBuilder().craftRemainder(FORCE_FLASK.get()), EntityType.ZOMBIFIED_PIGLIN));

public static final DeferredItem<ItemCardItem> ITEM_CARD = ITEMS.register("item_card", () -> new ItemCardItem(itemBuilder()));

Expand Down

0 comments on commit 41da469

Please sign in to comment.