More dice
This commit is contained in:
parent
ecd4981dd1
commit
80427fa3a2
81 changed files with 1619 additions and 7 deletions
|
@ -23,6 +23,7 @@ import net.minecraft.registry.RegistryWrapper;
|
|||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.util.Util;
|
||||
import su.a71.new_soviet.registration.NSE_Blocks;
|
||||
import su.a71.new_soviet.registration.NSE_Combat;
|
||||
import su.a71.new_soviet.registration.NSE_Custom;
|
||||
import su.a71.new_soviet.registration.NSE_Items;
|
||||
|
||||
|
@ -336,6 +337,25 @@ public class DataGeneration implements DataGeneratorEntrypoint {
|
|||
}
|
||||
}
|
||||
|
||||
private void diceRecipe(Consumer<RecipeJsonProvider> exporter, ItemConvertible dice) {
|
||||
var buttons = Util.make(Lists.newArrayList(), list -> {
|
||||
list.add(Blocks.OAK_BUTTON);
|
||||
list.add(Blocks.BAMBOO_BUTTON);
|
||||
list.add(Blocks.BIRCH_BUTTON);
|
||||
list.add(Blocks.CHERRY_BUTTON);
|
||||
list.add(Blocks.ACACIA_BUTTON);
|
||||
list.add(Blocks.CRIMSON_BUTTON);
|
||||
list.add(Blocks.DARK_OAK_BUTTON);
|
||||
list.add(Blocks.JUNGLE_BUTTON);
|
||||
list.add(Blocks.MANGROVE_BUTTON);
|
||||
list.add(Blocks.SPRUCE_BUTTON);
|
||||
list.add(Blocks.WARPED_BUTTON);
|
||||
});
|
||||
for (Object button : buttons) {
|
||||
offerStonecuttingRecipe(exporter, RecipeCategory.MISC, dice, (ItemConvertible) button);
|
||||
}
|
||||
}
|
||||
|
||||
private void warningStripeRecipe(Consumer<RecipeJsonProvider> exporter, ItemConvertible output, ItemConvertible dye) {
|
||||
ShapedRecipeJsonBuilder.create(RecipeCategory.BUILDING_BLOCKS, output, 4)
|
||||
.pattern("D#D")
|
||||
|
@ -591,6 +611,10 @@ public class DataGeneration implements DataGeneratorEntrypoint {
|
|||
list.add(NSE_Blocks.BIG_TUFF_TILES);
|
||||
list.add(Blocks.TUFF);
|
||||
}), RecipeCategory.BUILDING_BLOCKS);
|
||||
|
||||
diceRecipe(exporter, NSE_Items.DICE_D4);
|
||||
diceRecipe(exporter, NSE_Items.DICE_D6);
|
||||
diceRecipe(exporter, NSE_Items.DICE_D20);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.util.Hand;
|
|||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
|
@ -112,7 +113,8 @@ public class LandMineBlock extends Block implements Waterloggable {
|
|||
}
|
||||
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
return SHAPE;
|
||||
Vec3d vec3d = state.getModelOffset(world, pos);
|
||||
return SHAPE.offset(vec3d.getX(), vec3d.getY(), vec3d.getZ());
|
||||
}
|
||||
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
|
|
49
src/main/java/su/a71/new_soviet/items/DiceD20Item.java
Normal file
49
src/main/java/su/a71/new_soviet/items/DiceD20Item.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package su.a71.new_soviet.items;
|
||||
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.stat.Stats;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.a71.new_soviet.NewSoviet;
|
||||
import su.a71.new_soviet.registration.NSE_Items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiceD20Item extends Item {
|
||||
public DiceD20Item(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
||||
ItemStack itemStack = user.getStackInHand(hand);
|
||||
user.getItemCooldownManager().set(this, 20 * itemStack.getCount());
|
||||
if (!world.isClient) {
|
||||
StringBuilder output = new StringBuilder();
|
||||
for (var i = 0; i < itemStack.getCount(); i++) {
|
||||
world.playSound((PlayerEntity)null, user.getX(), user.getY(), user.getZ(), NSE_Items.DICE_SOUND, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
output.append(NewSoviet.RANDOM.nextBetween(1, this.getSides())).append(", ");
|
||||
}
|
||||
user.sendMessage(Text.translatable(itemStack.getCount() == 1 ? "item.new_soviet.dice.thrown" : "item.new_soviet.dice.thrown_multiple").append(" " + output.subSequence(0, output.length() - 2)));
|
||||
}
|
||||
|
||||
user.increaseStat(Stats.USED.getOrCreateStat(this), itemStack.getCount());
|
||||
return TypedActionResult.success(itemStack, world.isClient());
|
||||
}
|
||||
|
||||
public int getSides() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
|
||||
tooltip.add(Text.translatable("item.new_soviet.dice_d20.tooltip"));
|
||||
super.appendTooltip(stack, world, tooltip, context);
|
||||
}
|
||||
}
|
49
src/main/java/su/a71/new_soviet/items/DiceD4Item.java
Normal file
49
src/main/java/su/a71/new_soviet/items/DiceD4Item.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package su.a71.new_soviet.items;
|
||||
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.stat.Stats;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.a71.new_soviet.NewSoviet;
|
||||
import su.a71.new_soviet.registration.NSE_Items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiceD4Item extends Item {
|
||||
public DiceD4Item(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
||||
ItemStack itemStack = user.getStackInHand(hand);
|
||||
user.getItemCooldownManager().set(this, 20 * itemStack.getCount());
|
||||
if (!world.isClient) {
|
||||
StringBuilder output = new StringBuilder();
|
||||
for (var i = 0; i < itemStack.getCount(); i++) {
|
||||
world.playSound((PlayerEntity)null, user.getX(), user.getY(), user.getZ(), NSE_Items.DICE_SOUND, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
output.append(NewSoviet.RANDOM.nextBetween(1, this.getSides())).append(", ");
|
||||
}
|
||||
user.sendMessage(Text.translatable(itemStack.getCount() == 1 ? "item.new_soviet.dice.thrown" : "item.new_soviet.dice.thrown_multiple").append(" " + output.subSequence(0, output.length() - 2)));
|
||||
}
|
||||
|
||||
user.increaseStat(Stats.USED.getOrCreateStat(this), itemStack.getCount());
|
||||
return TypedActionResult.success(itemStack, world.isClient());
|
||||
}
|
||||
|
||||
public int getSides() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
|
||||
tooltip.add(Text.translatable("item.new_soviet.dice_d4.tooltip"));
|
||||
super.appendTooltip(stack, world, tooltip, context);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package su.a71.new_soviet.items;
|
||||
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -9,9 +10,12 @@ import net.minecraft.text.Text;
|
|||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.a71.new_soviet.NewSoviet;
|
||||
import su.a71.new_soviet.registration.NSE_Items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiceItem extends Item {
|
||||
public DiceItem(Settings settings) {
|
||||
super(settings);
|
||||
|
@ -24,12 +28,22 @@ public class DiceItem extends Item {
|
|||
StringBuilder output = new StringBuilder();
|
||||
for (var i = 0; i < itemStack.getCount(); i++) {
|
||||
world.playSound((PlayerEntity)null, user.getX(), user.getY(), user.getZ(), NSE_Items.DICE_SOUND, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
output.append(NewSoviet.RANDOM.nextBetween(1, 6) + ", ");
|
||||
output.append(NewSoviet.RANDOM.nextBetween(1, this.getSides())).append(", ");
|
||||
}
|
||||
user.sendMessage(Text.translatable(itemStack.getCount() == 1 ? "item.new_soviet.dice.thrown" : "item.new_soviet.dice.thrown_multiple").append(" " + output.subSequence(0, output.length() - 2)));
|
||||
}
|
||||
|
||||
user.incrementStat(Stats.USED.getOrCreateStat(this));
|
||||
user.increaseStat(Stats.USED.getOrCreateStat(this), itemStack.getCount());
|
||||
return TypedActionResult.success(itemStack, world.isClient());
|
||||
}
|
||||
|
||||
public int getSides() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
|
||||
tooltip.add(Text.translatable("item.new_soviet.dice_d6.tooltip"));
|
||||
super.appendTooltip(stack, world, tooltip, context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.util.Optional;
|
|||
import java.util.function.Supplier;
|
||||
import net.minecraft.util.Rarity;
|
||||
import su.a71.new_soviet.NewSoviet;
|
||||
import su.a71.new_soviet.items.DiceD20Item;
|
||||
import su.a71.new_soviet.items.DiceD4Item;
|
||||
import su.a71.new_soviet.items.DiceItem;
|
||||
|
||||
public class NSE_Items {
|
||||
|
@ -30,7 +32,10 @@ public class NSE_Items {
|
|||
public static final FoodComponent COCONUT_FC = (new FoodComponent.Builder()).hunger(4).saturationModifier(1.2F).statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 100, 1), 1.0F).statusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 2400, 0), 1.0F).alwaysEdible().build();
|
||||
public static final Item COCONUT = new Item(new Item.Settings().food(COCONUT_FC).rarity(Rarity.EPIC));
|
||||
|
||||
public static final DiceItem DICE = new DiceItem(new Item.Settings().maxCount(6));
|
||||
public static final DiceItem DICE_D6 = new DiceItem(new Item.Settings().maxCount(6));
|
||||
public static final DiceD4Item DICE_D4 = new DiceD4Item(new Item.Settings().maxCount(6));
|
||||
public static final DiceD20Item DICE_D20 = new DiceD20Item(new Item.Settings().maxCount(6));
|
||||
|
||||
public static final SoundEvent DICE_SOUND = SoundEvent.of(new Identifier("new_soviet", "dice_sound"));
|
||||
|
||||
private static final ItemGroup NSE_ITEMS_TAB = FabricItemGroup.builder()
|
||||
|
@ -52,7 +57,9 @@ public class NSE_Items {
|
|||
Registry.register(Registries.ITEM_GROUP, new Identifier("new_soviet", "items"), NSE_ITEMS_TAB);
|
||||
register("sickle", () -> SICKLE, NSE_ITEMS_TAB);
|
||||
register("coconut", () -> COCONUT, NSE_ITEMS_TAB);
|
||||
register("dice", () -> DICE, NSE_ITEMS_TAB);
|
||||
register("dice_d6", () -> DICE_D6, NSE_ITEMS_TAB);
|
||||
register("dice_d4", () -> DICE_D4, NSE_ITEMS_TAB);
|
||||
register("dice_d20", () -> DICE_D20, NSE_ITEMS_TAB);
|
||||
|
||||
Registry.register(Registries.SOUND_EVENT, new Identifier("new_soviet", "dice_sound"), DICE_SOUND);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue