Silk moth AI upgrade, silk harvesting, hives
This commit is contained in:
parent
2f2b6dc654
commit
778977a869
15 changed files with 237 additions and 14 deletions
114
src/main/java/ru/betterend/blocks/SilkMothHiveBlock.java
Normal file
114
src/main/java/ru/betterend/blocks/SilkMothHiveBlock.java
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Material;
|
||||||
|
import net.minecraft.entity.ItemEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
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.state.property.DirectionProperty;
|
||||||
|
import net.minecraft.state.property.IntProperty;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.BlockMirror;
|
||||||
|
import net.minecraft.util.BlockRotation;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Box;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
import ru.betterend.entity.SilkMothEntity;
|
||||||
|
import ru.betterend.registry.EndEntities;
|
||||||
|
import ru.betterend.registry.EndItems;
|
||||||
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
|
public class SilkMothHiveBlock extends BlockBase {
|
||||||
|
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||||
|
public static final IntProperty FULLNESS = BlockProperties.FULLNESS;
|
||||||
|
|
||||||
|
public SilkMothHiveBlock() {
|
||||||
|
super(FabricBlockSettings.of(Material.WOOD).hardness(0.5F).resistance(0.1F).sounds(BlockSoundGroup.WOOL).nonOpaque().ticksRandomly().breakByHand(true));
|
||||||
|
this.setDefaultState(getDefaultState().with(FULLNESS, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||||
|
stateManager.add(FACING, FULLNESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
|
Direction dir = ctx.getPlayerFacing().getOpposite();
|
||||||
|
return this.getDefaultState().with(FACING, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||||
|
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||||
|
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||||
|
Direction dir = state.get(FACING);
|
||||||
|
BlockPos spawn = pos.offset(dir);
|
||||||
|
if (!world.getBlockState(spawn).isAir()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> { return true; }).size();
|
||||||
|
if (count > 6) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SilkMothEntity moth = new SilkMothEntity(EndEntities.SILK_MOTH, world);
|
||||||
|
moth.refreshPositionAndAngles(spawn.getX() + 0.5, spawn.getY() + 0.5, spawn.getZ() + 0.5, dir.asRotation(), 0);
|
||||||
|
moth.setVelocity(new Vec3d(dir.getOffsetX() * 0.4, 0, dir.getOffsetZ() * 0.4));
|
||||||
|
moth.setHive(world, pos);
|
||||||
|
world.spawnEntity(moth);
|
||||||
|
world.playSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||||
|
if (hand == Hand.MAIN_HAND) {
|
||||||
|
ItemStack stack = player.getMainHandStack();
|
||||||
|
if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.get(FULLNESS) == 3) {
|
||||||
|
BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0));
|
||||||
|
Direction dir = state.get(FACING);
|
||||||
|
double px = pos.getX() + dir.getOffsetX() + 0.5;
|
||||||
|
double py = pos.getY() + dir.getOffsetY() + 0.5;
|
||||||
|
double pz = pos.getZ() + dir.getOffsetZ() + 0.5;
|
||||||
|
ItemStack drop = new ItemStack(EndItems.SILK_FIBER, MHelper.randRange(8, 16, world.getRandom()));
|
||||||
|
ItemEntity entity = new ItemEntity(world, px, py, pz, drop);
|
||||||
|
world.spawnEntity(entity);
|
||||||
|
if (world.getRandom().nextInt(4) == 0) {
|
||||||
|
drop = new ItemStack(EndItems.SILK_MOTH_MATRIX);
|
||||||
|
entity = new ItemEntity(world, px, py, pz, drop);
|
||||||
|
world.spawnEntity(entity);
|
||||||
|
}
|
||||||
|
if (!player.isCreative()) {
|
||||||
|
stack.setDamage(stack.getDamage() + 1);
|
||||||
|
}
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ActionResult.FAIL;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,11 +5,13 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -24,8 +26,11 @@ import net.minecraft.state.property.DirectionProperty;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.state.property.IntProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.tag.BlockTags;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.BlockMirror;
|
import net.minecraft.util.BlockMirror;
|
||||||
import net.minecraft.util.BlockRotation;
|
import net.minecraft.util.BlockRotation;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Box;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
|
@ -39,7 +44,9 @@ import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.entity.SilkMothEntity;
|
import ru.betterend.entity.SilkMothEntity;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.registry.EndEntities;
|
import ru.betterend.registry.EndEntities;
|
||||||
|
import ru.betterend.registry.EndItems;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
|
public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
|
||||||
public static final BooleanProperty ACTIVE = BlockProperties.ACTIVE;
|
public static final BooleanProperty ACTIVE = BlockProperties.ACTIVE;
|
||||||
|
@ -128,7 +135,7 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> { return true; }).size();
|
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> { return true; }).size();
|
||||||
if (count > 8) {
|
if (count > 6) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SilkMothEntity moth = new SilkMothEntity(EndEntities.SILK_MOTH, world);
|
SilkMothEntity moth = new SilkMothEntity(EndEntities.SILK_MOTH, world);
|
||||||
|
@ -138,4 +145,29 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
|
||||||
world.spawnEntity(moth);
|
world.spawnEntity(moth);
|
||||||
world.playSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1, 1);
|
world.playSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||||
|
if (hand == Hand.MAIN_HAND) {
|
||||||
|
ItemStack stack = player.getMainHandStack();
|
||||||
|
if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.get(ACTIVE) && state.get(FULLNESS) == 3) {
|
||||||
|
BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0));
|
||||||
|
Direction dir = state.get(FACING);
|
||||||
|
double px = pos.getX() + dir.getOffsetX() + 0.5;
|
||||||
|
double py = pos.getY() + dir.getOffsetY() + 0.5;
|
||||||
|
double pz = pos.getZ() + dir.getOffsetZ() + 0.5;
|
||||||
|
ItemStack drop = new ItemStack(EndItems.SILK_FIBER, MHelper.randRange(1, 4, world.getRandom()));
|
||||||
|
ItemEntity entity = new ItemEntity(world, px, py, pz, drop);
|
||||||
|
world.spawnEntity(entity);
|
||||||
|
drop = new ItemStack(EndItems.SILK_MOTH_MATRIX, MHelper.randRange(1, 3, world.getRandom()));
|
||||||
|
entity = new ItemEntity(world, px, py, pz, drop);
|
||||||
|
world.spawnEntity(entity);
|
||||||
|
if (!player.isCreative()) {
|
||||||
|
stack.setDamage(stack.getDamage() + 1);
|
||||||
|
}
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ActionResult.FAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ru.betterend.entity;
|
package ru.betterend.entity;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -34,8 +35,10 @@ import net.minecraft.nbt.NbtHelper;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.util.registry.RegistryKey;
|
import net.minecraft.util.registry.RegistryKey;
|
||||||
|
@ -44,7 +47,6 @@ import net.minecraft.world.ServerWorldAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.blocks.BlockProperties;
|
import ru.betterend.blocks.BlockProperties;
|
||||||
import ru.betterend.blocks.SilkMothNestBlock;
|
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndEntities;
|
import ru.betterend.registry.EndEntities;
|
||||||
import ru.betterend.registry.EndItems;
|
import ru.betterend.registry.EndItems;
|
||||||
|
@ -177,7 +179,13 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
|
||||||
|
|
||||||
public static boolean canSpawn(EntityType<SilkMothEntity> type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) {
|
public static boolean canSpawn(EntityType<SilkMothEntity> type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) {
|
||||||
int y = world.getChunk(pos).sampleHeightmap(Type.WORLD_SURFACE, pos.getX() & 15, pos.getY() & 15);
|
int y = world.getChunk(pos).sampleHeightmap(Type.WORLD_SURFACE, pos.getX() & 15, pos.getY() & 15);
|
||||||
return y > 0 && pos.getY() >= y;
|
return y > 0 && pos.getY() >= y && notManyEntities(world, pos, 32, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean notManyEntities(ServerWorldAccess world, BlockPos pos, int radius, int maxCount) {
|
||||||
|
Box box = new Box(pos).expand(radius);
|
||||||
|
List<SilkMothEntity> list = world.getEntitiesByClass(SilkMothEntity.class, box, (entity) -> true);
|
||||||
|
return list.size() <= maxCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MothLookControl extends LookControl {
|
class MothLookControl extends LookControl {
|
||||||
|
@ -207,7 +215,13 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
Vec3d vec3d = this.getRandomLocation();
|
Vec3d vec3d = null;
|
||||||
|
if (SilkMothEntity.this.hivePos != null && SilkMothEntity.this.hiveWorld == SilkMothEntity.this.world) {
|
||||||
|
if (SilkMothEntity.this.getPos().squaredDistanceTo(SilkMothEntity.this.hivePos.getX(), SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) > 16) {
|
||||||
|
vec3d = SilkMothEntity.this.getPos().add(random.nextGaussian() * 2, 0, random.nextGaussian() * 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vec3d = vec3d == null ? this.getRandomLocation() : vec3d;
|
||||||
if (vec3d != null) {
|
if (vec3d != null) {
|
||||||
try {
|
try {
|
||||||
SilkMothEntity.this.navigation.startMovingAlong(SilkMothEntity.this.navigation.findPathTo(new BlockPos(vec3d), 1), 1.0D);
|
SilkMothEntity.this.navigation.startMovingAlong(SilkMothEntity.this.navigation.findPathTo(new BlockPos(vec3d), 1), 1.0D);
|
||||||
|
@ -235,22 +249,23 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
|
||||||
&& SilkMothEntity.this.hiveWorld == SilkMothEntity.this.world
|
&& SilkMothEntity.this.hiveWorld == SilkMothEntity.this.world
|
||||||
&& SilkMothEntity.this.navigation.isIdle()
|
&& SilkMothEntity.this.navigation.isIdle()
|
||||||
&& SilkMothEntity.this.random.nextInt(16) == 0
|
&& SilkMothEntity.this.random.nextInt(16) == 0
|
||||||
&& SilkMothEntity.this.getPos().squaredDistanceTo(SilkMothEntity.this.hivePos.getX(), SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) < 32;
|
&& SilkMothEntity.this.getPos().squaredDistanceTo(SilkMothEntity.this.hivePos.getX(), SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) < 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldContinue() {
|
public boolean shouldContinue() {
|
||||||
return SilkMothEntity.this.navigation.isFollowingPath() && world.getBlockState(entrance).isAir() && world.getBlockState(hivePos).isOf(EndBlocks.SILK_MOTH_NEST);
|
return SilkMothEntity.this.navigation.isFollowingPath() && world.getBlockState(entrance).isAir() && (world.getBlockState(hivePos).isOf(EndBlocks.SILK_MOTH_NEST) || world.getBlockState(hivePos).isOf(EndBlocks.SILK_MOTH_HIVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
BlockState state = SilkMothEntity.this.world.getBlockState(SilkMothEntity.this.hivePos);
|
BlockState state = SilkMothEntity.this.world.getBlockState(SilkMothEntity.this.hivePos);
|
||||||
if (!state.isOf(EndBlocks.SILK_MOTH_NEST)) {
|
if (!state.isOf(EndBlocks.SILK_MOTH_NEST) && !state.isOf(EndBlocks.SILK_MOTH_HIVE)) {
|
||||||
SilkMothEntity.this.hivePos = null;
|
SilkMothEntity.this.hivePos = null;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
SilkMothEntity.this.entrance = SilkMothEntity.this.hivePos.offset(state.get(SilkMothNestBlock.FACING));
|
SilkMothEntity.this.entrance = SilkMothEntity.this.hivePos.offset(state.get(Properties.HORIZONTAL_FACING));
|
||||||
SilkMothEntity.this.navigation.startMovingAlong(SilkMothEntity.this.navigation.findPathTo(entrance, 1), 1.0D);
|
SilkMothEntity.this.navigation.startMovingAlong(SilkMothEntity.this.navigation.findPathTo(entrance, 1), 1.0D);
|
||||||
}
|
}
|
||||||
catch (Exception e) {}
|
catch (Exception e) {}
|
||||||
|
@ -259,20 +274,30 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
if (SilkMothEntity.this.entrance == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
double dx = Math.abs(SilkMothEntity.this.entrance.getX() - SilkMothEntity.this.getX());
|
double dx = Math.abs(SilkMothEntity.this.entrance.getX() - SilkMothEntity.this.getX());
|
||||||
double dy = Math.abs(SilkMothEntity.this.entrance.getY() - SilkMothEntity.this.getY());
|
double dy = Math.abs(SilkMothEntity.this.entrance.getY() - SilkMothEntity.this.getY());
|
||||||
double dz = Math.abs(SilkMothEntity.this.entrance.getZ() - SilkMothEntity.this.getZ());
|
double dz = Math.abs(SilkMothEntity.this.entrance.getZ() - SilkMothEntity.this.getZ());
|
||||||
if (dx + dy + dz < 1) {
|
if (dx + dy + dz < 1) {
|
||||||
BlockState state = SilkMothEntity.this.world.getBlockState(hivePos);
|
BlockState state = SilkMothEntity.this.world.getBlockState(hivePos);
|
||||||
if (state.isOf(EndBlocks.SILK_MOTH_NEST)) {
|
if (state.isOf(EndBlocks.SILK_MOTH_NEST) || state.isOf(EndBlocks.SILK_MOTH_HIVE)) {
|
||||||
int fullness = state.get(BlockProperties.FULLNESS);
|
int fullness = state.get(BlockProperties.FULLNESS);
|
||||||
if (fullness < 3 && SilkMothEntity.this.random.nextBoolean()) {
|
boolean isHive = state.isOf(EndBlocks.SILK_MOTH_HIVE);
|
||||||
fullness ++;
|
if (fullness < 3 && (isHive || SilkMothEntity.this.random.nextBoolean())) {
|
||||||
BlocksHelper.setWithUpdate(SilkMothEntity.this.hiveWorld, SilkMothEntity.this.hivePos, state);
|
fullness += isHive ? MHelper.randRange(1, 2, random) : 1;
|
||||||
|
if (fullness > 3) {
|
||||||
|
fullness = 3;
|
||||||
|
}
|
||||||
|
BlocksHelper.setWithUpdate(SilkMothEntity.this.hiveWorld, SilkMothEntity.this.hivePos, state.with(BlockProperties.FULLNESS, fullness));
|
||||||
}
|
}
|
||||||
SilkMothEntity.this.world.playSound(null, SilkMothEntity.this.entrance, SoundEvents.BLOCK_BEEHIVE_ENTER, SoundCategory.BLOCKS, 1, 1);
|
SilkMothEntity.this.world.playSound(null, SilkMothEntity.this.entrance, SoundEvents.BLOCK_BEEHIVE_ENTER, SoundCategory.BLOCKS, 1, 1);
|
||||||
SilkMothEntity.this.remove();
|
SilkMothEntity.this.remove();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
SilkMothEntity.this.hivePos = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,8 @@ public class CraftingRecipes {
|
||||||
GridRecipe.make("charcoal_block", EndBlocks.CHARCOAL_BLOCK).setShape("###", "###", "###").addMaterial('#', Items.CHARCOAL).build();
|
GridRecipe.make("charcoal_block", EndBlocks.CHARCOAL_BLOCK).setShape("###", "###", "###").addMaterial('#', Items.CHARCOAL).build();
|
||||||
GridRecipe.make("end_stone_furnace", EndBlocks.END_STONE_FURNACE).setShape("###", "# #", "###").addMaterial('#', Blocks.END_STONE).build();
|
GridRecipe.make("end_stone_furnace", EndBlocks.END_STONE_FURNACE).setShape("###", "# #", "###").addMaterial('#', Blocks.END_STONE).build();
|
||||||
GridRecipe.make("filalux_lantern", EndBlocks.FILALUX_LANTERN).setShape("###", "###", "###").addMaterial('#', EndBlocks.FILALUX).build();
|
GridRecipe.make("filalux_lantern", EndBlocks.FILALUX_LANTERN).setShape("###", "###", "###").addMaterial('#', EndBlocks.FILALUX).build();
|
||||||
|
|
||||||
|
GridRecipe.make("silk_moth_hive", EndBlocks.SILK_MOTH_HIVE).setShape("###", "LML", "###").addMaterial('#', EndBlocks.TENANEA.planks).addMaterial('L', EndBlocks.TENANEA_LEAVES).addMaterial('M', EndItems.SILK_MOTH_MATRIX).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerLantern(String name, Block lantern, Block slab) {
|
private static void registerLantern(String name, Block lantern, Block slab) {
|
||||||
|
|
|
@ -86,6 +86,7 @@ import ru.betterend.blocks.RespawnObeliskBlock;
|
||||||
import ru.betterend.blocks.RunedFlavolite;
|
import ru.betterend.blocks.RunedFlavolite;
|
||||||
import ru.betterend.blocks.ShadowBerryBlock;
|
import ru.betterend.blocks.ShadowBerryBlock;
|
||||||
import ru.betterend.blocks.ShadowGrassBlock;
|
import ru.betterend.blocks.ShadowGrassBlock;
|
||||||
|
import ru.betterend.blocks.SilkMothHiveBlock;
|
||||||
import ru.betterend.blocks.SilkMothNestBlock;
|
import ru.betterend.blocks.SilkMothNestBlock;
|
||||||
import ru.betterend.blocks.SmallAmaranitaBlock;
|
import ru.betterend.blocks.SmallAmaranitaBlock;
|
||||||
import ru.betterend.blocks.SmallJellyshroomBlock;
|
import ru.betterend.blocks.SmallJellyshroomBlock;
|
||||||
|
@ -354,6 +355,7 @@ public class EndBlocks {
|
||||||
|
|
||||||
// Mob-Related
|
// Mob-Related
|
||||||
public static final Block SILK_MOTH_NEST = registerBlock("silk_moth_nest", new SilkMothNestBlock());
|
public static final Block SILK_MOTH_NEST = registerBlock("silk_moth_nest", new SilkMothNestBlock());
|
||||||
|
public static final Block SILK_MOTH_HIVE = registerBlock("silk_moth_hive", new SilkMothHiveBlock());
|
||||||
|
|
||||||
// Ores //
|
// Ores //
|
||||||
public static final Block ENDER_ORE = registerBlock("ender_ore", new EndOreBlock(EndItems.ENDER_SHARD, 1, 3, 5));
|
public static final Block ENDER_ORE = registerBlock("ender_ore", new EndOreBlock(EndItems.ENDER_SHARD, 1, 3, 5));
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class EndEntities {
|
||||||
public static final EntityType<EndFishEntity> END_FISH = register("end_fish", SpawnGroup.WATER_AMBIENT, 0.5F, 0.5F, EndFishEntity::new, EndFishEntity.createMobAttributes(), true, MHelper.color(3, 50, 76), MHelper.color(120, 206, 255));
|
public static final EntityType<EndFishEntity> END_FISH = register("end_fish", SpawnGroup.WATER_AMBIENT, 0.5F, 0.5F, EndFishEntity::new, EndFishEntity.createMobAttributes(), true, MHelper.color(3, 50, 76), MHelper.color(120, 206, 255));
|
||||||
public static final EntityType<ShadowWalkerEntity> SHADOW_WALKER = register("shadow_walker", SpawnGroup.MONSTER, 0.6F, 1.95F, ShadowWalkerEntity::new, ShadowWalkerEntity.createMobAttributes(), true, MHelper.color(30, 30, 30), MHelper.color(5, 5, 5));
|
public static final EntityType<ShadowWalkerEntity> SHADOW_WALKER = register("shadow_walker", SpawnGroup.MONSTER, 0.6F, 1.95F, ShadowWalkerEntity::new, ShadowWalkerEntity.createMobAttributes(), true, MHelper.color(30, 30, 30), MHelper.color(5, 5, 5));
|
||||||
public static final EntityType<CubozoaEntity> CUBOZOA = register("cubozoa", SpawnGroup.WATER_AMBIENT, 0.6F, 1F, CubozoaEntity::new, CubozoaEntity.createMobAttributes(), true, MHelper.color(151, 77, 181), MHelper.color(93, 176, 238));
|
public static final EntityType<CubozoaEntity> CUBOZOA = register("cubozoa", SpawnGroup.WATER_AMBIENT, 0.6F, 1F, CubozoaEntity::new, CubozoaEntity.createMobAttributes(), true, MHelper.color(151, 77, 181), MHelper.color(93, 176, 238));
|
||||||
public static final EntityType<SilkMothEntity> SILK_MOTH = register("silk_moth", SpawnGroup.AMBIENT, 0.6F, 0.6F, SilkMothEntity::new, SilkMothEntity.createMobAttributes(), true, MHelper.color(0, 0, 0), MHelper.color(225, 225, 225));
|
public static final EntityType<SilkMothEntity> SILK_MOTH = register("silk_moth", SpawnGroup.AMBIENT, 0.6F, 0.6F, SilkMothEntity::new, SilkMothEntity.createMobAttributes(), true, MHelper.color(198, 138, 204), MHelper.color(242, 220, 236));
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
SpawnHelper.restrictionAir(DRAGONFLY, DragonflyEntity::canSpawn);
|
SpawnHelper.restrictionAir(DRAGONFLY, DragonflyEntity::canSpawn);
|
||||||
|
|
|
@ -74,6 +74,7 @@ public class EndItems {
|
||||||
public final static Item LEATHER_WRAPPED_STICK = registerItem("leather_wrapped_stick");
|
public final static Item LEATHER_WRAPPED_STICK = registerItem("leather_wrapped_stick");
|
||||||
public final static Item SILK_FIBER = registerItem("silk_fiber");
|
public final static Item SILK_FIBER = registerItem("silk_fiber");
|
||||||
public final static Item LUMECORN_ROD = registerItem("lumecorn_rod");
|
public final static Item LUMECORN_ROD = registerItem("lumecorn_rod");
|
||||||
|
public final static Item SILK_MOTH_MATRIX = registerItem("silk_moth_matrix");
|
||||||
|
|
||||||
// Armor //
|
// Armor //
|
||||||
public static final Item AETERNIUM_HELMET = registerItem("aeternium_helmet", new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.HEAD, makeItemSettings().fireproof()));
|
public static final Item AETERNIUM_HELMET = registerItem("aeternium_helmet", new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.HEAD, makeItemSettings().fireproof()));
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"facing=north,fullness=0": { "model": "betterend:block/silk_moth_hive" },
|
||||||
|
"facing=south,fullness=0": { "model": "betterend:block/silk_moth_hive", "y": 180 },
|
||||||
|
"facing=east,fullness=0": { "model": "betterend:block/silk_moth_hive", "y": 90 },
|
||||||
|
"facing=west,fullness=0": { "model": "betterend:block/silk_moth_hive", "y": 270 },
|
||||||
|
"facing=north,fullness=1": { "model": "betterend:block/silk_moth_hive" },
|
||||||
|
"facing=south,fullness=1": { "model": "betterend:block/silk_moth_hive", "y": 180 },
|
||||||
|
"facing=east,fullness=1": { "model": "betterend:block/silk_moth_hive", "y": 90 },
|
||||||
|
"facing=west,fullness=1": { "model": "betterend:block/silk_moth_hive", "y": 270 },
|
||||||
|
"facing=north,fullness=2": { "model": "betterend:block/silk_moth_hive" },
|
||||||
|
"facing=south,fullness=2": { "model": "betterend:block/silk_moth_hive", "y": 180 },
|
||||||
|
"facing=east,fullness=2": { "model": "betterend:block/silk_moth_hive", "y": 90 },
|
||||||
|
"facing=west,fullness=2": { "model": "betterend:block/silk_moth_hive", "y": 270 },
|
||||||
|
"facing=north,fullness=3": { "model": "betterend:block/silk_moth_hive_silk" },
|
||||||
|
"facing=south,fullness=3": { "model": "betterend:block/silk_moth_hive_silk", "y": 180 },
|
||||||
|
"facing=east,fullness=3": { "model": "betterend:block/silk_moth_hive_silk", "y": 90 },
|
||||||
|
"facing=west,fullness=3": { "model": "betterend:block/silk_moth_hive_silk", "y": 270 }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube",
|
||||||
|
"textures": {
|
||||||
|
"down": "betterend:block/moth_hive_side",
|
||||||
|
"east": "betterend:block/moth_hive_side",
|
||||||
|
"north": "betterend:block/moth_hive_front",
|
||||||
|
"particle": "betterend:block/moth_hive_side",
|
||||||
|
"south": "betterend:block/moth_hive_side",
|
||||||
|
"up": "betterend:block/moth_hive_side",
|
||||||
|
"west": "betterend:block/moth_hive_side"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube",
|
||||||
|
"textures": {
|
||||||
|
"down": "betterend:block/moth_hive_side",
|
||||||
|
"east": "betterend:block/moth_hive_side",
|
||||||
|
"north": "betterend:block/moth_hive_front_silk",
|
||||||
|
"particle": "betterend:block/moth_hive_side",
|
||||||
|
"south": "betterend:block/moth_hive_side",
|
||||||
|
"up": "betterend:block/moth_hive_side",
|
||||||
|
"west": "betterend:block/moth_hive_side"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"parent": "betterend:block/silk_moth_hive"
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 311 B |
Binary file not shown.
After Width: | Height: | Size: 319 B |
Binary file not shown.
After Width: | Height: | Size: 269 B |
Binary file not shown.
After Width: | Height: | Size: 424 B |
Loading…
Add table
Add a link
Reference in a new issue