generated from TropheusJ/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
201 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/main/java/io/github/tropheusj/its_as_shrimple_as_that/entity/ShrimpMerchant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package io.github.tropheusj.its_as_shrimple_as_that.entity; | ||
|
||
import io.github.tropheusj.its_as_shrimple_as_that.ItsAsShrimpleAsThat; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.sounds.SoundEvent; | ||
import net.minecraft.sounds.SoundEvents; | ||
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.trading.ItemCost; | ||
import net.minecraft.world.item.trading.Merchant; | ||
import net.minecraft.world.item.trading.MerchantOffer; | ||
import net.minecraft.world.item.trading.MerchantOffers; | ||
|
||
public class ShrimpMerchant implements Merchant { | ||
@Nullable | ||
private Player tradingPlayer; | ||
|
||
private MerchantOffers offers; | ||
|
||
public ShrimpMerchant() { | ||
this.offers = new MerchantOffers(); | ||
this.offers.add(itemForGems(ItsAsShrimpleAsThat.FRIED_RICE, 2)); | ||
} | ||
|
||
private MerchantOffer itemForGems(Item item, int count) { | ||
return new MerchantOffer( | ||
new ItemCost(Items.AMBER_GEM, count), | ||
new ItemStack(item), | ||
Integer.MAX_VALUE, // max uses | ||
1, // xp | ||
1 // price multiplier | ||
); | ||
} | ||
|
||
@Override | ||
public void setTradingPlayer(@Nullable Player player) { | ||
this.tradingPlayer = player; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Player getTradingPlayer() { | ||
return this.tradingPlayer; | ||
} | ||
|
||
public boolean isTrading() { | ||
return this.tradingPlayer != null; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public MerchantOffers getOffers() { | ||
return this.offers; | ||
} | ||
|
||
@Override | ||
public void overrideOffers(MerchantOffers merchantOffers) { | ||
this.offers = merchantOffers; | ||
} | ||
|
||
@Override | ||
public void notifyTrade(MerchantOffer merchantOffer) { | ||
merchantOffer.increaseUses(); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public SoundEvent getNotifyTradeSound() { | ||
return SoundEvents.VILLAGER_YES; | ||
} | ||
|
||
@Override | ||
public boolean isClientSide() { | ||
return false; | ||
} | ||
|
||
// don't care | ||
|
||
@Override | ||
public void notifyTradeUpdated(ItemStack itemStack) { | ||
} | ||
|
||
@Override | ||
public int getVillagerXp() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void overrideXp(int i) { | ||
} | ||
|
||
@Override | ||
public boolean showProgressBar() { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/io/github/tropheusj/its_as_shrimple_as_that/item/FriedRiceItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.github.tropheusj.its_as_shrimple_as_that.item; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import net.minecraft.advancements.CriteriaTriggers; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.stats.Stats; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.food.FoodProperties; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.level.Level; | ||
|
||
public class FriedRiceItem extends Item { | ||
public FriedRiceItem(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
public static Properties makeProperties() { | ||
return new Properties().stacksTo(1).food(new FoodProperties.Builder().nutrition(5).build()); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity entity) { | ||
if (entity instanceof ServerPlayer player) { | ||
CriteriaTriggers.CONSUME_ITEM.trigger(player, stack); | ||
player.awardStat(Stats.ITEM_USED.get(this)); | ||
} | ||
|
||
stack.consume(1, entity); | ||
|
||
return stack.isEmpty() ? new ItemStack(Items.BOWL) : stack; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/resources/assets/its_as_shrimple_as_that/lang/en_us.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/its_as_shrimple_as_that/models/item/fried_rice.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "its_as_shrimple_as_that:item/fried_rice" | ||
} | ||
} |
Binary file added
BIN
+4.38 KB
src/main/resources/assets/its_as_shrimple_as_that/textures/item/fried_rice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.