Decorative 4.1.0 - 1.17 and code cleanup

Update to 1.17-pre1 and Java 16
Use MidnightLib for configuration, makes the config gui cleaner and accessable without modmenu
This commit is contained in:
Motschen
2021-05-30 13:13:22 +02:00
parent bfc6fc4d16
commit 57c92dbcba
943 changed files with 1428 additions and 1652 deletions

View File

@@ -1,6 +1,11 @@
package eu.midnightdust.motschen.decorative;
import eu.midnightdust.motschen.decorative.block.render.*;
import eu.midnightdust.motschen.decorative.block.render.model.CeilingFanBladesModel;
import eu.midnightdust.motschen.decorative.block.render.model.WallClockHandsModel;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import eu.midnightdust.motschen.decorative.entity.client.model.BeachBallModel;
import eu.midnightdust.motschen.decorative.entity.client.model.DuckBathTireModel;
import eu.midnightdust.motschen.decorative.entity.client.renderer.*;
import eu.midnightdust.motschen.decorative.init.BathTires;
import eu.midnightdust.motschen.decorative.init.BlockEntities;
@@ -9,38 +14,47 @@ import eu.midnightdust.motschen.decorative.init.Signs;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityModelLayerRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.util.DyeColor;
@SuppressWarnings({"deprecation", "UnstableApiUsage"})
public class DecorativeClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
EntityModelLayerRegistry.registerModelLayer(BathTireModel.BATH_TIRE_MODEL_LAYER, BathTireModel::getTexturedModelData);
EntityModelLayerRegistry.registerModelLayer(DuckBathTireModel.DUCK_BATH_TIRE_MODEL_LAYER, DuckBathTireModel::getTexturedModelData);
EntityModelLayerRegistry.registerModelLayer(BeachBallModel.BEACH_BALL_MODEL_LAYER, BeachBallModel::getTexturedModelData);
EntityRendererRegistry.INSTANCE.register(Pool.BEACH_BALL, (dispatcher, context) -> new BeachBallRenderer(dispatcher));
EntityModelLayerRegistry.registerModelLayer(CeilingFanBladesModel.CEILING_FAN_MODEL_LAYER, CeilingFanBladesModel::getTexturedModelData);
EntityModelLayerRegistry.registerModelLayer(WallClockHandsModel.CLOCK_HANDS_MODEL_LAYER, WallClockHandsModel::getTexturedModelData);
EntityRendererRegistry.INSTANCE.register(BathTires.WHITE_BATH_TIRE, (dispatcher, context) -> new WhiteBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.ORANGE_BATH_TIRE, (dispatcher, context) -> new OrangeBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.MAGENTA_BATH_TIRE, (dispatcher, context) -> new MagentaBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.LIGHT_BLUE_BATH_TIRE, (dispatcher, context) -> new LightBlueBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.YELLOW_BATH_TIRE, (dispatcher, context) -> new YellowBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.LIME_BATH_TIRE, (dispatcher, context) -> new LimeBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.PINK_BATH_TIRE, (dispatcher, context) -> new PinkBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.GRAY_BATH_TIRE, (dispatcher, context) -> new GrayBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.LIGHT_GRAY_BATH_TIRE, (dispatcher, context) -> new LightGrayBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.CYAN_BATH_TIRE, (dispatcher, context) -> new CyanBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.PURPLE_BATH_TIRE, (dispatcher, context) -> new PurpleBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.BLUE_BATH_TIRE, (dispatcher, context) -> new BlueBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.BROWN_BATH_TIRE, (dispatcher, context) -> new BrownBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.GREEN_BATH_TIRE, (dispatcher, context) -> new GreenBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.RED_BATH_TIRE, (dispatcher, context) -> new RedBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.BLACK_BATH_TIRE, (dispatcher, context) -> new BlackBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(Pool.BEACH_BALL, BeachBallRenderer::new);
EntityRendererRegistry.INSTANCE.register(BathTires.DUCK_BATH_TIRE, (dispatcher, context) -> new DuckBathTireRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(BathTires.WHITE_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.WHITE));
EntityRendererRegistry.INSTANCE.register(BathTires.ORANGE_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.ORANGE));
EntityRendererRegistry.INSTANCE.register(BathTires.MAGENTA_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.MAGENTA));
EntityRendererRegistry.INSTANCE.register(BathTires.LIGHT_BLUE_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.LIGHT_BLUE));
EntityRendererRegistry.INSTANCE.register(BathTires.YELLOW_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.YELLOW));
EntityRendererRegistry.INSTANCE.register(BathTires.LIME_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.LIME));
EntityRendererRegistry.INSTANCE.register(BathTires.PINK_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.PINK));
EntityRendererRegistry.INSTANCE.register(BathTires.GRAY_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.GRAY));
EntityRendererRegistry.INSTANCE.register(BathTires.LIGHT_GRAY_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.LIGHT_GRAY));
EntityRendererRegistry.INSTANCE.register(BathTires.CYAN_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.CYAN));
EntityRendererRegistry.INSTANCE.register(BathTires.PURPLE_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.PURPLE));
EntityRendererRegistry.INSTANCE.register(BathTires.BLUE_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.BLUE));
EntityRendererRegistry.INSTANCE.register(BathTires.BROWN_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.BROWN));
EntityRendererRegistry.INSTANCE.register(BathTires.GREEN_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.GREEN));
EntityRendererRegistry.INSTANCE.register(BathTires.RED_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.RED));
EntityRendererRegistry.INSTANCE.register(BathTires.BLACK_BATH_TIRE, (context) -> new BathTireRenderer(context, DyeColor.BLACK));
EntityRendererRegistry.INSTANCE.register(BathTires.DUCK_BATH_TIRE, DuckBathTireRenderer::new);
registerBlockColor(DecorativeMain.BirdBath, Blocks.WATER);

View File

@@ -1,5 +1,6 @@
package eu.midnightdust.motschen.decorative;
import eu.midnightdust.lib.config.MidnightConfig;
import eu.midnightdust.motschen.decorative.block.*;
import eu.midnightdust.motschen.decorative.blockstates.CeilingFanStage;
import eu.midnightdust.motschen.decorative.blockstates.Part;
@@ -10,8 +11,6 @@ import eu.midnightdust.motschen.decorative.init.*;
import eu.midnightdust.motschen.decorative.sound.DecorativeSoundEvents;
import eu.midnightdust.motschen.decorative.world.OreFeatureInjector;
import eu.midnightdust.motschen.decorative.world.OreFeatures;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@@ -22,9 +21,9 @@ import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class DecorativeMain implements ModInitializer {
public static final String MOD_ID = "decorative";
public static DecorativeConfig DECORATIVE_CONFIG;
public static final ItemGroup IndoorGroup = FabricItemGroupBuilder.build(new Identifier(MOD_ID, "indoor"), () -> new ItemStack(DecorativeMain.Television));
public static final ItemGroup TrafficGroup = FabricItemGroupBuilder.build(new Identifier(MOD_ID, "traffic"), () -> new ItemStack(DecorativeMain.TrafficCone));
@@ -57,10 +56,10 @@ public class DecorativeMain implements ModInitializer {
@Override
public void onInitialize() {
AutoConfig.register(DecorativeConfig.class, JanksonConfigSerializer::new);
DECORATIVE_CONFIG = AutoConfig.getConfigHolder(DecorativeConfig.class).getConfig();
MidnightConfig.init("decorative", DecorativeConfig.class);
BlockEntities.init();
// Traffic //
Registry.register(Registry.BLOCK, new Identifier(MOD_ID,"rocky_asphalt"), RockyAsphalt);
Registry.register(Registry.ITEM, new Identifier(MOD_ID,"rocky_asphalt"), new BlockItem(RockyAsphalt, new Item.Settings().group(DecorativeMain.TrafficGroup)));

View File

@@ -2,33 +2,72 @@ package eu.midnightdust.motschen.decorative.block;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.cauldron.CauldronBehavior;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
public class BirdBath extends CauldronBlock {
import java.util.Objects;
public class BirdBath extends AbstractCauldronBlock {
private static final VoxelShape SHAPE;
public static final IntProperty LEVEL = IntProperty.of("level",0,3);
public BirdBath() {
super(FabricBlockSettings.copy(Blocks.CAULDRON).nonOpaque().sounds(BlockSoundGroup.STONE));
super(FabricBlockSettings.copy(Blocks.WATER_CAULDRON).nonOpaque().sounds(BlockSoundGroup.STONE), CauldronBehavior.WATER_CAULDRON_BEHAVIOR);
}
@Override
public boolean isFull(BlockState state) {
return state.get(LEVEL) == 3;
}
@Override
protected boolean canBeFilledByDripstone(Fluid fluid) {
return fluid == Fluids.WATER;
}
@Override
protected double getFluidHeight(BlockState state) {
return (6.0D + (double)state.get(LEVEL) * 3.0D) / 16.0D;
}
@Override
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
return state.get(LEVEL);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(LEVEL);
}
@Override
protected void fillFromDripstone(BlockState state, World world, BlockPos pos, Fluid fluid) {
if (!this.isFull(state)) {
world.setBlockState(pos, state.with(LEVEL, state.get(LEVEL) + 1));
world.syncWorldEvent(1047, pos, 0);
}
}
@Override
public BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
return super.getPlacementState(itemPlacementContext)
return Objects.requireNonNull(super.getPlacementState(itemPlacementContext))
.with(LEVEL, 0);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
return SHAPE;
}
static {
VoxelShape shape = createCuboidShape(4, 0, 4, 12, 9, 12);
SHAPE = shape;
SHAPE = createCuboidShape(4, 0, 4, 12, 9, 12);
}
public boolean canPlaceAt(BlockState state, WorldView worldView, BlockPos pos) {

View File

@@ -3,9 +3,13 @@ package eu.midnightdust.motschen.decorative.block;
import eu.midnightdust.motschen.decorative.blockstates.CeilingFanStage;
import eu.midnightdust.motschen.decorative.DecorativeMain;
import eu.midnightdust.motschen.decorative.block.blockentity.CeilingFanBlockEntity;
import eu.midnightdust.motschen.decorative.init.BlockEntities;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.BrewingStandBlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
@@ -21,8 +25,9 @@ import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;
public class CeilingFan extends Block implements BlockEntityProvider {
public class CeilingFan extends BlockWithEntity implements BlockEntityProvider {
private static final VoxelShape SHAPE;
private static final EnumProperty<CeilingFanStage> STAGE = DecorativeMain.STAGE;
@@ -32,8 +37,17 @@ public class CeilingFan extends Block implements BlockEntityProvider {
}
@Override
public BlockEntity createBlockEntity(BlockView view) {
return new CeilingFanBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new CeilingFanBlockEntity(pos, state);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, BlockEntities.CeilingFanBlockEntity, CeilingFanBlockEntity::tick);
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override

View File

@@ -1,18 +1,26 @@
package eu.midnightdust.motschen.decorative.block;
import eu.midnightdust.motschen.decorative.block.blockentity.ChoppingLogBlockEntity;
import eu.midnightdust.motschen.decorative.init.BlockEntities;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;
public class ChoppingLog extends HorizontalFacingBlock implements BlockEntityProvider {
import java.util.Objects;
public class ChoppingLog extends BlockWithEntity implements BlockEntityProvider {
private static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
public ChoppingLog() {
super(FabricBlockSettings.copy(Blocks.OAK_PLANKS).nonOpaque().sounds(BlockSoundGroup.WOOD));
@@ -21,7 +29,7 @@ public class ChoppingLog extends HorizontalFacingBlock implements BlockEntityPro
@Override
public BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
return super.getPlacementState(itemPlacementContext)
return Objects.requireNonNull(super.getPlacementState(itemPlacementContext))
.with(FACING, itemPlacementContext.getPlayerFacing().getOpposite());
}
@@ -35,8 +43,17 @@ public class ChoppingLog extends HorizontalFacingBlock implements BlockEntityPro
}
@Override
public BlockEntity createBlockEntity(BlockView view) {
return new ChoppingLogBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new ChoppingLogBlockEntity(pos, state);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, BlockEntities.ChoppingLogBlockEntity, ChoppingLogBlockEntity::tick);
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
}

View File

@@ -1,20 +1,26 @@
package eu.midnightdust.motschen.decorative.block;
import eu.midnightdust.motschen.decorative.block.blockentity.DigitalClockBlockEntity;
import eu.midnightdust.motschen.decorative.block.blockentity.WallClockBlockEntity;
import eu.midnightdust.motschen.decorative.init.BlockEntities;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
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;
import org.jetbrains.annotations.Nullable;
public class DigitalClock extends HorizontalFacingBlock implements BlockEntityProvider {
public class DigitalClock extends BlockWithEntity implements BlockEntityProvider {
private static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
private static final VoxelShape NORTH_SHAPE;
private static final VoxelShape EAST_SHAPE;
private static final VoxelShape SOUTH_SHAPE;
@@ -26,8 +32,17 @@ public class DigitalClock extends HorizontalFacingBlock implements BlockEntityPr
}
@Override
public BlockEntity createBlockEntity(BlockView view) {
return new DigitalClockBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new DigitalClockBlockEntity(pos, state);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, BlockEntities.DigitalClockBlockEntity, DigitalClockBlockEntity::tick);
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override

View File

@@ -5,6 +5,7 @@ import net.minecraft.block.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsage;
import net.minecraft.item.Items;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
@@ -36,14 +37,7 @@ public class FireHydrant extends HorizontalFacingBlock {
if (!itemStack.isEmpty() && hand==Hand.MAIN_HAND) {
if (itemStack.getItem() == Items.BUCKET) {
if (!world.isClient) {
if (!player.abilities.creativeMode) {
itemStack.decrement(1);
if (itemStack.isEmpty()) {
player.setStackInHand(hand, new ItemStack(Items.WATER_BUCKET));
} else if (!player.inventory.insertStack(new ItemStack(Items.WATER_BUCKET))) {
player.dropItem(new ItemStack(Items.WATER_BUCKET), false);
}
}
ItemUsage.exchangeStack(itemStack, player, new ItemStack(Items.BUCKET));
world.playSound(null, pos, SoundEvents.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
return ActionResult.SUCCESS;

View File

View File

View File

@@ -1,9 +1,12 @@
package eu.midnightdust.motschen.decorative.block;
import eu.midnightdust.motschen.decorative.block.blockentity.PoolSprinklerBlockEntity;
import eu.midnightdust.motschen.decorative.init.BlockEntities;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
@@ -11,6 +14,7 @@ import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
@@ -21,14 +25,18 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;
public class PoolSprinkler extends HorizontalFacingBlock implements BlockEntityProvider {
import java.util.Objects;
public class PoolSprinkler extends BlockWithEntity implements BlockEntityProvider {
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
public static final BooleanProperty POWERED = DoorBlock.POWERED;
private static final VoxelShape NORTH_SHAPE;
private static final VoxelShape EAST_SHAPE;
private static final VoxelShape SOUTH_SHAPE;
private static final VoxelShape WEST_SHAPE;
public static final BooleanProperty POWERED = DoorBlock.POWERED;
public PoolSprinkler() {
super(FabricBlockSettings.copy(Blocks.STONE).nonOpaque().sounds(BlockSoundGroup.STONE));
@@ -36,14 +44,14 @@ public class PoolSprinkler extends HorizontalFacingBlock implements BlockEntityP
}
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
world.setBlockState(pos, state.with(POWERED, Boolean.valueOf(!state.get(POWERED))));
world.setBlockState(pos, state.with(POWERED, !state.get(POWERED)));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 0.5f);
return ActionResult.SUCCESS;
}
@Override
public BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
return super.getPlacementState(itemPlacementContext)
return Objects.requireNonNull(super.getPlacementState(itemPlacementContext))
.with(FACING, itemPlacementContext.getPlayerFacing().getOpposite())
.with(POWERED, Boolean.FALSE);
}
@@ -89,8 +97,17 @@ public class PoolSprinkler extends HorizontalFacingBlock implements BlockEntityP
return !worldView.isAir(pos.down());
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new PoolSprinklerBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new PoolSprinklerBlockEntity(pos, state);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, BlockEntities.PoolSprinklerBlockEntity, PoolSprinklerBlockEntity::tick);
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
}

View File

View File

@@ -1,9 +1,12 @@
package eu.midnightdust.motschen.decorative.block;
import eu.midnightdust.motschen.decorative.block.blockentity.ShowerHeadBlockEntity;
import eu.midnightdust.motschen.decorative.init.BlockEntities;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
@@ -11,6 +14,7 @@ import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
@@ -21,14 +25,16 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;
public class ShowerHead extends HorizontalFacingBlock implements BlockEntityProvider {
public class ShowerHead extends BlockWithEntity implements BlockEntityProvider {
private static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
public static final BooleanProperty POWERED = DoorBlock.POWERED;
private static final VoxelShape NORTH_SHAPE;
private static final VoxelShape EAST_SHAPE;
private static final VoxelShape SOUTH_SHAPE;
private static final VoxelShape WEST_SHAPE;
public static final BooleanProperty POWERED = DoorBlock.POWERED;
public ShowerHead() {
super(FabricBlockSettings.copy(Blocks.STONE).nonOpaque().sounds(BlockSoundGroup.STONE));
@@ -36,7 +42,7 @@ public class ShowerHead extends HorizontalFacingBlock implements BlockEntityProv
}
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
world.setBlockState(pos, state.with(POWERED, Boolean.valueOf(!state.get(POWERED))));
world.setBlockState(pos, state.with(POWERED, !state.get(POWERED)));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 0.5f);
return ActionResult.SUCCESS;
}
@@ -91,8 +97,17 @@ public class ShowerHead extends HorizontalFacingBlock implements BlockEntityProv
return !worldView.isAir(pos.north()) | !worldView.isAir(pos.east()) | !worldView.isAir(pos.south()) | !worldView.isAir(pos.west());
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new ShowerHeadBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new ShowerHeadBlockEntity(pos, state);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, BlockEntities.ShowerHeadBlockEntity, ShowerHeadBlockEntity::tick);
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
}

View File

@@ -35,13 +35,13 @@ public class Sign extends HorizontalFacingBlock {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
switch (state.get(FACING)) {
case NORTH: return NORTH_SHAPE;
case EAST: return EAST_SHAPE;
case SOUTH: return SOUTH_SHAPE;
case WEST: return WEST_SHAPE;
default: return super.getOutlineShape(state, view, pos, context);
}
return switch (state.get(FACING)) {
case NORTH -> NORTH_SHAPE;
case EAST -> EAST_SHAPE;
case SOUTH -> SOUTH_SHAPE;
case WEST -> WEST_SHAPE;
default -> super.getOutlineShape(state, view, pos, context);
};
}
static {
VoxelShape shape = createCuboidShape(0, 0, 6.9, 16, 16, 9);

View File

@@ -23,9 +23,7 @@ public class SignPost extends Block {
return SHAPE;
}
static {
VoxelShape shape = createCuboidShape(7, 0, 7, 9, 16, 9);
SHAPE = shape;
SHAPE = createCuboidShape(7, 0, 7, 9, 16, 9);
}
public boolean canPlaceAt(BlockState state, WorldView worldView, BlockPos pos) {

View File

@@ -43,16 +43,12 @@ public class SlidingDoor extends DoorBlock {
state.get(FACING);
boolean bl = !state.get(OPEN);
boolean bl2 = state.get(HINGE) == DoorHinge.RIGHT;
switch(state.get(FACING)) {
default:
return bl ? WEST_SHAPE : (bl2 ? EAST_SHAPE_OPEN : WEST_SHAPE_OPEN);
case NORTH:
return bl ? NORTH_SHAPE : (bl2 ? SOUTH_SHAPE_OPEN : NORTH_SHAPE_OPEN);
case EAST:
return bl ? EAST_SHAPE : (bl2 ? WEST_SHAPE_OPEN : EAST_SHAPE_OPEN);
case SOUTH:
return bl ? SOUTH_SHAPE : (bl2 ? NORTH_SHAPE_OPEN : SOUTH_SHAPE_OPEN);
}
return switch (state.get(FACING)) {
default -> bl ? WEST_SHAPE : (bl2 ? EAST_SHAPE_OPEN : WEST_SHAPE_OPEN);
case NORTH -> bl ? NORTH_SHAPE : (bl2 ? SOUTH_SHAPE_OPEN : NORTH_SHAPE_OPEN);
case EAST -> bl ? EAST_SHAPE : (bl2 ? WEST_SHAPE_OPEN : EAST_SHAPE_OPEN);
case SOUTH -> bl ? SOUTH_SHAPE : (bl2 ? NORTH_SHAPE_OPEN : SOUTH_SHAPE_OPEN);
};
}
static {
VoxelShape shape = createCuboidShape(0, 0, 7, 16, 16, 9);

View File

@@ -24,6 +24,8 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import java.util.Objects;
public class Springboard extends HorizontalFacingBlock {
private static final VoxelShape NORTH_SHAPE_FRONT;
private static final VoxelShape EAST_SHAPE_FRONT;
@@ -43,68 +45,52 @@ public class Springboard extends HorizontalFacingBlock {
ItemStack itemStack = player.getStackInHand(hand);
if (!world.isClient) {
if (itemStack.isEmpty() && hand==Hand.MAIN_HAND) {
switch (state.get(PART)) {
case FRONT:
if (player.getY() >= pos.getY()+0.1 && player.squaredDistanceTo(pos.getX(), pos.getY(), pos.getZ()) <= 1.0) {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.LEVITATION, 10, 10));
return ActionResult.SUCCESS;
}
else return ActionResult.FAIL;
default:
return ActionResult.FAIL;
if (state.get(PART) == Part.FRONT) {
if (player.getY() >= pos.getY() + 0.1 && player.squaredDistanceTo(pos.getX(), pos.getY(), pos.getZ()) <= 1.0) {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.LEVITATION, 10, 10));
return ActionResult.SUCCESS;
}
}
}
else return ActionResult.FAIL;
}
else return ActionResult.FAIL;
return ActionResult.FAIL;
}
@Override
public BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
return super.getPlacementState(itemPlacementContext)
return Objects.requireNonNull(super.getPlacementState(itemPlacementContext))
.with(FACING, itemPlacementContext.getPlayerFacing())
.with(PART, Part.BACK);
}
@Override
public void onPlaced(World arg, BlockPos pos, BlockState state, LivingEntity arg4, ItemStack arg5) {
switch (state.get(PART)) {
case BACK: switch (state.get(FACING)) {
if (state.get(PART) == Part.BACK) {
switch (state.get(FACING)) {
case NORTH:
if (!arg.getBlockState(pos.north()).isAir()) {
arg.breakBlock(pos, true);
} else {
arg.setBlockState(pos.north(), state.with(PART, Part.FRONT).with(FACING, Direction.NORTH));
}
else {
arg.setBlockState(pos.north(), state.with(PART, Part.FRONT).with(FACING, Direction.NORTH));
}
return;
case EAST:
if (!arg.getBlockState(pos.east()).isAir()) {
arg.breakBlock(pos, true);
} else {
arg.setBlockState(pos.east(), state.with(PART, Part.FRONT).with(FACING, Direction.EAST));
}
else {
arg.setBlockState(pos.east(), state.with(PART, Part.FRONT).with(FACING, Direction.EAST));
}
return;
case SOUTH:
if (!arg.getBlockState(pos.south()).isAir()) {
arg.breakBlock(pos, true);
} else {
arg.setBlockState(pos.south(), state.with(PART, Part.FRONT).with(FACING, Direction.SOUTH));
}
else {
arg.setBlockState(pos.south(), state.with(PART, Part.FRONT).with(FACING, Direction.SOUTH));
}
return;
case WEST:
if (!arg.getBlockState(pos.west()).isAir()) {
arg.breakBlock(pos, true);
} else {
arg.setBlockState(pos.west(), state.with(PART, Part.FRONT).with(FACING, Direction.WEST));
}
else {
arg.setBlockState(pos.west(), state.with(PART, Part.FRONT).with(FACING, Direction.WEST));
}
return;
default:
return;
}
default: return;
}
}
@Override
@@ -113,37 +99,23 @@ public class Springboard extends HorizontalFacingBlock {
case BACK: switch (state.get(FACING)) {
case NORTH:
if (world.getBlockState(pos.north()).contains(PART)) { world.breakBlock(pos.north(), true);}
return;
case EAST:
if (world.getBlockState(pos.east()).contains(PART)) { world.breakBlock(pos.east(), true);}
return;
case SOUTH:
if (world.getBlockState(pos.south()).contains(PART)) { world.breakBlock(pos.south(), true);}
return;
case WEST:
if (world.getBlockState(pos.west()).contains(PART)) { world.breakBlock(pos.west(), true);}
return;
default:
return;
}
case FRONT: switch (state.get(FACING)) {
case NORTH:
if (world.getBlockState(pos.south()).contains(PART)) { world.breakBlock(pos.south(), true); }
return;
case EAST:
if (world.getBlockState(pos.west()).contains(PART)) { world.breakBlock(pos.south(), true); }
return;
case SOUTH:
if (world.getBlockState(pos.north()).contains(PART)) { world.breakBlock(pos.south(), true); }
return;
case WEST:
if (world.getBlockState(pos.east()).contains(PART)) { world.breakBlock(pos.south(), true); }
return;
default:
return;
}
default: return;
}
}
@@ -154,13 +126,25 @@ public class Springboard extends HorizontalFacingBlock {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
switch (state.get(FACING)) {
case NORTH: switch (state.get(PART)) { case FRONT: return NORTH_SHAPE_FRONT; case BACK: return NORTH_SHAPE_BACK;}
case EAST: switch (state.get(PART)) { case FRONT: return EAST_SHAPE_FRONT; case BACK: return EAST_SHAPE_BACK;}
case SOUTH: switch (state.get(PART)) { case FRONT: return SOUTH_SHAPE_FRONT; case BACK: return SOUTH_SHAPE_BACK;}
case WEST: switch (state.get(PART)) { case FRONT: return WEST_SHAPE_FRONT; case BACK: return WEST_SHAPE_BACK;}
default: return super.getOutlineShape(state, view, pos, context);
}
return switch (state.get(FACING)) {
case NORTH -> switch (state.get(PART)) {
case FRONT -> NORTH_SHAPE_FRONT;
case BACK -> NORTH_SHAPE_BACK;
};
case EAST -> switch (state.get(PART)) {
case FRONT -> EAST_SHAPE_FRONT;
case BACK -> EAST_SHAPE_BACK;
};
case SOUTH -> switch (state.get(PART)) {
case FRONT -> SOUTH_SHAPE_FRONT;
case BACK -> SOUTH_SHAPE_BACK;
};
case WEST -> switch (state.get(PART)) {
case FRONT -> WEST_SHAPE_FRONT;
case BACK -> WEST_SHAPE_BACK;
};
default -> super.getOutlineShape(state, view, pos, context);
};
}
static {
//long_plank

View File

@@ -24,9 +24,7 @@ public class StonePath extends Block {
return SHAPE;
}
static {
VoxelShape shape = createCuboidShape(0, 0, 0, 16, 1, 16);
SHAPE = shape;
SHAPE = createCuboidShape(0, 0, 0, 16, 1, 16);
}
public boolean canPlaceAt(BlockState state, WorldView worldView, BlockPos pos) {

View File

@@ -23,6 +23,7 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import java.util.Objects;
import java.util.function.ToIntFunction;
public class Television extends HorizontalFacingBlock {
@@ -39,29 +40,39 @@ public class Television extends HorizontalFacingBlock {
}
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
switch (state.get(PROGRAM)) {
case OFF: world.setBlockState(pos, state.with(PROGRAM, Program.NYANCAT));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 1.5f);
return ActionResult.SUCCESS;
case NYANCAT: world.setBlockState(pos, state.with(PROGRAM, Program.CREEPER));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 1.5f);
return ActionResult.SUCCESS;
case CREEPER: world.setBlockState(pos, state.with(PROGRAM, Program.CRABRAVE));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 1.5f);
return ActionResult.SUCCESS;
case CRABRAVE: world.setBlockState(pos, state.with(PROGRAM, Program.TATER));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 1.5f);
return ActionResult.SUCCESS;
case TATER: world.setBlockState(pos, state.with(PROGRAM, Program.OFF));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 1.5f);
return ActionResult.SUCCESS;
switch (state.get(PROGRAM)) {
case OFF -> {
world.setBlockState(pos, state.with(PROGRAM, Program.NYANCAT));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 1.5f);
return ActionResult.SUCCESS;
}
case NYANCAT -> {
world.setBlockState(pos, state.with(PROGRAM, Program.CREEPER));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 1.5f);
return ActionResult.SUCCESS;
}
case CREEPER -> {
world.setBlockState(pos, state.with(PROGRAM, Program.CRABRAVE));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 1.5f);
return ActionResult.SUCCESS;
}
case CRABRAVE -> {
world.setBlockState(pos, state.with(PROGRAM, Program.TATER));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 1.5f);
return ActionResult.SUCCESS;
}
case TATER -> {
world.setBlockState(pos, state.with(PROGRAM, Program.OFF));
world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.2f, 1.5f);
return ActionResult.SUCCESS;
}
}
return ActionResult.SUCCESS;
}
@Override
public BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
return super.getPlacementState(itemPlacementContext)
return Objects.requireNonNull(super.getPlacementState(itemPlacementContext))
.with(FACING, itemPlacementContext.getPlayerFacing().getOpposite())
.with(PROGRAM, Program.OFF);
}
@@ -73,13 +84,13 @@ public class Television extends HorizontalFacingBlock {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
switch (state.get(FACING)) {
case NORTH: return NORTH_SHAPE;
case EAST: return EAST_SHAPE;
case SOUTH: return SOUTH_SHAPE;
case WEST: return WEST_SHAPE;
default: return super.getOutlineShape(state, view, pos, context);
}
return switch (state.get(FACING)) {
case NORTH -> NORTH_SHAPE;
case EAST -> EAST_SHAPE;
case SOUTH -> SOUTH_SHAPE;
case WEST -> WEST_SHAPE;
default -> super.getOutlineShape(state, view, pos, context);
};
}
static {
VoxelShape shape = createCuboidShape(-7, 4, 7, 22, 22, 9);

View File

@@ -20,9 +20,7 @@ public class TrafficCone extends Block {
return SHAPE;
}
static {
VoxelShape shape = createCuboidShape(4, 0, 4, 12, 11.5, 12);
SHAPE = shape;
SHAPE = createCuboidShape(4, 0, 4, 12, 11.5, 12);
}
public boolean canPlaceAt(BlockState state, WorldView worldView, BlockPos pos) {

View File

@@ -1,19 +1,28 @@
package eu.midnightdust.motschen.decorative.block;
import eu.midnightdust.motschen.decorative.block.blockentity.WallClockBlockEntity;
import eu.midnightdust.motschen.decorative.init.BlockEntities;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
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;
import org.jetbrains.annotations.Nullable;
public class WallClock extends HorizontalFacingBlock implements BlockEntityProvider {
import java.util.Objects;
public class WallClock extends BlockWithEntity implements BlockEntityProvider {
private static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
private static final VoxelShape NORTH_SHAPE;
private static final VoxelShape EAST_SHAPE;
private static final VoxelShape SOUTH_SHAPE;
@@ -25,8 +34,17 @@ public class WallClock extends HorizontalFacingBlock implements BlockEntityProvi
}
@Override
public BlockEntity createBlockEntity(BlockView view) {
return new WallClockBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new WallClockBlockEntity(pos, state);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, BlockEntities.WallClockBlockEntity, WallClockBlockEntity::tick);
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
@@ -36,27 +54,27 @@ public class WallClock extends HorizontalFacingBlock implements BlockEntityProvi
@Override
public BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
return super.getPlacementState(itemPlacementContext)
return Objects.requireNonNull(super.getPlacementState(itemPlacementContext))
.with(FACING, itemPlacementContext.getPlayerFacing().getOpposite());
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
switch (state.get(FACING)) {
case NORTH: return NORTH_SHAPE;
case EAST: return EAST_SHAPE;
case SOUTH: return SOUTH_SHAPE;
case WEST: return WEST_SHAPE;
default: return super.getOutlineShape(state, view, pos, context);
}
return switch (state.get(FACING)) {
case NORTH -> NORTH_SHAPE;
case EAST -> EAST_SHAPE;
case SOUTH -> SOUTH_SHAPE;
case WEST -> WEST_SHAPE;
default -> super.getOutlineShape(state, view, pos, context);
};
}
static {
VoxelShape shape = createCuboidShape(0, 0, 15, 16, 16, 16);
NORTH_SHAPE = shape;
WEST_SHAPE = rotate(Direction.EAST, Direction.NORTH, shape);
EAST_SHAPE = rotate(Direction.EAST, Direction.SOUTH, shape);
SOUTH_SHAPE = rotate(Direction.EAST, Direction.WEST, shape);
WEST_SHAPE = rotate(Direction.NORTH, Direction.WEST, shape);
EAST_SHAPE = rotate(Direction.NORTH, Direction.EAST, shape);
SOUTH_SHAPE = rotate(Direction.NORTH, Direction.SOUTH, shape);
}
private static VoxelShape rotate(Direction from, Direction to, VoxelShape shape) {
VoxelShape[] buffer = new VoxelShape[]{ shape, VoxelShapes.empty() };

View File

@@ -19,6 +19,8 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import java.util.Objects;
public class WaterPump extends HorizontalFacingBlock {
private static final VoxelShape NORTH_SHAPE;
private static final VoxelShape EAST_SHAPE;
@@ -34,30 +36,19 @@ public class WaterPump extends HorizontalFacingBlock {
if (!itemStack.isEmpty() && hand==Hand.MAIN_HAND) {
if (itemStack.getItem() == Items.BUCKET) {
if (!world.isClient) {
if (!player.abilities.creativeMode) {
itemStack.decrement(1);
if (itemStack.isEmpty()) {
player.setStackInHand(hand, new ItemStack(Items.WATER_BUCKET));
} else if (!player.inventory.insertStack(new ItemStack(Items.WATER_BUCKET))) {
player.dropItem(new ItemStack(Items.WATER_BUCKET), false);
}
}
ItemUsage.exchangeStack(itemStack, player, new ItemStack(Items.BUCKET));
world.playSound(null, pos, SoundEvents.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
return ActionResult.SUCCESS;
}
else {
return ActionResult.PASS;
}
}
if (itemStack.isEmpty()) {
return ActionResult.PASS;
} return ActionResult.PASS;
}
return ActionResult.PASS;
}
@Override
public BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
return super.getPlacementState(itemPlacementContext)
return Objects.requireNonNull(super.getPlacementState(itemPlacementContext))
.with(FACING, itemPlacementContext.getPlayerFacing().getOpposite());
}
@@ -67,13 +58,13 @@ public class WaterPump extends HorizontalFacingBlock {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
switch (state.get(FACING)) {
case NORTH: return NORTH_SHAPE;
case EAST: return EAST_SHAPE;
case SOUTH: return SOUTH_SHAPE;
case WEST: return WEST_SHAPE;
default: return super.getOutlineShape(state, view, pos, context);
}
return switch (state.get(FACING)) {
case NORTH -> NORTH_SHAPE;
case EAST -> EAST_SHAPE;
case SOUTH -> SOUTH_SHAPE;
case WEST -> WEST_SHAPE;
default -> super.getOutlineShape(state, view, pos, context);
};
}
static {
VoxelShape shape = createCuboidShape(4.25, 0, 0, 11.75, 24, 14);

View File

@@ -5,55 +5,45 @@ import eu.midnightdust.motschen.decorative.DecorativeMain;
import eu.midnightdust.motschen.decorative.init.BlockEntities;
import eu.midnightdust.motschen.decorative.sound.DecorativeSoundEvents;
import net.minecraft.block.BlockState;
import net.minecraft.block.BrewingStandBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BrewingStandBlockEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.time.LocalTime;
public class CeilingFanBlockEntity extends BlockEntity implements Tickable {
public class CeilingFanBlockEntity extends BlockEntity {
private int rot;
private int second;
public CeilingFanBlockEntity() {
super(BlockEntities.CeilingFanBlockEntity);
public CeilingFanBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntities.CeilingFanBlockEntity, pos, state);
}
@Override
public void tick() {
BlockPos pos = this.pos;
BlockState state = this.world.getBlockState(pos);
if (world != null && state.get(DecorativeMain.STAGE) == CeilingFanStage.LEVEL_1) {
if (LocalTime.now().getSecond() != second) {
second = LocalTime.now().getSecond();
public static void tick(World world, BlockPos pos, BlockState state, CeilingFanBlockEntity blockEntity) {
if (state.get(DecorativeMain.STAGE) == CeilingFanStage.LEVEL_1) {
if (LocalTime.now().getSecond() != blockEntity.second) {
blockEntity.second = LocalTime.now().getSecond();
world.playSound(null,pos, DecorativeSoundEvents.CEILINGFAN_AMBIENT, SoundCategory.BLOCKS, 0.1f, 1.0f);
}
rot = rot + 6;
return;
blockEntity.rot = blockEntity.rot + 6;
}
if (world != null && state.get(DecorativeMain.STAGE) == CeilingFanStage.LEVEL_2) {
if (LocalTime.now().getSecond() != second) {
second = LocalTime.now().getSecond();
else if (state.get(DecorativeMain.STAGE) == CeilingFanStage.LEVEL_2) {
if (LocalTime.now().getSecond() != blockEntity.second) {
blockEntity.second = LocalTime.now().getSecond();
world.playSound(null,pos, DecorativeSoundEvents.CEILINGFAN_AMBIENT, SoundCategory.BLOCKS, 0.2f, 1.0f);
}
rot = rot + 10;
return;
blockEntity.rot = blockEntity.rot + 10;
}
if (world != null && state.get(DecorativeMain.STAGE) == CeilingFanStage.LEVEL_3) {
if (LocalTime.now().getSecond() != second) {
second = LocalTime.now().getSecond();
else if (state.get(DecorativeMain.STAGE) == CeilingFanStage.LEVEL_3) {
if (LocalTime.now().getSecond() != blockEntity.second) {
blockEntity.second = LocalTime.now().getSecond();
world.playSound(null,pos, DecorativeSoundEvents.CEILINGFAN_AMBIENT, SoundCategory.BLOCKS, 0.3f, 1.0f);
}
rot = rot + 14;
return;
}
else {
return;
blockEntity.rot = blockEntity.rot + 14;
}
}
public int getRot() {

View File

@@ -4,48 +4,40 @@ import eu.midnightdust.motschen.decorative.init.BlockEntities;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Tickable;
import net.minecraft.block.entity.JukeboxBlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
public class ChoppingLogBlockEntity extends BlockEntity implements Tickable {
public class ChoppingLogBlockEntity extends BlockEntity {
private int facing;
private double axe_x;
private double axe_z;
public ChoppingLogBlockEntity() {
super(BlockEntities.ChoppingLogBlockEntity);
public ChoppingLogBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntities.ChoppingLogBlockEntity, pos, state);
}
@Override
public void tick() {
BlockPos pos = this.pos;
BlockState state = this.world.getBlockState(pos);
if (world != null && state.get(HorizontalFacingBlock.FACING) == Direction.EAST) {
facing = 180;
axe_x = 0.2D;
axe_z = 0.5D;
return;
public static void tick(World world, BlockPos pos, BlockState state, ChoppingLogBlockEntity blockEntity) {
if (state.get(HorizontalFacingBlock.FACING) == Direction.EAST) {
blockEntity.facing = 180;
blockEntity.axe_x = 0.2D;
blockEntity.axe_z = 0.5D;
}
if (world != null && state.get(HorizontalFacingBlock.FACING) == Direction.SOUTH) {
facing = 90;
axe_x = 0.5D;
axe_z = 0.2D;
return;
else if (state.get(HorizontalFacingBlock.FACING) == Direction.SOUTH) {
blockEntity.facing = 90;
blockEntity.axe_x = 0.5D;
blockEntity.axe_z = 0.2D;
}
if (world != null && state.get(HorizontalFacingBlock.FACING) == Direction.WEST) {
facing = 0;
axe_x = 0.8D;
axe_z = 0.5D;
return;
else if (state.get(HorizontalFacingBlock.FACING) == Direction.WEST) {
blockEntity.facing = 0;
blockEntity.axe_x = 0.8D;
blockEntity.axe_z = 0.5D;
}
else {
facing = 270;
axe_x = 0.5D;
axe_z = 0.8D;
return;
blockEntity.facing = 270;
blockEntity.axe_x = 0.5D;
blockEntity.axe_z = 0.8D;
}
}

View File

@@ -4,57 +4,52 @@ import eu.midnightdust.motschen.decorative.init.BlockEntities;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import java.time.LocalTime;
public class DigitalClockBlockEntity extends BlockEntity implements Tickable {
public class DigitalClockBlockEntity extends BlockEntity {
private int facing;
private double x;
private double z;
private int second;
public DigitalClockBlockEntity() {
super(BlockEntities.DigitalClockBlockEntity);
public DigitalClockBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntities.DigitalClockBlockEntity, pos, state);
}
@Override
public void tick() {
if (LocalTime.now().getSecond() != second) {
second = LocalTime.now().getSecond();
public static void tick(World world, BlockPos pos, BlockState state, DigitalClockBlockEntity blockEntity) {
if (LocalTime.now().getSecond() != blockEntity.second) {
blockEntity.second = LocalTime.now().getSecond();
}
BlockPos pos = this.pos;
BlockState state = this.world.getBlockState(pos);
if (world != null && state.get(HorizontalFacingBlock.FACING) == Direction.EAST) {
facing = 270;
x = 0.626;
z = 0.825;
return;
switch (state.get(HorizontalFacingBlock.FACING)) {
case NORTH: {
blockEntity.facing = 0;
blockEntity.x = 0.825;
blockEntity.z = 0.374;
break;
}
case EAST:{
blockEntity.facing = 270;
blockEntity.x = 0.626;
blockEntity.z = 0.825;
break;
}
case SOUTH:{
blockEntity.facing = 180;
blockEntity.x = 0.175;
blockEntity.z = 0.626;
break;
}
case WEST:{
blockEntity.facing = 90;
blockEntity.x = 0.374;
blockEntity.z = 0.175;
break;
}
default: break;
}
if (world != null && state.get(HorizontalFacingBlock.FACING) == Direction.SOUTH) {
facing = 180;
x = 0.175;
z = 0.626;
return;
}
if (world != null && state.get(HorizontalFacingBlock.FACING) == Direction.WEST) {
facing = 90;
x = 0.374;
z = 0.175;
return;
}
else {
facing = 0;
x = 0.825;
z = 0.374;
return;
}
}
public int getFacing() {
return facing;

View File

@@ -5,37 +5,23 @@ import eu.midnightdust.motschen.decorative.init.BlockEntities;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class PoolSprinklerBlockEntity extends BlockEntity implements Tickable {
public class PoolSprinklerBlockEntity extends BlockEntity {
public PoolSprinklerBlockEntity() {
super(BlockEntities.PoolSprinklerBlockEntity);
public PoolSprinklerBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntities.PoolSprinklerBlockEntity, pos, state);
}
@Override
public void tick() {
BlockPos pos = this.pos;
if (world != null) {
BlockState state = this.world.getBlockState(pos);
if (state.get(PoolSprinkler.POWERED)) {
switch (state.get(PoolSprinkler.FACING)) {
case NORTH:
world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() - 0.34, 1, 1, 1);
return;
case EAST:
world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 1.34, pos.getY() + 0.5, pos.getZ() + 0.5, 1, 1, 1);
return;
case SOUTH:
world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 1.34, 1, 1, 1);
return;
case WEST:
world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() - 0.34, pos.getY() + 0.5, pos.getZ() + 0.5, 1, 1, 1);
return;
default:
return;
}
public static void tick(World world, BlockPos pos, BlockState state, PoolSprinklerBlockEntity blockEntity) {
if (state.get(PoolSprinkler.POWERED)) {
switch (state.get(PoolSprinkler.FACING)) {
case NORTH: world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() - 0.34, 1, 1, 1); break;
case EAST: world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 1.34, pos.getY() + 0.5, pos.getZ() + 0.5, 1, 1, 1); break;
case SOUTH: world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 1.34, 1, 1, 1); break;
case WEST: world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() - 0.34, pos.getY() + 0.5, pos.getZ() + 0.5, 1, 1, 1); break;
default: break;
}
}
}

View File

@@ -5,38 +5,25 @@ import eu.midnightdust.motschen.decorative.init.BlockEntities;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class ShowerHeadBlockEntity extends BlockEntity implements Tickable {
public class ShowerHeadBlockEntity extends BlockEntity {
public ShowerHeadBlockEntity() {
super(BlockEntities.ShowerHeadBlockEntity);
public ShowerHeadBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntities.ShowerHeadBlockEntity, pos, state);
}
@Override
public void tick() {
BlockPos pos = this.pos;
if (world != null) {
BlockState state = this.world.getBlockState(pos);
if (state.get(PoolSprinkler.POWERED) == true) {
switch (state.get(PoolSprinkler.FACING)) {
case NORTH:
world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.625, 1, 1, 1);
return;
case EAST:
world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.375, pos.getY() + 0.5, pos.getZ() + 0.5, 1, 1, 1);
return;
case SOUTH:
world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.375, 1, 1, 1);
return;
case WEST:
world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.625, pos.getY() + 0.5, pos.getZ() + 0.5, 1, 1, 1);
return;
default:
return;
}
public static void tick(World world, BlockPos pos, BlockState state, ShowerHeadBlockEntity blockEntity) {
if (state.get(PoolSprinkler.POWERED)) {
switch (state.get(PoolSprinkler.FACING)) {
case NORTH: world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.625, 1, 1, 1); break;
case EAST: world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.375, pos.getY() + 0.5, pos.getZ() + 0.5, 1, 1, 1); break;
case SOUTH: world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.375, 1, 1, 1); break;
case WEST: world.addParticle(ParticleTypes.DRIPPING_WATER, pos.getX() + 0.625, pos.getY() + 0.5, pos.getZ() + 0.5, 1, 1, 1); break;
default: break;
}
}
}
}

View File

@@ -6,66 +6,54 @@ import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import java.time.LocalTime;
public class WallClockBlockEntity extends BlockEntity implements Tickable {
private int facing;
private double x;
private double z;
private int second;
public class WallClockBlockEntity extends BlockEntity {
public int facing;
public double x;
public double z;
public int second;
public WallClockBlockEntity() {
super(BlockEntities.WallClockBlockEntity);
public WallClockBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntities.WallClockBlockEntity, pos, state);
}
@Override
public void tick() {
if (LocalTime.now().getSecond() != second) {
second = LocalTime.now().getSecond();
world.playSound(null, pos, SoundEvents.BLOCK_WOODEN_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.004f, 1f);
public static void tick(World world, BlockPos pos, BlockState state, WallClockBlockEntity blockEntity) {
if (LocalTime.now().getSecond() != blockEntity.second) {
blockEntity.second = LocalTime.now().getSecond();
world.playSound(null, pos, SoundEvents.BLOCK_WOODEN_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.04f, 1f);
}
BlockPos pos = this.pos;
BlockState state = this.world.getBlockState(pos);
if (world != null && state.get(HorizontalFacingBlock.FACING) == Direction.EAST) {
facing = 270;
x = 0.05;
z = 0.5;
return;
switch (state.get(HorizontalFacingBlock.FACING)) {
case NORTH: {
blockEntity.facing = 0;
blockEntity.x = 0.5;
blockEntity.z = 0.95;
break;
}
case EAST: {
blockEntity.facing = 270;
blockEntity.x = 0.05;
blockEntity.z = 0.5;
break;
}
case SOUTH: {
blockEntity.facing = 180;
blockEntity.x = 0.5;
blockEntity.z = 0.05;
break;
}
case WEST: {
blockEntity.facing = 90;
blockEntity.x = 0.95;
blockEntity.z = 0.5;
break;
}
default: break;
}
if (world != null && state.get(HorizontalFacingBlock.FACING) == Direction.SOUTH) {
facing = 180;
x = 0.5;
z = 0.05;
return;
}
if (world != null && state.get(HorizontalFacingBlock.FACING) == Direction.WEST) {
facing = 90;
x = 0.95;
z = 0.5;
return;
}
else {
facing = 0;
x = 0.5;
z = 0.95;
return;
}
}
public int getFacing() {
return facing;
}
public double getX() {
return x;
}
public double getZ() {
return z;
}
}

View File

@@ -1,50 +1,40 @@
package eu.midnightdust.motschen.decorative.block.render;
import eu.midnightdust.motschen.decorative.block.blockentity.CeilingFanBlockEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class CeilingFanRenderer extends BlockEntityRenderer<CeilingFanBlockEntity> {
private final ModelPart blades;
private final ModelPart point;
public CeilingFanRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
super(blockEntityRenderDispatcher);
blades = new ModelPart(64, 64, 0, 0);
blades.setPivot(0.0F, 0.0F, 0.0F);
blades.addCuboid(-1.0F, 0.0F, 1.0F, 2.0F, 1.0F, 10.0F, 0.0F);
blades.addCuboid(-1.0F, 0.0F, -11.0F, 2.0F, 1.0F, 10.0F, 0.0F);
blades.addCuboid(1.0F, 0.0F, -1.0F, 10.0F, 1.0F, 2.0F, 0.0F);
blades.addCuboid(-11.0F, 0.0F, -1.0F, 10.0F, 1.0F, 2.0F, 0.0F);
point = new ModelPart(32, 32, 16, 0);
point.addCuboid(-1.0F, -1.0F, -1.0F, 2.0F, 2.0F, 2.0F, 0.0F);
blades.addChild(point);
}
@Override
public boolean rendersOutsideBoundingBox(CeilingFanBlockEntity blockEntity) {
return true;
}
@Override
public void render(CeilingFanBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
matrices.push();
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCull(new Identifier("decorative:textures/block/ceilingfan.png")));
matrices.translate(0.5,0.31,0.5);
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.getRot()));
blades.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrices.pop();
}
}
package eu.midnightdust.motschen.decorative.block.render;
import eu.midnightdust.motschen.decorative.block.blockentity.CeilingFanBlockEntity;
import eu.midnightdust.motschen.decorative.block.render.model.CeilingFanBladesModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
@Environment(EnvType.CLIENT)
public class CeilingFanRenderer implements BlockEntityRenderer<CeilingFanBlockEntity> {
private final CeilingFanBladesModel blades;
public CeilingFanRenderer(BlockEntityRendererFactory.Context ctx) {
blades = new CeilingFanBladesModel(ctx.getLayerModelPart(CeilingFanBladesModel.CEILING_FAN_MODEL_LAYER));
}
@Override
public boolean rendersOutsideBoundingBox(CeilingFanBlockEntity blockEntity) {
return true;
}
@Override
public void render(CeilingFanBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
matrices.push();
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCull(new Identifier("decorative:textures/block/ceilingfan.png")));
matrices.translate(0.5,0.31,0.5);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.getRot()));
blades.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrices.pop();
}
}

View File

@@ -1,40 +1,40 @@
package eu.midnightdust.motschen.decorative.block.render;
import eu.midnightdust.motschen.decorative.block.blockentity.ChoppingLogBlockEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.*;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
@Environment(EnvType.CLIENT)
public class ChoppingLogBlockEntityRenderer extends BlockEntityRenderer<ChoppingLogBlockEntity> {
public ChoppingLogBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
super(blockEntityRenderDispatcher);
}
@Override
public boolean rendersOutsideBoundingBox(ChoppingLogBlockEntity blockEntity) {
return true;
}
@Override
public void render(ChoppingLogBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
matrices.push();
int lightAbove = WorldRenderer.getLightmapCoordinates(blockEntity.getWorld(), blockEntity.getPos().up());
matrices.translate(blockEntity.getAxeX(), 1.5D, blockEntity.getAxeZ());
matrices.scale(2.5f,2.5f,2.5f);
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.getFacing()));
matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(160));
MinecraftClient.getInstance().getItemRenderer().renderItem(new ItemStack(Items.IRON_AXE), ModelTransformation.Mode.GROUND, lightAbove, overlay, matrices, vertexConsumers);
matrices.pop();
}
}
package eu.midnightdust.motschen.decorative.block.render;
import eu.midnightdust.motschen.decorative.block.blockentity.ChoppingLogBlockEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.*;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.math.Vec3f;
import java.util.Objects;
@Environment(EnvType.CLIENT)
public class ChoppingLogBlockEntityRenderer implements BlockEntityRenderer<ChoppingLogBlockEntity> {
public ChoppingLogBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) {
}
@Override
public boolean rendersOutsideBoundingBox(ChoppingLogBlockEntity blockEntity) {
return true;
}
@Override
public void render(ChoppingLogBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
matrices.push();
int lightAbove = WorldRenderer.getLightmapCoordinates(Objects.requireNonNull(blockEntity.getWorld()), blockEntity.getPos().up());
matrices.translate(blockEntity.getAxeX(), 1.5D, blockEntity.getAxeZ());
matrices.scale(2.5f,2.5f,2.5f);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.getFacing()));
matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(160));
MinecraftClient.getInstance().getItemRenderer().renderItem(new ItemStack(Items.IRON_AXE), ModelTransformation.Mode.GROUND, lightAbove, overlay, matrices, vertexConsumers, 0);
matrices.pop();
}
}

View File

@@ -1,77 +1,77 @@
package eu.midnightdust.motschen.decorative.block.render;
import eu.midnightdust.motschen.decorative.DecorativeMain;
import eu.midnightdust.motschen.decorative.block.blockentity.DigitalClockBlockEntity;
import eu.midnightdust.motschen.decorative.config.DecorativeConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.*;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import java.time.LocalTime;
@Environment(EnvType.CLIENT)
public class DigitalClockRenderer extends BlockEntityRenderer<DigitalClockBlockEntity> {
public DigitalClockRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
super(blockEntityRenderDispatcher);
}
private int getHour12hFormat() {
int hour;
hour = LocalTime.now().getHour();
if (hour > 12) {
hour = hour - 12;
}
return hour;
}
private String getTime() {
String hour;
String minute;
// Hour
if (DecorativeMain.DECORATIVE_CONFIG.timeFormat.equals(DecorativeConfig.TimeFormat.h12)) {
if (getHour12hFormat() <= 9) {
hour = "0" + getHour12hFormat();
} else {
hour = "" + getHour12hFormat();
}
}
else {
if (LocalTime.now().getHour() <= 9) {
hour = "0" + LocalTime.now().getHour();
} else {
hour = "" + LocalTime.now().getHour();
}
}
// Minute
if (LocalTime.now().getMinute() <= 9) {
minute = "0" + LocalTime.now().getMinute();
}
else {
minute = "" + LocalTime.now().getMinute();
}
String time = hour +":"+ minute;
return time;
}
@Override
public void render(DigitalClockBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
matrices.push();
TextRenderer textRenderer = dispatcher.getTextRenderer();
matrices.translate(blockEntity.getX(),0.35,blockEntity.getZ());
matrices.scale(0.025f, 0.025f, 0.025f);
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.getFacing()));
matrices.translate(0,0,-0.1);
matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180));
textRenderer.draw(getTime(), 0, 0, 16382457, false, matrices.peek().getModel(), vertexConsumers, false, 0, 15);
matrices.pop();
}
package eu.midnightdust.motschen.decorative.block.render;
import eu.midnightdust.motschen.decorative.DecorativeMain;
import eu.midnightdust.motschen.decorative.block.blockentity.DigitalClockBlockEntity;
import eu.midnightdust.motschen.decorative.config.DecorativeConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.*;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3f;
import java.time.LocalTime;
@Environment(EnvType.CLIENT)
public class DigitalClockRenderer implements BlockEntityRenderer<DigitalClockBlockEntity> {
private final TextRenderer textRenderer;
public DigitalClockRenderer(BlockEntityRendererFactory.Context ctx) {
textRenderer = ctx.getTextRenderer();
}
private int getHour12hFormat() {
int hour;
hour = LocalTime.now().getHour();
if (hour > 12) {
hour = hour - 12;
}
return hour;
}
private String getTime() {
String hour;
String minute;
// Hour
if (DecorativeConfig.timeFormat.equals(DecorativeConfig.TimeFormat.h12)) {
if (getHour12hFormat() <= 9) {
hour = "0" + getHour12hFormat();
} else {
hour = "" + getHour12hFormat();
}
}
else {
if (LocalTime.now().getHour() <= 9) {
hour = "0" + LocalTime.now().getHour();
} else {
hour = "" + LocalTime.now().getHour();
}
}
// Minute
if (LocalTime.now().getMinute() <= 9) {
minute = "0" + LocalTime.now().getMinute();
}
else {
minute = "" + LocalTime.now().getMinute();
}
return hour +":"+ minute;
}
@Override
public void render(DigitalClockBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
matrices.push();
matrices.translate(blockEntity.getX(),0.35,blockEntity.getZ());
matrices.scale(0.025f, 0.025f, 0.025f);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.getFacing()));
matrices.translate(0,0,-0.1);
matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(180));
textRenderer.draw(getTime(), 0, 0, 16382457, false, matrices.peek().getModel(), vertexConsumers, false, 0, light);
matrices.pop();
}
}

View File

@@ -1,77 +1,58 @@
package eu.midnightdust.motschen.decorative.block.render;
import eu.midnightdust.motschen.decorative.block.blockentity.WallClockBlockEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.*;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.Identifier;
import java.time.LocalTime;
@Environment(EnvType.CLIENT)
public class WallClockRenderer extends BlockEntityRenderer<WallClockBlockEntity> {
private final ModelPart blades;
private final ModelPart seconds;
private final ModelPart minutes;
private final ModelPart hours;
public WallClockRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
super(blockEntityRenderDispatcher);
blades = new ModelPart(16, 16, 0, 0);
blades.setPivot(0.0F, 0.0F, 0.0F);
seconds = new ModelPart(16, 16, 8, 0);
seconds.addCuboid(-0.175F, 0.0F, 0.01F, 0.25F, 7.0F, 0.2F, 0.0F);
blades.addChild(seconds);
minutes = new ModelPart(16, 16, 0, 0);
minutes.addCuboid(-0.25F, 0.0F, 0.0F, 0.5F, 6.0F, 0.2F, 0.0F);
blades.addChild(minutes);
hours = new ModelPart(16, 16, 0, 0);
hours.addCuboid(-0.25F, 0.0F, 0.0F, 0.5F, 4.0F, 0.2F, 0.0F);
blades.addChild(hours);
}
private int getHour12hFormat() {
int hour;
hour = LocalTime.now().getHour();
if (hour >= 12) {
hour = hour - 12;
}
return hour;
}
@Override
public void render(WallClockBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
VertexConsumer blackVertex = vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCull(new Identifier("textures/block/black_concrete.png")));
VertexConsumer redVertex = vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCull(new Identifier("textures/block/red_concrete.png")));
matrices.push();
matrices.translate(blockEntity.getX(),0.5,blockEntity.getZ());
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.getFacing()));
matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(LocalTime.now().getSecond() * 6));
seconds.render(matrices, redVertex, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrices.pop();
matrices.push();
matrices.translate(blockEntity.getX(),0.5,blockEntity.getZ());
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.getFacing()));
matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(LocalTime.now().getMinute() * 6));
minutes.render(matrices, blackVertex, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrices.pop();
matrices.push();
matrices.translate(blockEntity.getX(),0.5,blockEntity.getZ());
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.getFacing()));
matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(getHour12hFormat() * 30));
hours.render(matrices, blackVertex, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrices.pop();
}
}
package eu.midnightdust.motschen.decorative.block.render;
import eu.midnightdust.motschen.decorative.block.blockentity.WallClockBlockEntity;
import eu.midnightdust.motschen.decorative.block.render.model.WallClockHandsModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.*;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
import java.time.LocalTime;
@Environment(EnvType.CLIENT)
public class WallClockRenderer implements BlockEntityRenderer<WallClockBlockEntity> {
private final WallClockHandsModel handsModel;
public WallClockRenderer(BlockEntityRendererFactory.Context ctx) {
handsModel = new WallClockHandsModel(ctx.getLayerModelPart(WallClockHandsModel.CLOCK_HANDS_MODEL_LAYER));
}
private int getHour12hFormat() {
int hour;
hour = LocalTime.now().getHour();
if (hour >= 12) {
hour = hour - 12;
}
return hour;
}
@Override
public void render(WallClockBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
VertexConsumer vertex = vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCull(new Identifier("textures/block/red_concrete.png")));
matrices.push();
matrices.translate(blockEntity.x,0.5,blockEntity.z);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.facing));
matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(LocalTime.now().getSecond() * 6));
handsModel.seconds.render(matrices, vertex, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrices.pop();
matrices.push();
matrices.translate(blockEntity.x,0.5,blockEntity.z);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.facing));
matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(LocalTime.now().getMinute() * 6));
handsModel.minutes.render(matrices, vertex, light, OverlayTexture.DEFAULT_UV, 0.0F, 0.0F, 0.0F, 1.0F);
matrices.pop();
matrices.push();
matrices.translate(blockEntity.x,0.5,blockEntity.z);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(blockEntity.facing));
matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(getHour12hFormat() * 30));
handsModel.hours.render(matrices, vertex, light, OverlayTexture.DEFAULT_UV, 0.0F, 0.0F, 0.0F, 1.0F);
matrices.pop();
}
}

View File

@@ -0,0 +1,42 @@
package eu.midnightdust.motschen.decorative.block.render.model;
import net.minecraft.client.model.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
public class CeilingFanBladesModel extends Model {
private final ModelPart blades;
public static final EntityModelLayer CEILING_FAN_MODEL_LAYER = new EntityModelLayer(new Identifier("decorative", "ceiling_fan"), "main");
public CeilingFanBladesModel(ModelPart root) {
super(RenderLayer::getEntitySolid);
blades = root;
blades.setPivot(0.0F, 0.0F, 0.0F);
}
public ModelPart getPart() {
return blades;
}
public static TexturedModelData getTexturedModelData() {
return TexturedModelData.of(getModelData(), 64, 64);
}
public static ModelData getModelData() {
ModelData modelData = new ModelData();
ModelPartData modelPartData = modelData.getRoot();
modelPartData.addChild("blade1", ModelPartBuilder.create().cuboid(-1.0F, 0.0F, 1.0F, 2.0F, 1.0F, 10.0F), ModelTransform.NONE);
modelPartData.addChild("blade2", ModelPartBuilder.create().cuboid(-1.0F, 0.0F, -11.0F, 2.0F, 1.0F, 10.0F), ModelTransform.NONE);
modelPartData.addChild("blade3", ModelPartBuilder.create().cuboid(1.0F, 0.0F, -1.0F, 10.0F, 1.0F, 2.0F), ModelTransform.NONE);
modelPartData.addChild("blade4", ModelPartBuilder.create().cuboid(-11.0F, 0.0F, -1.0F, 10.0F, 1.0F, 2.0F), ModelTransform.NONE);
modelPartData.addChild("point", ModelPartBuilder.create().uv(32,0).cuboid(-1.0F, -1.0F, -1.0F, 2.0F, 2.0F, 2.0F), ModelTransform.NONE);
return modelData;
}
@Override
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
blades.render(matrices, vertices, light, overlay, red, green, blue, alpha);
}
}

View File

@@ -0,0 +1,47 @@
package eu.midnightdust.motschen.decorative.block.render.model;
import net.minecraft.client.model.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
public class WallClockHandsModel extends Model {
private final ModelPart hands;
public final ModelPart seconds;
public final ModelPart minutes;
public final ModelPart hours;
public static final EntityModelLayer CLOCK_HANDS_MODEL_LAYER = new EntityModelLayer(new Identifier("decorative", "clock_hands"), "main");
public WallClockHandsModel(ModelPart root) {
super(RenderLayer::getEntitySolid);
hands = root;
hands.setPivot(0.0F, 0.0F, 0.0F);
seconds = hands.getChild("seconds");//new ModelPart(16, 16, 8, 0);
minutes = hands.getChild("minutes");//new ModelPart(16, 16, 0, 0);
hours = hands.getChild("hours");//new ModelPart(16, 16, 0, 0);
}
public ModelPart getPart() {
return hands;
}
public static TexturedModelData getTexturedModelData() {
return TexturedModelData.of(getModelData(), 16, 16);
}
public static ModelData getModelData(){
ModelData modelData = new ModelData();
ModelPartData modelPartData = modelData.getRoot();
modelPartData.addChild("seconds", ModelPartBuilder.create().uv(0, 0).cuboid(-0.175F, 0.0F, 0.01F, 0.25F, 7.0F, 0.2F), ModelTransform.NONE);
modelPartData.addChild("minutes", ModelPartBuilder.create().uv(0, 0).cuboid(-0.25F, 0.0F, 0.0F, 0.5F, 6.0F, 0.2F), ModelTransform.NONE);
modelPartData.addChild("hours", ModelPartBuilder.create().uv(0, 0).cuboid(-0.25F, 0.0F, 0.0F, 0.5F, 4.0F, 0.2F), ModelTransform.NONE);
return modelData;
}
@Override
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
hands.render(matrices, vertices, light, overlay, red, green, blue, alpha);
}
}

View File

@@ -1,17 +1,13 @@
package eu.midnightdust.motschen.decorative.config;
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
@Config(name = "decorative")
public class DecorativeConfig implements ConfigData {
@Comment(value = "Change the time format")
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public TimeFormat timeFormat = TimeFormat.h12;
public enum TimeFormat {
h12, h24
}
}
package eu.midnightdust.motschen.decorative.config;
import eu.midnightdust.lib.config.MidnightConfig;
import java.util.TimeZone;
public class DecorativeConfig extends MidnightConfig {
@Entry public static TimeFormat timeFormat = TimeZone.getDefault().useDaylightTime() ? TimeFormat.h12 : TimeFormat.h24;
public enum TimeFormat {
h12, h24
}
}

View File

@@ -1,16 +1,16 @@
package eu.midnightdust.motschen.decorative.config;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> AutoConfig.getConfigScreen(DecorativeConfig.class, parent).get();
}
package eu.midnightdust.motschen.decorative.config;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import eu.midnightdust.lib.config.MidnightConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> MidnightConfig.getScreen(parent,"decorative");
}
}

View File

@@ -21,11 +21,6 @@ public class BathTireEntity extends PigEntity {
super(entityType, world);
}
@Override
protected int getCurrentExperience(PlayerEntity player) {
return 0;
}
@Override
protected SoundEvent getAmbientSound() {
return null;

View File

@@ -22,11 +22,6 @@ public class BeachBallEntity extends PigEntity {
super(entityType, world);
}
@Override
protected int getCurrentExperience(PlayerEntity player) {
return 0;
}
@Override
protected SoundEvent getAmbientSound() {
return null;
@@ -107,7 +102,7 @@ public class BeachBallEntity extends PigEntity {
public ActionResult interactAt(PlayerEntity player, Vec3d hitPos, Hand hand) {
if(!player.getEntityWorld().isClient && player.getStackInHand(hand)== ItemStack.EMPTY && hand==Hand.MAIN_HAND && player.isSneaking())
{
remove();
this.remove(RemovalReason.DISCARDED);
player.setStackInHand(hand, new ItemStack(Pool.BEACH_BALL_ITEM));
return ActionResult.SUCCESS;
}

View File

@@ -1,39 +1,44 @@
package eu.midnightdust.motschen.decorative.entity.client.model;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.model.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
public class BathTireModel extends EntityModel<BathTireEntity> {
private final ModelPart body;
public static final EntityModelLayer BATH_TIRE_MODEL_LAYER = new EntityModelLayer(new Identifier("decorative", "bath_tire"), "main");
public BathTireModel() {
textureWidth = 16;
textureHeight = 16;
body = new ModelPart(this);
public BathTireModel(ModelPart root) {
super(RenderLayer::getEntitySolid);
body = root;
body.setPivot(0.0F, 24.0F, 0.0F);
body.setTextureOffset(0, 0).addCuboid(6.0F, -9.0F, -11.0F, 4.0F, 4.0F, 16.0F, 0.0F, false);
body.setTextureOffset(0, 0).addCuboid(-10.0F, -9.0F, -11.0F, 4.0F, 4.0F, 16.0F, 0.0F, false);
body.setTextureOffset(0, 0).addCuboid(-8.0F, -8.99F, -13.0F, 16.0F, 4.0F, 4.0F, 0.0F, false);
body.setTextureOffset(0, 0).addCuboid(-8.0F, -8.99F, 3.0F, 16.0F, 4.0F, 4.0F, 0.0F, false);
}
public static TexturedModelData getTexturedModelData() {
return TexturedModelData.of(getModelData(), 16, 16);
}
public static ModelData getModelData(){
ModelData modelData = new ModelData();
ModelPartData modelPartData = modelData.getRoot();
modelPartData.addChild("cube1", ModelPartBuilder.create().cuboid(6.0F, -9.0F, -11.0F, 4.0F, 4.0F, 16.0F), ModelTransform.NONE);
modelPartData.addChild("cube2", ModelPartBuilder.create().cuboid(-10.0F, -9.0F, -11.0F, 4.0F, 4.0F, 16.0F), ModelTransform.NONE);
modelPartData.addChild("cube3", ModelPartBuilder.create().cuboid(-8.0F, -8.99F, -13.0F, 16.0F, 4.0F, 4.0F), ModelTransform.NONE);
modelPartData.addChild("cube4", ModelPartBuilder.create().cuboid(-8.0F, -8.99F, 3.0F, 16.0F, 4.0F, 4.0F), ModelTransform.NONE);
return modelData;
}
@Override
public void setAngles(BathTireEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){
//previously the render function, render code was moved to a method below
}
@Override
public void render(MatrixStack matrixStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
body.render(matrixStack, buffer, packedLight, packedOverlay);
}
public void setRotationAngle(ModelPart modelRenderer, float x, float y, float z) {
modelRenderer.pivotX = x;
modelRenderer.pivotY = y;
modelRenderer.pivotZ = z;
}
}

View File

@@ -1,27 +1,39 @@
package eu.midnightdust.motschen.decorative.entity.client.model;
import eu.midnightdust.motschen.decorative.entity.BeachBallEntity;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.model.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
public class BeachBallModel extends EntityModel<BeachBallEntity> {
private final ModelPart body;
public static final EntityModelLayer BEACH_BALL_MODEL_LAYER = new EntityModelLayer(new Identifier("decorative", "beach_ball"), "main");
public BeachBallModel() {
textureWidth = 64;
textureHeight = 64;
public BeachBallModel(ModelPart root) {
super(RenderLayer::getEntitySolid);
body = root;
body.setPivot(0.0F, 20.0F, 0.0F);
}
body = new ModelPart(this);
body.setPivot(0.0F, 24.0F, 0.0F);
body.setTextureOffset(0, 22).addCuboid(-4.0F, -1.0F, -4.0F, 8.0F, 1.0F, 8.0F, 0.0F, false);
body.setTextureOffset(0, 22).addCuboid(-4.0F, -12.0F, -4.0F, 8.0F, 1.0F, 8.0F, 0.0F, false);
body.setTextureOffset(0, 48).addCuboid(-6.0F, -10.0F, -4.0F, 1.0F, 8.0F, 8.0F, 0.0F, false);
body.setTextureOffset(20, 48).addCuboid(5.0F, -10.0F, -4.0F, 1.0F, 8.0F, 8.0F, 0.0F, false);
body.setTextureOffset(0, 33).addCuboid(-4.0F, -10.0F, -6.0F, 8.0F, 8.0F, 1.0F, 0.0F, false);
body.setTextureOffset(20, 33).addCuboid(-4.0F, -10.0F, 5.0F, 8.0F, 8.0F, 1.0F, 0.0F, false);
body.setTextureOffset(0, 0).addCuboid(-5.0F, -11.0F, -5.0F, 10.0F, 10.0F, 10.0F, 0.0F, false);
public static TexturedModelData getTexturedModelData() {
return TexturedModelData.of(getModelData(), 64, 64);
}
public static ModelData getModelData(){
ModelData modelData = new ModelData();
ModelPartData modelPartData = modelData.getRoot();
modelPartData.addChild("cube1", ModelPartBuilder.create().uv(0, 22).cuboid(-4.0F, -1.0F, -4.0F, 8.0F, 1.0F, 8.0F), ModelTransform.NONE);
modelPartData.addChild("cube2", ModelPartBuilder.create().uv(0, 22).cuboid(-4.0F, -12.0F, -4.0F, 8.0F, 1.0F, 8.0F), ModelTransform.NONE);
modelPartData.addChild("cube3", ModelPartBuilder.create().uv(0, 48).cuboid(-6.0F, -10.0F, -4.0F, 1.0F, 8.0F, 8.0F), ModelTransform.NONE);
modelPartData.addChild("cube4", ModelPartBuilder.create().uv(20, 48).cuboid(5.0F, -10.0F, -4.0F, 1.0F, 8.0F, 8.0F), ModelTransform.NONE);
modelPartData.addChild("cube5", ModelPartBuilder.create().uv(0, 33).cuboid(-4.0F, -10.0F, -6.0F, 8.0F, 8.0F, 1.0F), ModelTransform.NONE);
modelPartData.addChild("cube6", ModelPartBuilder.create().uv(20, 33).cuboid(-4.0F, -10.0F, 5.0F, 8.0F, 8.0F, 1.0F), ModelTransform.NONE);
modelPartData.addChild("cube7", ModelPartBuilder.create().uv(0,0).cuboid(-5.0F, -11.0F, -5.0F, 10.0F, 10.0F, 10.0F), ModelTransform.NONE);
return modelData;
}
@Override
@@ -33,10 +45,4 @@ public class BeachBallModel extends EntityModel<BeachBallEntity> {
public void render(MatrixStack matrixStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
body.render(matrixStack, buffer, packedLight, packedOverlay);
}
public void setRotationAngle(ModelPart modelRenderer, float x, float y, float z) {
modelRenderer.pivotX = x;
modelRenderer.pivotY = y;
modelRenderer.pivotZ = z;
}
}

View File

@@ -1,47 +1,53 @@
package eu.midnightdust.motschen.decorative.entity.client.model;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.model.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
public class DuckBathTireModel extends EntityModel<BathTireEntity> {
private final ModelPart body;
public static final EntityModelLayer DUCK_BATH_TIRE_MODEL_LAYER = new EntityModelLayer(new Identifier("decorative", "duck_bath_tire"), "main");
public DuckBathTireModel() {
textureWidth = 64;
textureHeight = 64;
public DuckBathTireModel(ModelPart root) {
super(RenderLayer::getEntitySolid);
body = root;
body.setPivot(0.0F, 20.0F, 0.0F);
}
body = new ModelPart(this);
body.setPivot(0.0F, 19.0F, 0.0F);
body.setTextureOffset(0, 9).addCuboid(6.0F, -3.0F, -8.0F, 4.0F, 3.0F, 16.0F, 0.0F, false);
body.setTextureOffset(0, 37).addCuboid(-10.0F, -3.0F, -8.0F, 4.0F, 3.0F, 16.0F, 0.0F, false);
body.setTextureOffset(0, 57).addCuboid(-8.0F, -2.99F, -10.0F, 16.0F, 3.0F, 4.0F, 0.0F, false);
body.setTextureOffset(0, 29).addCuboid(-8.0F, -2.99F, 6.0F, 16.0F, 3.0F, 4.0F, 0.0F, false);
body.setTextureOffset(50, 0).addCuboid(-2.0F, -8.0F, -10.0F, 4.0F, 5.0F, 3.0F, 0.0F, false);
body.setTextureOffset(46, 11).addCuboid(-2.999F, -10.0F, -12.0F, 6.0F, 5.0F, 3.0F, 0.0F, false);
body.setTextureOffset(15, 31).addCuboid(-2.499F, -10.5F, -12.001F, 5.0F, 1.0F, 3.0F, 0.0F, false);
body.setTextureOffset(58, 20).addCuboid(-0.999F, -8.0F, -13.0F, 2.0F, 2.0F, 1.0F, 0.0F, false);
body.setTextureOffset(58, 20).addCuboid(-1.999F, -7.0F, -13.0F, 1.0F, 1.0F, 1.0F, 0.0F, false);
body.setTextureOffset(53, 21).addCuboid(-1.999F, -10.0F, -12.5F, 1.0F, 1.0F, 1.0F, 0.0F, false);
body.setTextureOffset(53, 21).addCuboid(1.001F, -10.0F, -12.5F, 1.0F, 1.0F, 1.0F, 0.0F, false);
body.setTextureOffset(58, 20).addCuboid(1.001F, -7.0F, -13.0F, 1.0F, 1.0F, 1.0F, 0.0F, false);
public static TexturedModelData getTexturedModelData() {
return TexturedModelData.of(getModelData(), 64, 64);
}
public static ModelData getModelData(){
ModelData modelData = new ModelData();
ModelPartData modelPartData = modelData.getRoot();
modelPartData.addChild("cube1", ModelPartBuilder.create().uv(0, 9).cuboid(6.0F, -3.0F, -8.0F, 4.0F, 3.0F, 16.0F), ModelTransform.NONE);
modelPartData.addChild("cube2", ModelPartBuilder.create().uv(0, 37).cuboid(-10.0F, -3.0F, -8.0F, 4.0F, 3.0F, 16.0F), ModelTransform.NONE);
modelPartData.addChild("cube3", ModelPartBuilder.create().uv(0, 57).cuboid(-8.0F, -2.99F, -10.0F, 16.0F, 3.0F, 4.0F), ModelTransform.NONE);
modelPartData.addChild("cube4", ModelPartBuilder.create().uv(0, 29).cuboid(-8.0F, -2.99F, 6.0F, 16.0F, 3.0F, 4.0F), ModelTransform.NONE);
modelPartData.addChild("cube5", ModelPartBuilder.create().uv(50, 0).cuboid(-2.0F, -8.0F, -10.0F, 4.0F, 5.0F, 3.0F), ModelTransform.NONE);
modelPartData.addChild("cube6", ModelPartBuilder.create().uv(46, 11).cuboid(-2.999F, -10.0F, -12.0F, 6.0F, 5.0F, 3.0F), ModelTransform.NONE);
modelPartData.addChild("cube7", ModelPartBuilder.create().uv(15, 31).cuboid(-2.499F, -10.5F, -12.001F, 5.0F, 1.0F, 3.0F), ModelTransform.NONE);
modelPartData.addChild("cube8", ModelPartBuilder.create().uv(58, 20).cuboid(-0.999F, -8.0F, -13.0F, 2.0F, 2.0F, 1.0F), ModelTransform.NONE);
modelPartData.addChild("cube9", ModelPartBuilder.create().uv(58, 20).cuboid(-1.999F, -7.0F, -13.0F, 1.0F, 1.0F, 1.0F), ModelTransform.NONE);
modelPartData.addChild("cube10", ModelPartBuilder.create().uv(53, 21).cuboid(-1.999F, -10.0F, -12.5F, 1.0F, 1.0F, 1.0F), ModelTransform.NONE);
modelPartData.addChild("cube11", ModelPartBuilder.create().uv(53, 21).cuboid(1.001F, -10.0F, -12.5F, 1.0F, 1.0F, 1.0F), ModelTransform.NONE);
modelPartData.addChild("cube12", ModelPartBuilder.create().uv(58, 20).cuboid(1.001F, -7.0F, -13.0F, 1.0F, 1.0F, 1.0F), ModelTransform.NONE);
return modelData;
}
@Override
public void setAngles(BathTireEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){
public void setAngles(BathTireEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
//previously the render function, render code was moved to a method below
}
@Override
public void render(MatrixStack matrixStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
public void render(MatrixStack matrixStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
body.render(matrixStack, buffer, packedLight, packedOverlay);
}
public void setRotationAngle(ModelPart modelRenderer, float x, float y, float z) {
modelRenderer.pivotX = x;
modelRenderer.pivotY = y;
modelRenderer.pivotZ = z;
}
}

View File

@@ -0,0 +1,24 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class BathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
private static Identifier TEXTURE;
public BathTireRenderer(EntityRendererFactory.Context context, DyeColor color) {
super(context, new BathTireModel(context.getPart(BathTireModel.BATH_TIRE_MODEL_LAYER)), 0.5F);
TEXTURE = Identifier.tryParse("textures/block/"+color.getName()+"_concrete.png");
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return TEXTURE;
}
}

View File

@@ -5,15 +5,17 @@ import eu.midnightdust.motschen.decorative.entity.BeachBallEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BeachBallModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.client.render.entity.*;
import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer;
import net.minecraft.client.render.entity.feature.SlimeOverlayFeatureRenderer;
import net.minecraft.client.render.entity.model.*;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class BeachBallRenderer extends MobEntityRenderer<BeachBallEntity, BeachBallModel> {
public BeachBallRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BeachBallModel(), 0.5F);
public BeachBallRenderer(EntityRendererFactory.Context context) {
super(context, new BeachBallModel(context.getPart(BeachBallModel.BEACH_BALL_MODEL_LAYER)), 0.5F);
}
@Override

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class BlackBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public BlackBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/black_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class BlueBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public BlueBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/blue_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class BrownBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public BrownBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/brown_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class CyanBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public CyanBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/cyan_concrete.png");
}
}

View File

@@ -8,13 +8,15 @@ import eu.midnightdust.motschen.decorative.entity.client.model.DuckBathTireModel
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class DuckBathTireRenderer extends MobEntityRenderer<BathTireEntity, DuckBathTireModel> {
public DuckBathTireRenderer(EntityRenderDispatcher dispatcher) { super(dispatcher, new DuckBathTireModel(), 0.5F); }
public DuckBathTireRenderer(EntityRendererFactory.Context context) {
super(context, new DuckBathTireModel(context.getPart(DuckBathTireModel.DUCK_BATH_TIRE_MODEL_LAYER)), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class GrayBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public GrayBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/gray_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class GreenBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public GreenBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/green_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class LightBlueBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public LightBlueBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/light_blue_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class LightGrayBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public LightGrayBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/light_gray_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class LimeBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public LimeBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/lime_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class MagentaBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public MagentaBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/magenta_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class OrangeBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public OrangeBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/orange_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class PinkBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public PinkBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/pink_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class PurpleBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public PurpleBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/purple_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class RedBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public RedBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/red_concrete.png");
}
}

View File

@@ -1,23 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.DecorativeMain;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class WhiteBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public WhiteBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/white_concrete.png");
}
}

View File

@@ -1,22 +0,0 @@
package eu.midnightdust.motschen.decorative.entity.client.renderer;
import eu.midnightdust.motschen.decorative.entity.BathTireEntity;
import eu.midnightdust.motschen.decorative.entity.client.model.BathTireModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class YellowBathTireRenderer extends MobEntityRenderer<BathTireEntity, BathTireModel> {
public YellowBathTireRenderer(EntityRenderDispatcher dispatcher) {
super(dispatcher, new BathTireModel(), 0.5F);
}
@Override
public Identifier getTexture(BathTireEntity entity) {
return new Identifier("minecraft", "textures/block/yellow_concrete.png");
}
}

View File

View File

@@ -2,6 +2,7 @@ package eu.midnightdust.motschen.decorative.init;
import eu.midnightdust.motschen.decorative.DecorativeMain;
import eu.midnightdust.motschen.decorative.block.blockentity.*;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.Identifier;
@@ -17,11 +18,11 @@ public class BlockEntities {
public static BlockEntityType<DigitalClockBlockEntity> DigitalClockBlockEntity;
public static void init() {
PoolSprinklerBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"pool_sprinkler_blockentity"), BlockEntityType.Builder.create(PoolSprinklerBlockEntity::new, Pool.PoolSprinkler).build(null));
ShowerHeadBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"shower_head_blockentity"), BlockEntityType.Builder.create(ShowerHeadBlockEntity::new, DecorativeMain.ShowerHead).build(null));
CeilingFanBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"ceiling_fan_blockentity"), BlockEntityType.Builder.create(CeilingFanBlockEntity::new, DecorativeMain.CeilingFan).build(null));
ChoppingLogBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"chopping_log_blockentity"), BlockEntityType.Builder.create(ChoppingLogBlockEntity::new, LogsWithAxes.OakChoppingLog, LogsWithAxes.BirchChoppingLog, LogsWithAxes.AcaciaChoppingLog, LogsWithAxes.DarkOakChoppingLog, LogsWithAxes.JungleChoppingLog, LogsWithAxes.SpruceChoppingLog).build(null));
WallClockBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"wall_clock_blockentity"), BlockEntityType.Builder.create(WallClockBlockEntity::new, DecorativeMain.WallClock).build(null));
DigitalClockBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"digital_clock_blockentity"), BlockEntityType.Builder.create(DigitalClockBlockEntity::new, Clocks.RedDigitalClock, Clocks.BlackDigitalClock, Clocks.BlueDigitalClock, Clocks.BrownDigitalClock, Clocks.CyanDigitalClock, Clocks.GrayDigitalClock, Clocks.GreenDigitalClock, Clocks.LightBlueDigitalClock, Clocks.LightGrayDigitalClock, Clocks.LimeDigitalClock, Clocks.MagentaDigitalClock, Clocks.OrangeDigitalClock, Clocks.PinkDigitalClock, Clocks.PurpleDigitalClock, Clocks.WhiteDigitalClock, Clocks.YellowDigitalClock).build(null));
PoolSprinklerBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"pool_sprinkler_blockentity"), FabricBlockEntityTypeBuilder.create(PoolSprinklerBlockEntity::new, Pool.PoolSprinkler).build(null));
ShowerHeadBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"shower_head_blockentity"), FabricBlockEntityTypeBuilder.create(ShowerHeadBlockEntity::new, DecorativeMain.ShowerHead).build(null));
CeilingFanBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"ceiling_fan_blockentity"), FabricBlockEntityTypeBuilder.create(CeilingFanBlockEntity::new, DecorativeMain.CeilingFan).build(null));
ChoppingLogBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"chopping_log_blockentity"), FabricBlockEntityTypeBuilder.create(ChoppingLogBlockEntity::new, LogsWithAxes.OakChoppingLog, LogsWithAxes.BirchChoppingLog, LogsWithAxes.AcaciaChoppingLog, LogsWithAxes.DarkOakChoppingLog, LogsWithAxes.JungleChoppingLog, LogsWithAxes.SpruceChoppingLog).build(null));
WallClockBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"wall_clock_blockentity"), FabricBlockEntityTypeBuilder.create(WallClockBlockEntity::new, DecorativeMain.WallClock).build(null));
DigitalClockBlockEntity = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(DecorativeMain.MOD_ID,"digital_clock_blockentity"), FabricBlockEntityTypeBuilder.create(DigitalClockBlockEntity::new, Clocks.RedDigitalClock, Clocks.BlackDigitalClock, Clocks.BlueDigitalClock, Clocks.BrownDigitalClock, Clocks.CyanDigitalClock, Clocks.GrayDigitalClock, Clocks.GreenDigitalClock, Clocks.LightBlueDigitalClock, Clocks.LightGrayDigitalClock, Clocks.LimeDigitalClock, Clocks.MagentaDigitalClock, Clocks.OrangeDigitalClock, Clocks.PinkDigitalClock, Clocks.PurpleDigitalClock, Clocks.WhiteDigitalClock, Clocks.YellowDigitalClock).build(null));
}
}

View File

View File

View File

View File

View File

@@ -6,7 +6,8 @@ import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.stat.Stats;
import net.minecraft.util.Hand;
@@ -42,7 +43,7 @@ public class BathTireItem extends Item {
if (entityType.spawnFromItemStack((ServerWorld) world, itemStack, user, blockPos.up(1), SpawnReason.SPAWN_EGG, false, false) == null) {
return TypedActionResult.pass(itemStack);
} else {
if (!user.abilities.creativeMode) {
if (!user.getAbilities().creativeMode) {
itemStack.decrement(1);
}
@@ -55,9 +56,9 @@ public class BathTireItem extends Item {
}
}
public EntityType<?> getEntityType(CompoundTag tag) {
public EntityType<?> getEntityType(NbtCompound tag) {
if (tag != null && tag.contains("EntityTag", 10)) {
CompoundTag compoundTag = tag.getCompound("EntityTag");
NbtCompound compoundTag = tag.getCompound("EntityTag");
if (compoundTag.contains("id", 8)) {
return EntityType.get(compoundTag.getString("id")).orElse(this.type);
}

View File

@@ -1,19 +1,19 @@
package eu.midnightdust.motschen.decorative.mixin;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
import java.util.function.Supplier;
@Mixin(GenerationSettings.class)
public interface GenerationSettingsAccessorMixin {
@Accessor
List<List<Supplier<ConfiguredFeature<?, ?>>>> getFeatures();
@Accessor
void setFeatures(List<List<Supplier<ConfiguredFeature<?, ?>>>> features);
}
package eu.midnightdust.motschen.decorative.mixin;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
import java.util.function.Supplier;
@Mixin(GenerationSettings.class)
public interface GenerationSettingsAccessorMixin {
@Accessor
List<List<Supplier<ConfiguredFeature<?, ?>>>> getFeatures();
@Accessor
void setFeatures(List<List<Supplier<ConfiguredFeature<?, ?>>>> features);
}

View File

@@ -1,13 +1,13 @@
package eu.midnightdust.motschen.decorative.sound;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class DecorativeSoundEvents {
public static final SoundEvent CEILINGFAN_AMBIENT = register("decorative:ceiling_fan.ambient");
private static SoundEvent register(String id) {
return Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(new Identifier(id)));
}
package eu.midnightdust.motschen.decorative.sound;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class DecorativeSoundEvents {
public static final SoundEvent CEILINGFAN_AMBIENT = register("decorative:ceiling_fan.ambient");
private static SoundEvent register(String id) {
return Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(new Identifier(id)));
}
}

View File

@@ -1,44 +1,44 @@
package eu.midnightdust.motschen.decorative.world;
import com.google.common.collect.Lists;
import eu.midnightdust.motschen.decorative.mixin.GenerationSettingsAccessorMixin;
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
public class OreFeatureInjector {
public static void init() {
BuiltinRegistries.BIOME.forEach(OreFeatureInjector::addToBiome);
RegistryEntryAddedCallback.event(BuiltinRegistries.BIOME).register((i, identifier, biome) -> addToBiome(biome));
}
private static void addToBiome(Biome biome) {
addSaltOre(biome);
}
private static void addSaltOre(Biome biome) {
if (biome.getCategory() != Biome.Category.NETHER && biome.getCategory() != Biome.Category.THEEND) {
addFeature(biome, GenerationStep.Feature.UNDERGROUND_DECORATION, OreFeatures.ROCKY_ASPHALT_FEATURE);
}
}
public static void addFeature(Biome biome, GenerationStep.Feature step, ConfiguredFeature<?, ?> feature) {
GenerationSettingsAccessorMixin generationSettingsAccessor = (GenerationSettingsAccessorMixin) biome.getGenerationSettings();
int stepIndex = step.ordinal();
List<List<Supplier<ConfiguredFeature<?, ?>>>> featuresByStep = new ArrayList<>( generationSettingsAccessor.getFeatures());
while (featuresByStep.size() <= stepIndex) {
featuresByStep.add(Lists.newArrayList());
}
List<Supplier<ConfiguredFeature<?, ?>>> features = new ArrayList<>(featuresByStep.get(stepIndex));
features.add(() -> feature);
featuresByStep.set(stepIndex, features);
generationSettingsAccessor.setFeatures(featuresByStep);
}
package eu.midnightdust.motschen.decorative.world;
import com.google.common.collect.Lists;
import eu.midnightdust.motschen.decorative.mixin.GenerationSettingsAccessorMixin;
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
public class OreFeatureInjector {
public static void init() {
BuiltinRegistries.BIOME.forEach(OreFeatureInjector::addToBiome);
RegistryEntryAddedCallback.event(BuiltinRegistries.BIOME).register((i, identifier, biome) -> addToBiome(biome));
}
private static void addToBiome(Biome biome) {
addSaltOre(biome);
}
private static void addSaltOre(Biome biome) {
if (biome.getCategory() != Biome.Category.NETHER && biome.getCategory() != Biome.Category.THEEND) {
addFeature(biome, GenerationStep.Feature.UNDERGROUND_DECORATION, OreFeatures.ROCKY_ASPHALT_FEATURE);
}
}
public static void addFeature(Biome biome, GenerationStep.Feature step, ConfiguredFeature<?, ?> feature) {
GenerationSettingsAccessorMixin generationSettingsAccessor = (GenerationSettingsAccessorMixin) biome.getGenerationSettings();
int stepIndex = step.ordinal();
List<List<Supplier<ConfiguredFeature<?, ?>>>> featuresByStep = new ArrayList<>( generationSettingsAccessor.getFeatures());
while (featuresByStep.size() <= stepIndex) {
featuresByStep.add(Lists.newArrayList());
}
List<Supplier<ConfiguredFeature<?, ?>>> features = new ArrayList<>(featuresByStep.get(stepIndex));
features.add(() -> feature);
featuresByStep.set(stepIndex, features);
generationSettingsAccessor.setFeatures(featuresByStep);
}
}

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

Some files were not shown because too many files have changed in this diff Show More