Added shrinking happy ghasts with fire charges
This commit is contained in:
parent
1bd3b116dc
commit
574a5ea61b
|
|
@ -39,4 +39,9 @@ public class ModBlocks {
|
|||
"acoustic_plush",
|
||||
true
|
||||
);
|
||||
public static final Block Parched_Ghast = register(
|
||||
new ParchedGhast(BlockBehaviour.Properties.of()),
|
||||
"parched_ghast",
|
||||
true
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
package xyz.nearmisses.patience.mc_rebalance;
|
||||
|
||||
import com.blackgear.vanillabackport.client.registries.ModSoundTypes;
|
||||
import com.blackgear.vanillabackport.common.level.entities.happyghast.HappyGhast;
|
||||
import com.blackgear.vanillabackport.common.registries.ModEntities;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ParchedGhast extends Block implements SimpleWaterloggedBlock {
|
||||
|
||||
public ParchedGhast(Properties properties) {
|
||||
super(properties.noOcclusion().sound(ModSoundTypes.DRIED_GHAST));
|
||||
this.registerDefaultState(this.stateDefinition.any()
|
||||
.setValue(FACING, Direction.NORTH)
|
||||
.setValue(WATERLOGGED, false)
|
||||
);
|
||||
}
|
||||
|
||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING, WATERLOGGED);
|
||||
}
|
||||
@Override // New collision box
|
||||
public @NotNull VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
|
||||
return Block.box(3.0, 0.0, 3.0, 13.0, 15.0, 13.0);
|
||||
}
|
||||
|
||||
// Water functions
|
||||
@Override
|
||||
public @NotNull FluidState getFluidState(BlockState blockState) {
|
||||
return blockState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(blockState);
|
||||
}
|
||||
@Override
|
||||
public @NotNull BlockState updateShape(BlockState blockState, Direction direction, BlockState blockState2, LevelAccessor levelAccessor, BlockPos blockPos, BlockPos blockPos2) {
|
||||
if (blockState.getValue(WATERLOGGED)) {
|
||||
levelAccessor.scheduleTick(blockPos, Fluids.WATER, Fluids.WATER.getTickDelay(levelAccessor));
|
||||
levelAccessor.scheduleTick(blockPos, ModBlocks.Parched_Ghast, 200);
|
||||
//ModEntities.HAPPY_GHAST.get().create(levelAccessor)
|
||||
//levelAccessor.removeBlock(blockPos, true);
|
||||
}
|
||||
|
||||
return super.updateShape(blockState, direction, blockState2, levelAccessor, blockPos, blockPos2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
BlockPos blockPos = context.getClickedPos();
|
||||
FluidState fluidState = context.getLevel().getFluidState(blockPos);
|
||||
return this.defaultBlockState()
|
||||
.setValue(FACING, context.getHorizontalDirection().getOpposite())
|
||||
.setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER);
|
||||
}
|
||||
|
||||
public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
|
||||
if (state.getValue(WATERLOGGED)) {
|
||||
HappyGhast ghast = ModEntities.HAPPY_GHAST.get().create(level);
|
||||
if(ghast!=null) {
|
||||
ghast.setPos(pos.getCenter());
|
||||
level.addFreshEntity(ghast);
|
||||
level.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package xyz.nearmisses.patience.mc_rebalance.mixin;
|
||||
|
||||
import com.blackgear.vanillabackport.client.registries.ModSoundEvents;
|
||||
import com.blackgear.vanillabackport.common.level.entities.happyghast.HappyGhast;
|
||||
import com.blackgear.vanillabackport.core.data.tags.ModItemTags;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import xyz.nearmisses.patience.mc_rebalance.ModBlocks;
|
||||
|
||||
@Mixin(HappyGhast.class)
|
||||
public abstract class HappyGhastTweak extends Animal{
|
||||
protected HappyGhastTweak(EntityType<? extends Animal> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
@Inject(method = "mobInteract", at = @At(value="INVOKE", target="Lnet/minecraft/world/entity/player/Player;getItemInHand(Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/world/item/ItemStack;"), cancellable = true)
|
||||
private void mobInteract(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir){
|
||||
if(player.getItemInHand(hand).is(Items.FIRE_CHARGE)){
|
||||
this.playSound(ModSoundEvents.HAPPY_GHAST_AMBIENT.get());
|
||||
this.spawnAtLocation(ModBlocks.Parched_Ghast);
|
||||
if(this.getItemBySlot(EquipmentSlot.CHEST).is(ModItemTags.HARNESSES)){ // Drop harness if one is equipped
|
||||
this.playSound(ModSoundEvents.HARNESS_UNEQUIP.get());
|
||||
this.spawnAtLocation(this.getItemBySlot(EquipmentSlot.CHEST));
|
||||
}
|
||||
this.remove(RemovalReason.DISCARDED);
|
||||
cir.setReturnValue(InteractionResult.CONSUME);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,5 +15,7 @@
|
|||
"item.mc_rebalance.diamond_paxel": "Diamond Paxel",
|
||||
"item.mc_rebalance.netherite_paxel": "Dendrite Paxel",
|
||||
"effect.mc_rebalance.shattered": "Shattered",
|
||||
"enchantment.mc_rebalance.windup": "Windup"
|
||||
"enchantment.mc_rebalance.windup": "Windup",
|
||||
"block.mc_rebalance.parched_ghast": "Parched Ghast",
|
||||
"item.mc_rebalance.parched_ghast": "Parched Ghast"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"parent": "minecraft:block/dried_ghast",
|
||||
"textures": {
|
||||
"bottom": "minecraft:block/dried_ghast_hydration_3_bottom",
|
||||
"east": "minecraft:block/dried_ghast_hydration_3_east",
|
||||
"north": "minecraft:block/dried_ghast_hydration_3_north",
|
||||
"particle": "minecraft:block/dried_ghast_hydration_3_north",
|
||||
"south": "minecraft:block/dried_ghast_hydration_3_south",
|
||||
"tentacles": "minecraft:block/dried_ghast_hydration_3_tentacles",
|
||||
"top": "minecraft:block/dried_ghast_hydration_3_top",
|
||||
"west": "minecraft:block/dried_ghast_hydration_3_west"
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
"CreakingRework",
|
||||
"DiggerItemHitCooldownsTweak",
|
||||
"ExperienceOrbRework",
|
||||
"HappyGhastTweak",
|
||||
"WardenRework",
|
||||
"WitherSkeletonRework"
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue