mirror of
https://github.com/TeamMidnightDust/Decorative.git
synced 2025-12-15 12:35:10 +01:00
The water is pumpin'
- Water pumps now work with Polymer
This commit is contained in:
@@ -109,6 +109,7 @@ public class FireHydrant extends HorizontalFacingBlock implements FactoryBlock {
|
||||
public BlockState getPolymerBlockState(BlockState state) {
|
||||
return Blocks.BARRIER.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPolymerBreakEventBlockState(BlockState state, ServerPlayerEntity player) {
|
||||
return Blocks.RED_TERRACOTTA.getDefaultState();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package eu.midnightdust.motschen.decorative.block;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import eu.midnightdust.motschen.decorative.polymer.model.DirectionalItemDisplayModel;
|
||||
import eu.pb4.factorytools.api.block.FactoryBlock;
|
||||
import eu.pb4.polymer.virtualentity.api.ElementHolder;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -13,11 +15,12 @@ import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsage;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ItemActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
@@ -28,8 +31,7 @@ import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldView;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class WaterPump extends HorizontalFacingBlock implements FactoryBlock {
|
||||
private static final VoxelShape NORTH_SHAPE;
|
||||
@@ -45,7 +47,8 @@ public class WaterPump extends HorizontalFacingBlock implements FactoryBlock {
|
||||
protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
if (!stack.isEmpty() && hand==Hand.MAIN_HAND && stack.getItem() == Items.BUCKET) {
|
||||
if (!world.isClient) {
|
||||
ItemUsage.exchangeStack(stack, player, new ItemStack(Items.BUCKET));
|
||||
player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, new ItemStack(Items.WATER_BUCKET), false));
|
||||
player.getItemCooldownManager().set(Items.WATER_BUCKET, 5);
|
||||
world.playSound(null, pos, SoundEvents.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
return ItemActionResult.SUCCESS;
|
||||
@@ -107,4 +110,14 @@ public class WaterPump extends HorizontalFacingBlock implements FactoryBlock {
|
||||
public BlockState getPolymerBlockState(BlockState state) {
|
||||
return Blocks.BARRIER.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPolymerBreakEventBlockState(BlockState state, ServerPlayerEntity player) {
|
||||
return Blocks.GREEN_TERRACOTTA.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ElementHolder createElementHolder(ServerWorld world, BlockPos pos, BlockState initialBlockState) {
|
||||
return new DirectionalItemDisplayModel(initialBlockState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import eu.midnightdust.motschen.decorative.block.Guardrail;
|
||||
import eu.midnightdust.motschen.decorative.block.PoolSprinkler;
|
||||
import eu.midnightdust.motschen.decorative.block.ShowerHead;
|
||||
import eu.midnightdust.motschen.decorative.block.Sign;
|
||||
import eu.midnightdust.motschen.decorative.block.WaterPump;
|
||||
import eu.midnightdust.motschen.decorative.config.DecorativeConfig;
|
||||
import eu.pb4.factorytools.api.resourcepack.BaseItemProvider;
|
||||
import eu.pb4.factorytools.api.virtualentity.BlockModel;
|
||||
@@ -25,6 +26,7 @@ import static eu.midnightdust.motschen.decorative.DecorativeMain.id;
|
||||
public class DirectionalItemDisplayModel extends BlockModel {
|
||||
private final ItemDisplayElement main;
|
||||
public static ItemStack FIRE_HYDRANT;
|
||||
public static ItemStack WATER_PUMP;
|
||||
public static ItemStack GUARDRAIL;
|
||||
public static ItemStack POOL_SPRINKLER;
|
||||
public static ItemStack SHOWER_HEAD;
|
||||
@@ -32,6 +34,7 @@ public class DirectionalItemDisplayModel extends BlockModel {
|
||||
|
||||
public static void initModels() {
|
||||
FIRE_HYDRANT = BaseItemProvider.requestModel(id("block/fire_hydrant"));
|
||||
WATER_PUMP = BaseItemProvider.requestModel(id("block/water_pump"));
|
||||
GUARDRAIL = BaseItemProvider.requestModel(id("block/guardrail"));
|
||||
POOL_SPRINKLER = BaseItemProvider.requestModel(id("block/pool_sprinkler"));
|
||||
SHOWER_HEAD = BaseItemProvider.requestModel(id("block/shower_head"));
|
||||
@@ -61,6 +64,7 @@ public class DirectionalItemDisplayModel extends BlockModel {
|
||||
}
|
||||
public ItemStack getModel(BlockState state) {
|
||||
if (state.getBlock() instanceof FireHydrant) return FIRE_HYDRANT;
|
||||
else if (state.getBlock() instanceof WaterPump) return WATER_PUMP;
|
||||
else if (state.getBlock() instanceof PoolSprinkler) return POOL_SPRINKLER;
|
||||
else if (state.getBlock() instanceof ShowerHead) return SHOWER_HEAD;
|
||||
else if (state.getBlock() instanceof Sign) return SIGNS.get(Sign.Type.fromBlockName(state.getBlock().getTranslationKey()).getName());
|
||||
@@ -68,6 +72,7 @@ public class DirectionalItemDisplayModel extends BlockModel {
|
||||
}
|
||||
public float getRotation(BlockState state) {
|
||||
if (state.getBlock() instanceof FireHydrant) return state.get(FireHydrant.FACING).getHorizontal() * -90;
|
||||
else if (state.getBlock() instanceof WaterPump) return state.get(WaterPump.FACING).getHorizontal() * -90 - 90;
|
||||
else if (state.getBlock() instanceof PoolSprinkler) return state.get(PoolSprinkler.FACING).getHorizontal() * -90;
|
||||
else if (state.getBlock() instanceof ShowerHead) return state.get(ShowerHead.FACING).getHorizontal() * -90 + 90;
|
||||
else if (state.getBlock() instanceof Sign) return state.get(PoolSprinkler.FACING).getHorizontal() * -90 + 180;
|
||||
|
||||
Reference in New Issue
Block a user