Dice, please fix
This commit is contained in:
parent
ab7293e855
commit
3c3b802ab9
16 changed files with 256 additions and 5 deletions
|
@ -5,6 +5,8 @@ import net.fabricmc.api.EnvType;
|
|||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import su.a71.new_soviet.registration.NSE_Blocks;
|
||||
import su.a71.new_soviet.registration.NSE_Custom;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class NewSovietClient implements ClientModInitializer {
|
||||
|
|
|
@ -22,6 +22,9 @@ import net.minecraft.recipe.book.RecipeCategory;
|
|||
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_Custom;
|
||||
import su.a71.new_soviet.registration.NSE_Items;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
|
|
@ -4,18 +4,25 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.GsonBuilder;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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;
|
||||
|
||||
public class NewSoviet implements ModInitializer {
|
||||
public static final String MOD_ID = "new_soviet";
|
||||
public static final String MOD_NAME = "New Soviet Era";
|
||||
public static final Logger LOG;
|
||||
public static final Gson GSON;
|
||||
public static final Random RANDOM;
|
||||
|
||||
static {
|
||||
LOG = LoggerFactory.getLogger(MOD_NAME);
|
||||
GSON = (new GsonBuilder()).setPrettyPrinting().create();
|
||||
RANDOM = Random.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,5 +31,6 @@ public class NewSoviet implements ModInitializer {
|
|||
NSE_Blocks.initFlame();
|
||||
NSE_Items.init();
|
||||
NSE_Custom.init();
|
||||
NSE_Combat.init();
|
||||
}
|
||||
}
|
60
src/main/java/su/a71/new_soviet/blocks/WindowBlock.java
Normal file
60
src/main/java/su/a71/new_soviet/blocks/WindowBlock.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package su.a71.new_soviet.blocks;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class WindowBlock extends HorizontalFacingBlock {
|
||||
public static final IntProperty WIN_TYPE = IntProperty.of("window_type", 0, 2);
|
||||
public static final BooleanProperty BROKEN = Properties.CRACKED;
|
||||
|
||||
public WindowBlock(Settings settings) {
|
||||
super(settings);
|
||||
setDefaultState(getDefaultState()
|
||||
.with(Properties.HORIZONTAL_FACING, Direction.NORTH)
|
||||
.with(BROKEN, false)
|
||||
.with(WIN_TYPE, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(Properties.HORIZONTAL_FACING, WIN_TYPE, Properties.CRACKED);
|
||||
}
|
||||
|
||||
public void onEntityCollision(World world, BlockPos pos, Entity entity) {
|
||||
if (entity instanceof ProjectileEntity) {
|
||||
world.getBlockState(pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext ctx) {
|
||||
Direction dir = state.get(FACING);
|
||||
return switch (dir) {
|
||||
case NORTH, SOUTH -> VoxelShapes.cuboid(0.0625f, 0.0f, 0.3125f, 0.9375f, 0.5625f, 0.6875f);
|
||||
case EAST, WEST -> VoxelShapes.cuboid(0.3125f, 0.0f, 0.0625f, 0.6875f, 0.5625f, 0.9375f);
|
||||
default -> VoxelShapes.fullCube();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
BlockState above = ctx.getWorld().getBlockState(ctx.getBlockPos().up());
|
||||
BlockState below = ctx.getWorld().getBlockState(ctx.getBlockPos().down());
|
||||
// if ((above.getBlock() instanceof Window && ((Window) above.getBlock()).getStateManager().getProperty("broken") == true) || (below.getBlock() instanceof Window)) {
|
||||
//
|
||||
// }
|
||||
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
|
||||
}
|
||||
}
|
35
src/main/java/su/a71/new_soviet/items/DiceItem.java
Normal file
35
src/main/java/su/a71/new_soviet/items/DiceItem.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package su.a71.new_soviet.items;
|
||||
|
||||
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 su.a71.new_soviet.NewSoviet;
|
||||
import su.a71.new_soviet.registration.NSE_Items;
|
||||
|
||||
public class DiceItem extends Item {
|
||||
public DiceItem(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, 6) + ", ");
|
||||
}
|
||||
user.sendMessage(Text.translatable("item.new_soviet.dice.thrown").append(" " + output.subSequence(0, output.length() - 2)));
|
||||
}
|
||||
|
||||
user.incrementStat(Stats.USED.getOrCreateStat(this));
|
||||
return TypedActionResult.success(itemStack, world.isClient());
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package su.a71.new_soviet;
|
||||
package su.a71.new_soviet.registration;
|
||||
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
|
@ -18,6 +18,7 @@ import net.minecraft.registry.RegistryKey;
|
|||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import su.a71.new_soviet.NewSoviet;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
48
src/main/java/su/a71/new_soviet/registration/NSE_Combat.java
Normal file
48
src/main/java/su/a71/new_soviet/registration/NSE_Combat.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
package su.a71.new_soviet.registration;
|
||||
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.MapColor;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import su.a71.new_soviet.NewSoviet;
|
||||
import su.a71.new_soviet.blocks.*;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class NSE_Combat {
|
||||
|
||||
public static final LandMineBlock LANDMINE = new LandMineBlock(FabricBlockSettings.create().mapColor(MapColor.LIGHT_GRAY));
|
||||
|
||||
private static final ItemGroup NSE_COMBAT_TAB = FabricItemGroup.builder()
|
||||
.icon(() -> new ItemStack(LANDMINE))
|
||||
.displayName(Text.translatable("itemGroup.new_soviet.combat"))
|
||||
.build();
|
||||
|
||||
|
||||
private static void register(String name, Supplier<? extends Block> supplier, ItemGroup tab) {
|
||||
Registry.register(Registries.BLOCK, new Identifier(NewSoviet.MOD_ID, name), supplier.get());
|
||||
BlockItem blockItem = new BlockItem(supplier.get(), new FabricItemSettings());
|
||||
Registry.register(Registries.ITEM, new Identifier(NewSoviet.MOD_ID, name), blockItem);
|
||||
|
||||
Optional<RegistryKey<ItemGroup>> key = Registries.ITEM_GROUP.getKey(tab);
|
||||
key.ifPresent(itemGroupRegistryKey -> ItemGroupEvents.modifyEntriesEvent(itemGroupRegistryKey).register(content -> {
|
||||
content.add(blockItem);
|
||||
}));
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
Registry.register(Registries.ITEM_GROUP, new Identifier("new_soviet", "combat"), NSE_COMBAT_TAB);
|
||||
register("landmine", () -> LANDMINE, NSE_COMBAT_TAB);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package su.a71.new_soviet;
|
||||
package su.a71.new_soviet.registration;
|
||||
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
|
@ -15,6 +15,7 @@ import net.minecraft.registry.RegistryKey;
|
|||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import su.a71.new_soviet.NewSoviet;
|
||||
import su.a71.new_soviet.blocks.*;
|
||||
|
||||
import java.util.Optional;
|
|
@ -1,4 +1,4 @@
|
|||
package su.a71.new_soviet;
|
||||
package su.a71.new_soviet.registration;
|
||||
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
|
@ -12,12 +12,15 @@ import net.minecraft.registry.Registries;
|
|||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
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.DiceItem;
|
||||
|
||||
public class NSE_Items {
|
||||
// Like an iron axe but a hoe and slightly faster (-2.8f vs -3.1f) and a bit weaker (6 vs 6.5 damage)
|
||||
|
@ -27,6 +30,9 @@ 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 SoundEvent DICE_SOUND = SoundEvent.of(new Identifier("new_soviet", "dice_sound"));
|
||||
|
||||
private static final ItemGroup NSE_ITEMS_TAB = FabricItemGroup.builder()
|
||||
.icon(() -> new ItemStack(SICKLE))
|
||||
.displayName(Text.translatable("itemGroup.new_soviet.items"))
|
||||
|
@ -46,5 +52,8 @@ 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);
|
||||
|
||||
Registry.register(Registries.SOUND_EVENT, new Identifier("new_soviet", "dice_sound"), DICE_SOUND);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "new_soviet:block/landmine"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
"itemGroup.new_soviet.building_blocks": "Soviet Building Blocks",
|
||||
"itemGroup.new_soviet.items": "Soviet Items",
|
||||
"itemGroup.new_soviet.custom": "Soviet Additions",
|
||||
"itemGroup.new_soviet.combat": "Soviet Combat",
|
||||
"block.new_soviet.sand_tiles": "Sand Tiles",
|
||||
"block.new_soviet.cracked_sand_tiles": "Cracked Sand Tiles",
|
||||
"block.new_soviet.mossy_sand_tiles": "Mossy Sand Tiles",
|
||||
|
@ -126,6 +127,9 @@
|
|||
"block.new_soviet.radio": "Radio",
|
||||
"block.new_soviet.lamp": "Lamp",
|
||||
"block.new_soviet.ceiling_fan": "Ceiling Fan",
|
||||
"block.new_soviet.siren": "Siren"
|
||||
|
||||
"block.new_soviet.siren": "Siren",
|
||||
"item.new_soviet.dice": "Dice",
|
||||
"item.new_soviet.dice.thrown": "Dice was thrown with result:",
|
||||
"subtitles.new_soviet.dice_throw": "Dice thrown",
|
||||
"block.new_soviet.landmine": "AP Landmine"
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"credit": "Made with Blockbench",
|
||||
"texture_size": [32, 32],
|
||||
"textures": {
|
||||
"0": "new_soviet:block/combat/ap_mine",
|
||||
"particle": "new_soviet:block/combat/ap_mine"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [5, 1, 5],
|
||||
"to": [11, 2, 11],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
|
||||
"faces": {
|
||||
"north": {"uv": [3, 3, 6, 3.5], "texture": "#0"},
|
||||
"east": {"uv": [0, 3, 3, 3.5], "texture": "#0"},
|
||||
"south": {"uv": [9, 3, 12, 3.5], "texture": "#0"},
|
||||
"west": {"uv": [6, 3, 9, 3.5], "texture": "#0"},
|
||||
"up": {"uv": [6, 3, 3, 0], "texture": "#0"},
|
||||
"down": {"uv": [9, 0, 6, 3], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [5.5, 0, 5.5],
|
||||
"to": [10.5, 1, 10.5],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8.5, 0, 8.5]},
|
||||
"faces": {
|
||||
"north": {"uv": [2.5, 6, 5, 6.5], "texture": "#0"},
|
||||
"east": {"uv": [0, 6, 2.5, 6.5], "texture": "#0"},
|
||||
"south": {"uv": [7.5, 6, 10, 6.5], "texture": "#0"},
|
||||
"west": {"uv": [5, 6, 7.5, 6.5], "texture": "#0"},
|
||||
"up": {"uv": [5, 6, 2.5, 3.5], "texture": "#0"},
|
||||
"down": {"uv": [7.5, 3.5, 5, 6], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [7.5, 0, 4.5],
|
||||
"to": [8.5, 1, 5.5],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8.5, 0, 8.5]},
|
||||
"faces": {
|
||||
"north": {"uv": [0.5, 0.5, 1, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0.5, 0.5, 1], "texture": "#0"},
|
||||
"south": {"uv": [1.5, 0.5, 2, 1], "texture": "#0"},
|
||||
"west": {"uv": [1, 0.5, 1.5, 1], "texture": "#0"},
|
||||
"up": {"uv": [1, 0.5, 0.5, 0], "texture": "#0"},
|
||||
"down": {"uv": [1.5, 0, 1, 0.5], "texture": "#0"}
|
||||
}
|
||||
}
|
||||
],
|
||||
"groups": [
|
||||
{
|
||||
"name": "group",
|
||||
"origin": [8, 8, 8],
|
||||
"color": 0,
|
||||
"children": [0, 1, 2]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "new_soviet:item/dice"
|
||||
}
|
||||
}
|
||||
|
9
src/main/resources/assets/new_soviet/sounds.json
Normal file
9
src/main/resources/assets/new_soviet/sounds.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"dice_sound": {
|
||||
"subtitle": "subtitles.new_soviet.dice_throw",
|
||||
"sounds": [
|
||||
"new_soviet:dice_roll"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
BIN
src/main/resources/assets/new_soviet/sounds/dice_roll.ogg
Normal file
BIN
src/main/resources/assets/new_soviet/sounds/dice_roll.ogg
Normal file
Binary file not shown.
BIN
src/main/resources/assets/new_soviet/textures/item/dice.png
Normal file
BIN
src/main/resources/assets/new_soviet/textures/item/dice.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 198 B |
Loading…
Reference in a new issue