mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
a bit more work
This commit is contained in:
parent
1880bf785d
commit
ba47a8823e
13 changed files with 347 additions and 357 deletions
|
@ -4,61 +4,61 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom;
|
||||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||||
import de.ellpeck.naturesaura.reg.*;
|
import de.ellpeck.naturesaura.reg.*;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.BushBlock;
|
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.tileentity.BlockEntity;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.world.level.LevelReader;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.level.IBlockReader;
|
import net.minecraft.world.level.block.BushBlock;
|
||||||
import net.minecraft.level.ILevelReader;
|
import net.minecraft.world.level.block.EntityBlock;
|
||||||
import net.minecraft.level.Level;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.material.Material;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType {
|
public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType, EntityBlock {
|
||||||
|
|
||||||
protected static final VoxelShape SHAPE = Block.makeCuboidShape(5.0D, 0.0D, 5.0D, 11.0D, 10.0D, 11.0D);
|
protected static final VoxelShape SHAPE = Block.box(5.0D, 0.0D, 5.0D, 11.0D, 10.0D, 11.0D);
|
||||||
private final String baseName;
|
private final String baseName;
|
||||||
private final Block[] allowedGround;
|
private final Block[] allowedGround;
|
||||||
|
|
||||||
public BlockAuraBloom(String baseName, Block... allowedGround) {
|
public BlockAuraBloom(String baseName, Block... allowedGround) {
|
||||||
super(Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT));
|
super(Properties.of(Material.PLANT).noCollission().strength(0).sound(SoundType.GRASS));
|
||||||
this.baseName = baseName;
|
this.baseName = baseName;
|
||||||
this.allowedGround = allowedGround;
|
this.allowedGround = allowedGround;
|
||||||
ModRegistry.add(this);
|
ModRegistry.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValidPosition(BlockState state, ILevelReader levelIn, BlockPos pos) {
|
public boolean canSurvive(BlockState state, LevelReader levelIn, BlockPos pos) {
|
||||||
BlockPos down = pos.down();
|
BlockPos down = pos.below();
|
||||||
return this.isValidGround(levelIn.getBlockState(down), levelIn, down);
|
return this.mayPlaceOn(levelIn.getBlockState(down), levelIn, down);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isValidGround(BlockState state, IBlockReader levelIn, BlockPos pos) {
|
protected boolean mayPlaceOn(BlockState state, BlockGetter levelIn, BlockPos pos) {
|
||||||
return Arrays.stream(this.allowedGround).anyMatch(state::isIn);
|
return Arrays.stream(this.allowedGround).anyMatch(state::is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollision(BlockState state, Level levelIn, BlockPos pos, Entity entityIn) {
|
public void entityInside(BlockState state, Level levelIn, BlockPos pos, Entity entityIn) {
|
||||||
if (this == ModBlocks.AURA_CACTUS)
|
if (this == ModBlocks.AURA_CACTUS)
|
||||||
entityIn.attackEntityFrom(DamageSource.CACTUS, 1);
|
entityIn.hurt(DamageSource.CACTUS, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||||
Vector3d vec3d = state.getOffset(levelIn, pos);
|
Vec3 vec3d = state.getOffset(levelIn, pos);
|
||||||
return SHAPE.withOffset(vec3d.x, vec3d.y, vec3d.z);
|
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,7 +73,7 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Supplier<RenderType> getRenderType() {
|
public Supplier<RenderType> getRenderType() {
|
||||||
return RenderType::getCutout;
|
return RenderType::cutout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,14 +81,9 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
|
||||||
return this.baseName;
|
return this.baseName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@org.jetbrains.annotations.Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity createBlockEntity(BlockState state, IBlockReader level) {
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||||
return new BlockEntityAuraBloom();
|
return new BlockEntityAuraBloom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasBlockEntity(BlockState state) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,45 +8,47 @@ import de.ellpeck.naturesaura.packet.PacketClient;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import de.ellpeck.naturesaura.reg.*;
|
import de.ellpeck.naturesaura.reg.*;
|
||||||
import net.minecraft.block.AbstractRailBlock;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
|
||||||
import net.minecraft.entity.player.Player;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.state.EnumProperty;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.state.Property;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.state.StateContainer;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.state.properties.RailShape;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.entity.vehicle.AbstractMinecart;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.level.IBlockReader;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.level.Level;
|
import net.minecraft.world.level.block.BaseRailBlock;
|
||||||
import net.minecraft.level.gen.Heightmap;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.level.server.ServerLevel;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
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.EnumProperty;
|
||||||
|
import net.minecraft.world.level.block.state.properties.Property;
|
||||||
|
import net.minecraft.world.level.block.state.properties.RailShape;
|
||||||
|
import net.minecraft.world.level.levelgen.Heightmap;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraftforge.common.util.ITeleporter;
|
import net.minecraftforge.common.util.ITeleporter;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class BlockDimensionRail extends AbstractRailBlock implements IModItem, ICustomRenderType, ICustomBlockState, ICustomItemModel {
|
public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICustomRenderType, ICustomBlockState, ICustomItemModel {
|
||||||
|
|
||||||
public static final EnumProperty<RailShape> SHAPE = BlockStateProperties.RAIL_SHAPE;
|
public static final EnumProperty<RailShape> SHAPE = BlockStateProperties.RAIL_SHAPE;
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final RegistryKey<Level> goalDim;
|
private final ResourceKey<Level> goalDim;
|
||||||
private final RegistryKey<Level>[] canUseDims;
|
private final ResourceKey<Level>[] canUseDims;
|
||||||
|
|
||||||
public BlockDimensionRail(String name, RegistryKey<Level> goalDim, RegistryKey<Level>... canUseDims) {
|
@SafeVarargs
|
||||||
super(false, Properties.from(Blocks.RAIL));
|
public BlockDimensionRail(String name, ResourceKey<Level> goalDim, ResourceKey<Level>... canUseDims) {
|
||||||
|
super(false, Properties.copy(Blocks.RAIL));
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.goalDim = goalDim;
|
this.goalDim = goalDim;
|
||||||
this.canUseDims = canUseDims;
|
this.canUseDims = canUseDims;
|
||||||
|
@ -54,22 +56,22 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
|
||||||
ModRegistry.add(this);
|
ModRegistry.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canUseHere(RegistryKey<Level> dimension) {
|
private boolean canUseHere(ResourceKey<Level> dimension) {
|
||||||
for (RegistryKey<Level> dim : this.canUseDims)
|
for (var dim : this.canUseDims)
|
||||||
if (dim == dimension)
|
if (dim == dimension)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand hand, BlockRayTraceResult hit) {
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
var stack = player.getItemInHand(hand);
|
||||||
if (stack.getItem() == ModItems.RANGE_VISUALIZER) {
|
if (stack.getItem() == ModItems.RANGE_VISUALIZER) {
|
||||||
if (!levelIn.isClientSide) {
|
if (!levelIn.isClientSide) {
|
||||||
BlockPos goalPos = this.getGoalCoords(levelIn, pos);
|
var goalPos = this.getGoalCoords(levelIn, pos);
|
||||||
CompoundTag data = new CompoundTag();
|
var data = new CompoundTag();
|
||||||
data.putString("dim", this.goalDim.func_240901_a_().toString());
|
data.putString("dim", this.goalDim.location().toString());
|
||||||
data.putLong("pos", goalPos.toLong());
|
data.putLong("pos", goalPos.asLong());
|
||||||
PacketHandler.sendTo(player, new PacketClient(0, data));
|
PacketHandler.sendTo(player, new PacketClient(0, data));
|
||||||
}
|
}
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
@ -78,56 +80,56 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMinecartPass(BlockState state, Level level, BlockPos pos, AbstractMinecartEntity cart) {
|
public void onMinecartPass(BlockState state, Level level, BlockPos pos, AbstractMinecart cart) {
|
||||||
if (level.isClientSide)
|
if (level.isClientSide)
|
||||||
return;
|
return;
|
||||||
if (cart.isBeingRidden())
|
if (!cart.getPassengers().isEmpty())
|
||||||
return;
|
return;
|
||||||
if (!this.canUseHere(level.func_234923_W_()))
|
if (!this.canUseHere(level.dimension()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AxisAlignedBB box = cart.getBoundingBox();
|
var box = cart.getBoundingBox();
|
||||||
PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, PacketParticles.Type.DIMENSION_RAIL, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F)));
|
PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, PacketParticles.Type.DIMENSION_RAIL, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F)));
|
||||||
level.playSound(null, pos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 1F, 1F);
|
level.playSound(null, pos, SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 1F, 1F);
|
||||||
|
|
||||||
BlockPos goalCoords = this.getGoalCoords(level, pos);
|
var goalCoords = this.getGoalCoords(level, pos);
|
||||||
cart.changeDimension(level.getServer().getLevel(this.goalDim), new ITeleporter() {
|
cart.changeDimension(level.getServer().getLevel(this.goalDim), new ITeleporter() {
|
||||||
@Override
|
@Override
|
||||||
public Entity placeEntity(Entity entity, ServerLevel currentLevel, ServerLevel destLevel, float yaw, Function<Boolean, Entity> repositionEntity) {
|
public Entity placeEntity(Entity entity, ServerLevel currentLevel, ServerLevel destLevel, float yaw, Function<Boolean, Entity> repositionEntity) {
|
||||||
// repositionEntity always causes a NPE because why wouldn't it, so this is a fixed copy
|
// repositionEntity always causes a NPE because why wouldn't it, so this is a fixed copy
|
||||||
entity.level.getProfiler().endStartSection("reloading");
|
entity.level.getProfiler().popPush("reloading");
|
||||||
Entity result = entity.getType().create(destLevel);
|
var result = entity.getType().create(destLevel);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
result.copyDataFromOld(entity);
|
result.restoreFrom(entity);
|
||||||
destLevel.addFromAnotherDimension(result);
|
destLevel.addDuringTeleport(result);
|
||||||
result.moveToBlockPosAndAngles(goalCoords, yaw, result.rotationPitch);
|
result.moveTo(goalCoords, yaw, result.getXRot());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
BlockPos spot = IAuraChunk.getHighestSpot(level, pos, 35, pos);
|
var spot = IAuraChunk.getHighestSpot(level, pos, 35, pos);
|
||||||
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 50000);
|
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 50000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockPos getGoalCoords(Level level, BlockPos pos) {
|
private BlockPos getGoalCoords(Level level, BlockPos pos) {
|
||||||
MinecraftServer server = level.getServer();
|
var server = level.getServer();
|
||||||
if (this == ModBlocks.DIMENSION_RAIL_NETHER) {
|
if (this == ModBlocks.DIMENSION_RAIL_NETHER) {
|
||||||
// travel to the nether from the overworld
|
// travel to the nether from the overworld
|
||||||
return new BlockPos(pos.getX() / 8, pos.getY() / 2, pos.getZ() / 8);
|
return new BlockPos(pos.getX() / 8, pos.getY() / 2, pos.getZ() / 8);
|
||||||
} else if (this == ModBlocks.DIMENSION_RAIL_END) {
|
} else if (this == ModBlocks.DIMENSION_RAIL_END) {
|
||||||
// travel to the end from the overworld
|
// travel to the end from the overworld
|
||||||
return ServerLevel.field_241108_a_.up(8);
|
return ServerLevel.END_SPAWN_POINT.above(8);
|
||||||
} else {
|
} else {
|
||||||
if (level.func_234923_W_() == Level.field_234919_h_) {
|
if (level.dimension() == Level.OVERWORLD) {
|
||||||
// travel to the overworld from the nether
|
// travel to the overworld from the nether
|
||||||
return new BlockPos(pos.getX() * 8, pos.getY() * 2, pos.getZ() * 8);
|
return new BlockPos(pos.getX() * 8, pos.getY() * 2, pos.getZ() * 8);
|
||||||
} else {
|
} else {
|
||||||
// travel to the overworld from the end
|
// travel to the overworld from the end
|
||||||
ServerLevel overworld = server.getLevel(this.goalDim);
|
var overworld = server.getLevel(this.goalDim);
|
||||||
BlockPos spawn = overworld.func_241135_u_();
|
var spawn = overworld.getSharedSpawnPos();
|
||||||
BlockPos ret = new BlockPos(spawn.getX(), 0, spawn.getZ());
|
var ret = new BlockPos(spawn.getX(), 0, spawn.getZ());
|
||||||
return ret.up(overworld.getHeight(Heightmap.Type.WORLD_SURFACE, spawn.getX(), spawn.getZ()));
|
return ret.above(overworld.getHeight(Heightmap.Types.WORLD_SURFACE, spawn.getX(), spawn.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,17 +140,17 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFlexibleRail(BlockState state, IBlockReader level, BlockPos pos) {
|
public boolean isFlexibleRail(BlockState state, BlockGetter level, BlockPos pos) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canMakeSlopes(BlockState state, IBlockReader level, BlockPos pos) {
|
public boolean canMakeSlopes(BlockState state, BlockGetter level, BlockPos pos) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
builder.add(SHAPE);
|
builder.add(SHAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +161,7 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Supplier<RenderType> getRenderType() {
|
public Supplier<RenderType> getRenderType() {
|
||||||
return RenderType::getCutoutMipped;
|
return RenderType::cutoutMipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,15 +4,15 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.block.SlabBlock;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.world.level.block.SlabBlock;
|
||||||
|
|
||||||
public class Slab extends SlabBlock implements IModItem, ICustomBlockState {
|
public class Slab extends SlabBlock implements IModItem, ICustomBlockState {
|
||||||
|
|
||||||
public final String textureName;
|
public final String textureName;
|
||||||
private final String baseName;
|
private final String baseName;
|
||||||
|
|
||||||
public Slab(String baseName, String textureName, Properties properties) {
|
public Slab(String baseName, String textureName, Block.Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
this.baseName = baseName;
|
this.baseName = baseName;
|
||||||
this.textureName = textureName;
|
this.textureName = textureName;
|
||||||
|
@ -26,7 +26,7 @@ public class Slab extends SlabBlock implements IModItem, ICustomBlockState {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||||
ResourceLocation texture = generator.modLoc("block/" + this.textureName);
|
var texture = generator.modLoc("block/" + this.textureName);
|
||||||
generator.models().cubeAll(this.getBaseName() + "_double", texture);
|
generator.models().cubeAll(this.getBaseName() + "_double", texture);
|
||||||
generator.slabBlock(this, generator.modLoc(this.getBaseName() + "_double"), texture);
|
generator.slabBlock(this, generator.modLoc(this.getBaseName() + "_double"), texture);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.tileentity.ITickableBlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.tileentity.BlockEntityType;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
public class BlockEntityAuraBloom extends BlockEntityImpl implements ITickableBlockEntity {
|
public class BlockEntityAuraBloom extends BlockEntityImpl implements ITickableBlockEntity {
|
||||||
|
|
||||||
public boolean justGenerated;
|
public boolean justGenerated;
|
||||||
|
|
||||||
public BlockEntityAuraBloom() {
|
public BlockEntityAuraBloom(BlockPos pos, BlockState state) {
|
||||||
this(ModTileEntities.AURA_BLOOM);
|
this(ModTileEntities.AURA_BLOOM, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BlockEntityAuraBloom(BlockEntityType<BlockEntityAuraBloom> type) {
|
protected BlockEntityAuraBloom(BlockEntityType<BlockEntityAuraBloom> type, BlockPos pos, BlockState state) {
|
||||||
super(type);
|
super(type, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doing this in validate() creates a loading deadlock for some reason...
|
// Doing this in validate() creates a loading deadlock for some reason...
|
|
@ -1,5 +1,6 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
|
// TODO actually call this from the base entity block thing, and possibly others if not all use the base one!
|
||||||
public interface ITickableBlockEntity {
|
public interface ITickableBlockEntity {
|
||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
|
|
|
@ -2,64 +2,60 @@ package de.ellpeck.naturesaura.entities;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.entity.projectile.ThrowableEntity;
|
import net.minecraft.world.entity.projectile.ThrowableProjectile;
|
||||||
import net.minecraft.network.IPacket;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.util.math.*;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.level.Level;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
|
||||||
public class EntityLightProjectile extends ThrowableEntity {
|
public class EntityLightProjectile extends ThrowableProjectile {
|
||||||
public EntityLightProjectile(EntityType<? extends ThrowableEntity> type, Level levelIn) {
|
|
||||||
|
public EntityLightProjectile(EntityType<? extends ThrowableProjectile> type, Level levelIn) {
|
||||||
super(type, levelIn);
|
super(type, levelIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityLightProjectile(EntityType<? extends ThrowableEntity> type, LivingEntity livingEntityIn, Level levelIn) {
|
public EntityLightProjectile(EntityType<? extends ThrowableProjectile> type, LivingEntity livingEntityIn, Level levelIn) {
|
||||||
super(type, livingEntityIn, levelIn);
|
super(type, livingEntityIn, levelIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void defineSynchedData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (this.level.isClientSide && this.ticksExisted > 1) {
|
if (this.level.isClientSide && this.tickCount > 1) {
|
||||||
for (float i = 0; i <= 1; i += 0.2F) {
|
for (float i = 0; i <= 1; i += 0.2F) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
Mth.lerp(i, this.prevPosX, this.getPosX()),
|
Mth.lerp(i, this.xOld, this.getX()),
|
||||||
Mth.lerp(i, this.prevPosY, this.getPosY()),
|
Mth.lerp(i, this.yOld, this.getY()),
|
||||||
Mth.lerp(i, this.prevPosZ, this.getPosZ()),
|
Mth.lerp(i, this.zOld, this.getZ()),
|
||||||
this.rand.nextGaussian() * 0.01F, this.rand.nextGaussian() * 0.01F, this.rand.nextGaussian() * 0.01F,
|
this.random.nextGaussian() * 0.01F, this.random.nextGaussian() * 0.01F, this.random.nextGaussian() * 0.01F,
|
||||||
0xffcb5c, this.rand.nextFloat() * 0.5F + 1, 20, 0, false, true);
|
0xffcb5c, this.random.nextFloat() * 0.5F + 1, 20, 0, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onImpact(RayTraceResult result) {
|
protected void onHit(HitResult result) {
|
||||||
if (!this.level.isClientSide) {
|
if (!this.level.isClientSide) {
|
||||||
if (result instanceof BlockRayTraceResult) {
|
if (result instanceof BlockHitResult res) {
|
||||||
BlockRayTraceResult res = (BlockRayTraceResult) result;
|
BlockPos pos = res.getBlockPos().relative(res.getDirection());
|
||||||
BlockPos pos = res.getPos().offset(res.getFace());
|
|
||||||
BlockState state = this.level.getBlockState(pos);
|
BlockState state = this.level.getBlockState(pos);
|
||||||
if (state.getMaterial().isReplaceable())
|
if (state.getMaterial().isReplaceable())
|
||||||
this.level.setBlockState(pos, ModBlocks.LIGHT.getDefaultState());
|
this.level.setBlockAndUpdate(pos, ModBlocks.LIGHT.defaultBlockState());
|
||||||
} else if (result instanceof EntityRayTraceResult) {
|
} else if (result instanceof EntityHitResult entity) {
|
||||||
Entity entity = ((EntityRayTraceResult) result).getEntity();
|
entity.getEntity().setRemainingFireTicks(5);
|
||||||
entity.setFire(5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.remove();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void registerData() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPacket<?> createSpawnPacket() {
|
|
||||||
return NetworkHooks.getEntitySpawningPacket(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,25 +3,23 @@ package de.ellpeck.naturesaura.entities;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.entity.projectile.EyeOfEnderEntity;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.IPacket;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.network.datasync.DataParameter;
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.network.datasync.EntityDataManager;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.particles.ParticleTypes;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.util.SoundEvents;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.util.math.Mth;
|
import net.minecraft.world.entity.projectile.EyeOfEnder;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.level.Level;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
|
|
||||||
public class EntityStructureFinder extends EyeOfEnderEntity {
|
public class EntityStructureFinder extends EyeOfEnder {
|
||||||
|
|
||||||
public static final DataParameter<Integer> COLOR = EntityDataManager.createKey(EntityStructureFinder.class, DataSerializers.VARINT);
|
public static final EntityDataAccessor<Integer> COLOR = SynchedEntityData.defineId(EntityStructureFinder.class, EntityDataSerializers.INT);
|
||||||
|
|
||||||
private double targetX;
|
private double targetX;
|
||||||
private double targetY;
|
private double targetY;
|
||||||
|
@ -29,40 +27,40 @@ public class EntityStructureFinder extends EyeOfEnderEntity {
|
||||||
private int despawnTimer;
|
private int despawnTimer;
|
||||||
private boolean shatterOrDrop;
|
private boolean shatterOrDrop;
|
||||||
|
|
||||||
public EntityStructureFinder(EntityType<? extends EyeOfEnderEntity> type, Level level) {
|
public EntityStructureFinder(EntityType<? extends EyeOfEnder> type, Level level) {
|
||||||
super(type, level);
|
super(type, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerData() {
|
protected void defineSynchedData() {
|
||||||
super.registerData();
|
super.defineSynchedData();
|
||||||
this.dataManager.register(COLOR, 0);
|
this.entityData.define(COLOR, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeAdditional(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
super.writeAdditional(compound);
|
super.addAdditionalSaveData(compound);
|
||||||
compound.putInt("color", this.dataManager.get(COLOR));
|
compound.putInt("color", this.entityData.get(COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readAdditional(CompoundTag compound) {
|
public void readAdditionalSaveData(CompoundTag compound) {
|
||||||
super.readAdditional(compound);
|
super.readAdditionalSaveData(compound);
|
||||||
this.dataManager.set(COLOR, compound.getInt("color"));
|
this.entityData.set(COLOR, compound.getInt("color"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveTowards(BlockPos pos) {
|
public void signalTo(BlockPos pos) {
|
||||||
double d0 = pos.getX();
|
double d0 = pos.getX();
|
||||||
int i = pos.getY();
|
int i = pos.getY();
|
||||||
double d1 = pos.getZ();
|
double d1 = pos.getZ();
|
||||||
double d2 = d0 - this.getPosX();
|
double d2 = d0 - this.getX();
|
||||||
double d3 = d1 - this.getPosZ();
|
double d3 = d1 - this.getZ();
|
||||||
float f = Mth.sqrt(d2 * d2 + d3 * d3);
|
var f = Math.sqrt(d2 * d2 + d3 * d3);
|
||||||
if (f > 12.0F) {
|
if (f > 12.0F) {
|
||||||
this.targetX = this.getPosX() + d2 / (double) f * 12.0D;
|
this.targetX = this.getX() + d2 / (double) f * 12.0D;
|
||||||
this.targetZ = this.getPosZ() + d3 / (double) f * 12.0D;
|
this.targetZ = this.getZ() + d3 / (double) f * 12.0D;
|
||||||
this.targetY = this.getPosY() + 8.0D;
|
this.targetY = this.getY() + 8.0D;
|
||||||
} else {
|
} else {
|
||||||
this.targetX = d0;
|
this.targetX = d0;
|
||||||
this.targetY = i;
|
this.targetY = i;
|
||||||
|
@ -70,30 +68,30 @@ public class EntityStructureFinder extends EyeOfEnderEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.despawnTimer = 0;
|
this.despawnTimer = 0;
|
||||||
this.shatterOrDrop = this.rand.nextInt(4) > 0;
|
this.shatterOrDrop = this.random.nextInt(4) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
this.baseTick();
|
this.baseTick();
|
||||||
|
|
||||||
Vector3d vec3d = this.getMotion();
|
Vec3 vec3d = this.getDeltaMovement();
|
||||||
double d0 = this.getPosX() + vec3d.x;
|
double d0 = this.getX() + vec3d.x;
|
||||||
double d1 = this.getPosY() + vec3d.y;
|
double d1 = this.getY() + vec3d.y;
|
||||||
double d2 = this.getPosZ() + vec3d.z;
|
double d2 = this.getZ() + vec3d.z;
|
||||||
float f = Mth.sqrt(horizontalMag(vec3d));
|
var f = Math.sqrt(vec3d.horizontalDistance());
|
||||||
this.rotationYaw = (float) (Mth.atan2(vec3d.x, vec3d.z) * (double) (180F / (float) Math.PI));
|
this.setYRot((float) (Mth.atan2(vec3d.x, vec3d.z) * (double) (180F / (float) Math.PI)));
|
||||||
this.rotationPitch = (float) (Mth.atan2(vec3d.y, f) * (double) (180F / (float) Math.PI));
|
this.setXRot((float) (Mth.atan2(vec3d.y, f) * (double) (180F / (float) Math.PI)));
|
||||||
while (this.rotationPitch - this.prevRotationPitch < -180.0F)
|
while (this.getXRot() - this.xRotO < -180.0F)
|
||||||
this.prevRotationPitch -= 360.0F;
|
this.xRotO -= 360.0F;
|
||||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
|
while (this.getXRot() - this.xRotO >= 180.0F)
|
||||||
this.prevRotationPitch += 360.0F;
|
this.xRotO += 360.0F;
|
||||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
|
while (this.getYRot() - this.yRotO < -180.0F)
|
||||||
this.prevRotationYaw -= 360.0F;
|
this.yRotO -= 360.0F;
|
||||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
|
while (this.getYRot() - this.yRotO >= 180.0F)
|
||||||
this.prevRotationYaw += 360.0F;
|
this.yRotO += 360.0F;
|
||||||
this.rotationPitch = Mth.lerp(0.2F, this.prevRotationPitch, this.rotationPitch);
|
this.setXRot(Mth.lerp(0.2F, this.xRotO, this.getXRot()));
|
||||||
this.rotationYaw = Mth.lerp(0.2F, this.prevRotationYaw, this.rotationYaw);
|
this.setYRot(Mth.lerp(0.2F, this.yRotO, this.getYRot()));
|
||||||
if (!this.level.isClientSide) {
|
if (!this.level.isClientSide) {
|
||||||
double d3 = this.targetX - d0;
|
double d3 = this.targetX - d0;
|
||||||
double d4 = this.targetZ - d2;
|
double d4 = this.targetZ - d2;
|
||||||
|
@ -106,38 +104,34 @@ public class EntityStructureFinder extends EyeOfEnderEntity {
|
||||||
d6 *= 0.8D;
|
d6 *= 0.8D;
|
||||||
}
|
}
|
||||||
|
|
||||||
int j = this.getPosY() < this.targetY ? 1 : -1;
|
int j = this.getY() < this.targetY ? 1 : -1;
|
||||||
vec3d = new Vector3d(Math.cos(f2) * d5, d6 + ((double) j - d6) * (double) 0.015F, Math.sin(f2) * d5);
|
vec3d = new Vec3(Math.cos(f2) * d5, d6 + ((double) j - d6) * (double) 0.015F, Math.sin(f2) * d5);
|
||||||
this.setMotion(vec3d);
|
this.setDeltaMovement(vec3d);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isInWater()) {
|
if (this.isInWater()) {
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
this.level.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z);
|
this.level.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z);
|
||||||
} else if (this.level.isClientSide) {
|
} else if (this.level.isClientSide) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(d0 - vec3d.x * 0.25D + this.rand.nextDouble() * 0.6D - 0.3D, d1 - vec3d.y * 0.25D - 0.5D, d2 - vec3d.z * 0.25D + this.rand.nextDouble() * 0.6D - 0.3D, vec3d.x * 0.25F, vec3d.y * 0.25F, vec3d.z * 0.25F, this.dataManager.get(COLOR), 1, 50, 0, false, true);
|
NaturesAuraAPI.instance().spawnMagicParticle(d0 - vec3d.x * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, d1 - vec3d.y * 0.25D - 0.5D, d2 - vec3d.z * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, vec3d.x * 0.25F, vec3d.y * 0.25F, vec3d.z * 0.25F, this.entityData.get(COLOR), 1, 50, 0, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.level.isClientSide) {
|
if (!this.level.isClientSide) {
|
||||||
this.setPosition(d0, d1, d2);
|
this.setPos(d0, d1, d2);
|
||||||
++this.despawnTimer;
|
++this.despawnTimer;
|
||||||
if (this.despawnTimer > 80 && !this.level.isClientSide) {
|
if (this.despawnTimer > 80 && !this.level.isClientSide) {
|
||||||
this.playSound(SoundEvents.ENTITY_ENDER_EYE_DEATH, 1.0F, 1.0F);
|
this.playSound(SoundEvents.ENDER_EYE_DEATH, 1.0F, 1.0F);
|
||||||
this.remove();
|
this.remove(RemovalReason.DISCARDED);
|
||||||
if (this.shatterOrDrop) {
|
if (this.shatterOrDrop) {
|
||||||
this.level.addEntity(new ItemEntity(this.level, this.getPosX(), this.getPosY(), this.getPosZ(), this.getItem()));
|
this.level.addFreshEntity(new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), this.getItem()));
|
||||||
} else {
|
} else {
|
||||||
PacketHandler.sendToAllAround(this.level, this.getPosition(), 32, new PacketParticles((float) this.getPosX(), (float) this.getPosY(), (float) this.getPosZ(), PacketParticles.Type.STRUCTURE_FINDER, this.getEntityId()));
|
PacketHandler.sendToAllAround(this.level, this.getOnPos(), 32, new PacketParticles((float) this.getX(), (float) this.getY(), (float) this.getZ(), PacketParticles.Type.STRUCTURE_FINDER, this.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.setRawPosition(d0, d1, d2);
|
this.setPosRaw(d0, d1, d2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPacket<?> createSpawnPacket() {
|
|
||||||
return NetworkHooks.getEntitySpawningPacket(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,22 +2,24 @@ package de.ellpeck.naturesaura.items;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.entities.EntityStructureFinder;
|
import de.ellpeck.naturesaura.entities.EntityStructureFinder;
|
||||||
import de.ellpeck.naturesaura.entities.ModEntities;
|
import de.ellpeck.naturesaura.entities.ModEntities;
|
||||||
import net.minecraft.entity.player.Player;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.InteractionResult;
|
import net.minecraft.util.InteractionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
import net.minecraft.level.Level;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.level.gen.feature.structure.Structure;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.level.server.ServerLevel;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||||
|
|
||||||
public class ItemStructureFinder extends ItemImpl {
|
public class ItemStructureFinder extends ItemImpl {
|
||||||
private final Structure structureName;
|
|
||||||
|
private final StructureFeature<?> structureName;
|
||||||
private final int color;
|
private final int color;
|
||||||
private final int radius;
|
private final int radius;
|
||||||
|
|
||||||
public ItemStructureFinder(String baseName, Structure structureName, int color, int radius) {
|
public ItemStructureFinder(String baseName, StructureFeature<?> structureName, int color, int radius) {
|
||||||
super(baseName);
|
super(baseName);
|
||||||
this.structureName = structureName;
|
this.structureName = structureName;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
@ -25,11 +27,10 @@ public class ItemStructureFinder extends ItemImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(Level levelIn, Player playerIn, Hand handIn) {
|
public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
|
||||||
ItemStack stack = playerIn.getHeldItem(handIn);
|
ItemStack stack = playerIn.getItemInHand(handIn);
|
||||||
// ServerLevel.getStructureManager().doesGenerateFeatures()
|
if (!levelIn.isClientSide && ((ServerLevel) levelIn).structureFeatureManager().shouldGenerateFeatures()) {
|
||||||
if (!levelIn.isClientSide && ((ServerLevel) levelIn).func_241112_a_().func_235005_a_()) {
|
BlockPos pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapFeature((ServerLevel) levelIn, this.structureName, playerIn.getPosition(), this.radius, false);
|
||||||
BlockPos pos = ((ServerLevel) levelIn).getChunkProvider().getChunkGenerator().func_235956_a_((ServerLevel) levelIn, this.structureName, playerIn.getPosition(), this.radius, false);
|
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
EntityStructureFinder entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn);
|
EntityStructureFinder entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn);
|
||||||
entity.setPosition(playerIn.getPosX(), playerIn.getPosYHeight(0.5D), playerIn.getPosZ());
|
entity.setPosition(playerIn.getPosX(), playerIn.getPosYHeight(0.5D), playerIn.getPosZ());
|
||||||
|
|
|
@ -5,17 +5,14 @@ import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModArmorMaterial;
|
import de.ellpeck.naturesaura.reg.ModArmorMaterial;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
|
||||||
import net.minecraft.entity.ai.attributes.Attributes;
|
|
||||||
import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance;
|
|
||||||
import net.minecraft.entity.player.Player;
|
|
||||||
import net.minecraft.inventory.EquipmentSlotType;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.potion.EffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.potion.Effects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
|
import net.minecraft.world.item.*;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||||
|
@ -32,24 +29,24 @@ import java.util.UUID;
|
||||||
public class ItemArmor extends ArmorItem implements IModItem {
|
public class ItemArmor extends ArmorItem implements IModItem {
|
||||||
|
|
||||||
private static final AttributeModifier SKY_MOVEMENT_MODIFIER = new AttributeModifier(UUID.fromString("c1f96acc-e117-4dc1-a351-e196a4de6071"), NaturesAura.MOD_ID + ":sky_movement_speed", 0.15F, AttributeModifier.Operation.MULTIPLY_TOTAL);
|
private static final AttributeModifier SKY_MOVEMENT_MODIFIER = new AttributeModifier(UUID.fromString("c1f96acc-e117-4dc1-a351-e196a4de6071"), NaturesAura.MOD_ID + ":sky_movement_speed", 0.15F, AttributeModifier.Operation.MULTIPLY_TOTAL);
|
||||||
private static final Map<IArmorMaterial, Item[]> SETS = new HashMap<>();
|
private static final Map<ArmorMaterial, Item[]> SETS = new HashMap<>();
|
||||||
private final String baseName;
|
private final String baseName;
|
||||||
|
|
||||||
public ItemArmor(String baseName, IArmorMaterial materialIn, EquipmentSlotType equipmentSlotIn) {
|
public ItemArmor(String baseName, ArmorMaterial materialIn, EquipmentSlot equipmentSlotIn) {
|
||||||
super(materialIn, equipmentSlotIn, new Properties().group(NaturesAura.CREATIVE_TAB));
|
super(materialIn, equipmentSlotIn, new Properties().tab(NaturesAura.CREATIVE_TAB));
|
||||||
this.baseName = baseName;
|
this.baseName = baseName;
|
||||||
ModRegistry.add(this);
|
ModRegistry.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFullSetEquipped(LivingEntity entity, IArmorMaterial material) {
|
public static boolean isFullSetEquipped(LivingEntity entity, ArmorMaterial material) {
|
||||||
Item[] set = SETS.computeIfAbsent(material, m -> ForgeRegistries.ITEMS.getValues().stream()
|
var set = SETS.computeIfAbsent(material, m -> ForgeRegistries.ITEMS.getValues().stream()
|
||||||
.filter(i -> i instanceof ItemArmor && ((ItemArmor) i).getArmorMaterial() == material)
|
.filter(i -> i instanceof ItemArmor && ((ItemArmor) i).getMaterial() == material)
|
||||||
.sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getEquipmentSlot().ordinal()))
|
.sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getSlot().ordinal()))
|
||||||
.toArray(Item[]::new));
|
.toArray(Item[]::new));
|
||||||
for (int i = 0; i < 4; i++) {
|
for (var i = 0; i < 4; i++) {
|
||||||
EquipmentSlotType slot = EquipmentSlotType.values()[i + 2];
|
var slot = EquipmentSlot.values()[i + 2];
|
||||||
ItemStack stack = entity.getItemStackFromSlot(slot);
|
var stack = entity.getItemBySlot(slot);
|
||||||
if (stack.getItem() != set[i] && (slot != EquipmentSlotType.CHEST || stack.getItem() != Items.ELYTRA))
|
if (stack.getItem() != set[i] && (slot != EquipmentSlot.CHEST || stack.getItem() != Items.ELYTRA))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -71,33 +68,33 @@ public class ItemArmor extends ArmorItem implements IModItem {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onAttack(LivingAttackEvent event) {
|
public static void onAttack(LivingAttackEvent event) {
|
||||||
LivingEntity entity = event.getEntityLiving();
|
var entity = event.getEntityLiving();
|
||||||
if (!entity.level.isClientSide) {
|
if (!entity.level.isClientSide) {
|
||||||
if (!isFullSetEquipped(entity, ModArmorMaterial.INFUSED))
|
if (!isFullSetEquipped(entity, ModArmorMaterial.INFUSED))
|
||||||
return;
|
return;
|
||||||
Entity source = event.getSource().getTrueSource();
|
var source = event.getSource().getEntity();
|
||||||
if (source instanceof LivingEntity)
|
if (source instanceof LivingEntity)
|
||||||
((LivingEntity) source).addPotionEffect(new EffectInstance(Effects.WITHER, 40));
|
((LivingEntity) source).addEffect(new MobEffectInstance(MobEffects.WITHER, 40));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void update(TickEvent.PlayerTickEvent event) {
|
public static void update(TickEvent.PlayerTickEvent event) {
|
||||||
Player player = event.player;
|
var player = event.player;
|
||||||
ModifiableAttributeInstance speed = player.getAttribute(Attributes.MOVEMENT_SPEED);
|
var speed = player.getAttribute(Attributes.MOVEMENT_SPEED);
|
||||||
String key = NaturesAura.MOD_ID + ":sky_equipped";
|
var key = NaturesAura.MOD_ID + ":sky_equipped";
|
||||||
CompoundTag nbt = player.getPersistentData();
|
var nbt = player.getPersistentData();
|
||||||
boolean equipped = isFullSetEquipped(player, ModArmorMaterial.SKY);
|
var equipped = isFullSetEquipped(player, ModArmorMaterial.SKY);
|
||||||
if (equipped && !nbt.getBoolean(key)) {
|
if (equipped && !nbt.getBoolean(key)) {
|
||||||
// we just equipped it
|
// we just equipped it
|
||||||
nbt.putBoolean(key, true);
|
nbt.putBoolean(key, true);
|
||||||
player.stepHeight = 1.1F;
|
player.maxUpStep = 1.1F;
|
||||||
if (!speed.hasModifier(SKY_MOVEMENT_MODIFIER))
|
if (!speed.hasModifier(SKY_MOVEMENT_MODIFIER))
|
||||||
speed.applyNonPersistentModifier(SKY_MOVEMENT_MODIFIER);
|
speed.addPermanentModifier(SKY_MOVEMENT_MODIFIER);
|
||||||
} else if (!equipped && nbt.getBoolean(key)) {
|
} else if (!equipped && nbt.getBoolean(key)) {
|
||||||
// we just unequipped it
|
// we just unequipped it
|
||||||
nbt.putBoolean(key, false);
|
nbt.putBoolean(key, false);
|
||||||
player.stepHeight = 0.6F;
|
player.maxUpStep = 0.6F;
|
||||||
speed.removeModifier(SKY_MOVEMENT_MODIFIER);
|
speed.removeModifier(SKY_MOVEMENT_MODIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,20 @@ import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.block.BushBlock;
|
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
|
||||||
import net.minecraft.entity.player.Player;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.level.Level;
|
import net.minecraft.world.item.HoeItem;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.item.Tier;
|
||||||
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.BushBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -26,21 +30,21 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel {
|
||||||
|
|
||||||
private final String baseName;
|
private final String baseName;
|
||||||
|
|
||||||
public ItemHoe(String baseName, IItemTier material, int speed) {
|
public ItemHoe(String baseName, Tier material, int speed) {
|
||||||
super(material, speed, 0, new Properties().group(NaturesAura.CREATIVE_TAB));
|
super(material, speed, 0, new Properties().tab(NaturesAura.CREATIVE_TAB));
|
||||||
this.baseName = baseName;
|
this.baseName = baseName;
|
||||||
ModRegistry.add(this);
|
ModRegistry.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult onItemUse(ItemUseContext context) {
|
public InteractionResult useOn(UseOnContext context) {
|
||||||
if (this == ModItems.INFUSED_IRON_HOE) {
|
if (this == ModItems.INFUSED_IRON_HOE) {
|
||||||
Level level = context.getLevel();
|
Level level = context.getLevel();
|
||||||
InteractionResult result = super.onItemUse(context);
|
InteractionResult result = super.useOn(context);
|
||||||
if (!level.isClientSide && result.isSuccessOrConsume()) {
|
if (!level.isClientSide && result.consumesAction()) {
|
||||||
ItemStack seed = ItemStack.EMPTY;
|
ItemStack seed = ItemStack.EMPTY;
|
||||||
Random random = level.getRandom();
|
Random random = level.getRandom();
|
||||||
BlockPos pos = context.getPos();
|
BlockPos pos = context.getClickedPos();
|
||||||
if (random.nextInt(5) == 0) {
|
if (random.nextInt(5) == 0) {
|
||||||
seed = new ItemStack(Items.WHEAT_SEEDS);
|
seed = new ItemStack(Items.WHEAT_SEEDS);
|
||||||
} else if (random.nextInt(10) == 0) {
|
} else if (random.nextInt(10) == 0) {
|
||||||
|
@ -56,7 +60,7 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel {
|
||||||
|
|
||||||
if (!seed.isEmpty()) {
|
if (!seed.isEmpty()) {
|
||||||
ItemEntity item = new ItemEntity(level, pos.getX() + random.nextFloat(), pos.getY() + 1F, pos.getZ() + random.nextFloat(), seed);
|
ItemEntity item = new ItemEntity(level, pos.getX() + random.nextFloat(), pos.getY() + 1F, pos.getZ() + random.nextFloat(), seed);
|
||||||
level.addEntity(item);
|
level.addFreshEntity(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -64,15 +68,15 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
for (int x = -1; x <= 1; x++) {
|
for (int x = -1; x <= 1; x++) {
|
||||||
for (int z = -1; z <= 1; z++) {
|
for (int z = -1; z <= 1; z++) {
|
||||||
BlockPos offset = context.getPos().add(x, 0, z);
|
BlockPos offset = context.getClickedPos().offset(x, 0, z);
|
||||||
BlockRayTraceResult newResult = new BlockRayTraceResult(context.getHitVec(), context.getFace(), offset, context.isInside());
|
BlockHitResult newResult = new BlockHitResult(context.getClickLocation(), context.getClickedFace(), offset, context.isInside());
|
||||||
ItemUseContext newContext = new ItemUseContext(context.getPlayer(), context.getHand(), newResult);
|
UseOnContext newContext = new UseOnContext(context.getPlayer(), context.getHand(), newResult);
|
||||||
success |= super.onItemUse(newContext) == InteractionResult.SUCCESS;
|
success |= super.useOn(newContext) == InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return success ? InteractionResult.SUCCESS : InteractionResult.PASS;
|
return success ? InteractionResult.SUCCESS : InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
return super.onItemUse(context);
|
return super.useOn(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,7 +91,7 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel {
|
||||||
for (int z = -range; z <= range; z++) {
|
for (int z = -range; z <= range; z++) {
|
||||||
if (x == 0 && y == 0 && z == 0)
|
if (x == 0 && y == 0 && z == 0)
|
||||||
continue;
|
continue;
|
||||||
BlockPos offset = pos.add(x, y, z);
|
BlockPos offset = pos.offset(x, y, z);
|
||||||
BlockState otherState = player.level.getBlockState(offset);
|
BlockState otherState = player.level.getBlockState(offset);
|
||||||
if (otherState.getBlock() instanceof BushBlock)
|
if (otherState.getBlock() instanceof BushBlock)
|
||||||
player.level.destroyBlock(offset, true);
|
player.level.destroyBlock(offset, true);
|
||||||
|
|
|
@ -7,22 +7,23 @@ import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.item.IItemTier;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.SwordItem;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.potion.EffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.potion.Effects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.SwordItem;
|
||||||
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class ItemSword extends SwordItem implements IModItem, ICustomItemModel {
|
public class ItemSword extends SwordItem implements IModItem, ICustomItemModel {
|
||||||
|
|
||||||
private final String baseName;
|
private final String baseName;
|
||||||
|
|
||||||
public ItemSword(String baseName, IItemTier material, int damage, float speed) {
|
public ItemSword(String baseName, Tier material, int damage, float speed) {
|
||||||
super(material, damage, speed, new Properties().group(NaturesAura.CREATIVE_TAB));
|
super(material, damage, speed, new Properties().tab(NaturesAura.CREATIVE_TAB));
|
||||||
this.baseName = baseName;
|
this.baseName = baseName;
|
||||||
ModRegistry.add(this);
|
ModRegistry.add(this);
|
||||||
}
|
}
|
||||||
|
@ -33,13 +34,13 @@ public class ItemSword extends SwordItem implements IModItem, ICustomItemModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) {
|
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
|
||||||
if (this == ModItems.INFUSED_IRON_SWORD) {
|
if (this == ModItems.INFUSED_IRON_SWORD) {
|
||||||
target.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 60, 2));
|
target.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 60, 2));
|
||||||
} else if (this == ModItems.SKY_SWORD) {
|
} else if (this == ModItems.SKY_SWORD) {
|
||||||
target.addPotionEffect(new EffectInstance(Effects.LEVITATION, 60, 2));
|
target.addEffect(new MobEffectInstance(MobEffects.LEVITATION, 60, 2));
|
||||||
}
|
}
|
||||||
return super.hitEntity(stack, target, attacker);
|
return super.hurtEnemy(stack, target, attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -2,21 +2,21 @@ package de.ellpeck.naturesaura.reg;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import net.minecraft.inventory.EquipmentSlotType;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.item.IArmorMaterial;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.util.LazyValue;
|
import net.minecraft.world.item.ArmorMaterial;
|
||||||
import net.minecraft.util.SoundEvent;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import net.minecraft.util.SoundEvents;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.common.util.Lazy;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public enum ModArmorMaterial implements IArmorMaterial {
|
public enum ModArmorMaterial implements ArmorMaterial {
|
||||||
|
|
||||||
INFUSED(NaturesAura.MOD_ID + ":infused_iron", 19, new int[]{2, 5, 6, 2}, 16, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0, () -> Ingredient.fromItems(ModItems.INFUSED_IRON)),
|
INFUSED(NaturesAura.MOD_ID + ":infused_iron", 19, new int[]{2, 5, 6, 2}, 16, SoundEvents.ARMOR_EQUIP_GENERIC, 0, () -> Ingredient.of(ModItems.INFUSED_IRON)),
|
||||||
SKY(NaturesAura.MOD_ID + ":sky", 33, new int[]{3, 6, 8, 3}, 12, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 2, () -> Ingredient.fromItems(ModItems.SKY_INGOT));
|
SKY(NaturesAura.MOD_ID + ":sky", 33, new int[]{3, 6, 8, 3}, 12, SoundEvents.ARMOR_EQUIP_GENERIC, 2, () -> Ingredient.of(ModItems.SKY_INGOT));
|
||||||
|
|
||||||
private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11};
|
private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11};
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@ -25,7 +25,7 @@ public enum ModArmorMaterial implements IArmorMaterial {
|
||||||
private final int enchantability;
|
private final int enchantability;
|
||||||
private final SoundEvent soundEvent;
|
private final SoundEvent soundEvent;
|
||||||
private final float toughness;
|
private final float toughness;
|
||||||
private final LazyValue<Ingredient> repairMaterial;
|
private final Lazy<Ingredient> repairMaterial;
|
||||||
|
|
||||||
ModArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageReductionAmountsIn, int enchantabilityIn, SoundEvent equipSoundIn, float toughness, Supplier<Ingredient> repairMaterialSupplier) {
|
ModArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageReductionAmountsIn, int enchantabilityIn, SoundEvent equipSoundIn, float toughness, Supplier<Ingredient> repairMaterialSupplier) {
|
||||||
this.name = nameIn;
|
this.name = nameIn;
|
||||||
|
@ -34,32 +34,32 @@ public enum ModArmorMaterial implements IArmorMaterial {
|
||||||
this.enchantability = enchantabilityIn;
|
this.enchantability = enchantabilityIn;
|
||||||
this.soundEvent = equipSoundIn;
|
this.soundEvent = equipSoundIn;
|
||||||
this.toughness = toughness;
|
this.toughness = toughness;
|
||||||
this.repairMaterial = new LazyValue<>(repairMaterialSupplier);
|
this.repairMaterial = Lazy.of(repairMaterialSupplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurability(EquipmentSlotType slotIn) {
|
public int getDurabilityForSlot(EquipmentSlot slotIn) {
|
||||||
return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor;
|
return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDamageReductionAmount(EquipmentSlotType slotIn) {
|
public int getDefenseForSlot(EquipmentSlot slotIn) {
|
||||||
return this.damageReductionAmountArray[slotIn.getIndex()];
|
return this.damageReductionAmountArray[slotIn.getIndex()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnchantability() {
|
public int getEnchantmentValue() {
|
||||||
return this.enchantability;
|
return this.enchantability;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SoundEvent getSoundEvent() {
|
public SoundEvent getEquipSound() {
|
||||||
return this.soundEvent;
|
return this.soundEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Ingredient getRepairMaterial() {
|
public Ingredient getRepairIngredient() {
|
||||||
return this.repairMaterial.getValue();
|
return this.repairMaterial.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,35 +25,34 @@ import de.ellpeck.naturesaura.potion.ModPotions;
|
||||||
import de.ellpeck.naturesaura.potion.PotionBreathless;
|
import de.ellpeck.naturesaura.potion.PotionBreathless;
|
||||||
import de.ellpeck.naturesaura.recipes.EnabledCondition;
|
import de.ellpeck.naturesaura.recipes.EnabledCondition;
|
||||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.block.FlowerPotBlock;
|
import net.minecraft.block.FlowerPotBlock;
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||||
import net.minecraft.client.renderer.entity.SpriteRenderer;
|
import net.minecraft.client.renderer.entity.SpriteRenderer;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
|
||||||
import net.minecraft.entity.EntityClassification;
|
import net.minecraft.entity.EntityClassification;
|
||||||
import net.minecraft.entity.EntityType;
|
|
||||||
import net.minecraft.inventory.EquipmentSlotType;
|
|
||||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||||
import net.minecraft.level.Level;
|
|
||||||
import net.minecraft.level.gen.feature.Feature;
|
import net.minecraft.level.gen.feature.Feature;
|
||||||
import net.minecraft.level.gen.feature.structure.Structure;
|
|
||||||
import net.minecraft.tileentity.BlockEntityType;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.registry.LevelGenRegistries;
|
import net.minecraft.util.registry.LevelGenRegistries;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.world.entity.MobCategory;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||||
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
|
||||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
@ -80,9 +79,9 @@ public final class ModRegistry {
|
||||||
event.getRegistry().registerAll(
|
event.getRegistry().registerAll(
|
||||||
new BlockAncientLog("ancient_log"),
|
new BlockAncientLog("ancient_log"),
|
||||||
new BlockAncientLog("ancient_bark"),
|
new BlockAncientLog("ancient_bark"),
|
||||||
temp = new BlockImpl("ancient_planks", Block.Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(2F)),
|
temp = new BlockImpl("ancient_planks", Block.Properties.of(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(2F)),
|
||||||
new BlockStairsNA("ancient_stairs", "ancient_planks", temp::getDefaultState, Block.Properties.from(temp)),
|
new BlockStairsNA("ancient_stairs", "ancient_planks", temp::defaultBlockState, Block.Properties.from(temp)),
|
||||||
new Slab("ancient_slab", "ancient_planks", Block.Properties.from(temp)),
|
new Slab("ancient_slab", "ancient_planks", Block.Properties.copy(temp)),
|
||||||
new BlockAncientLeaves(),
|
new BlockAncientLeaves(),
|
||||||
new BlockAncientSapling(),
|
new BlockAncientSapling(),
|
||||||
new BlockNatureAltar(),
|
new BlockNatureAltar(),
|
||||||
|
@ -90,23 +89,23 @@ public final class ModRegistry {
|
||||||
new BlockGoldenLeaves(),
|
new BlockGoldenLeaves(),
|
||||||
new BlockGoldPowder(),
|
new BlockGoldPowder(),
|
||||||
new BlockWoodStand(),
|
new BlockWoodStand(),
|
||||||
temp = new BlockImpl("infused_stone", Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(1.75F)),
|
temp = new BlockImpl("infused_stone", Block.Properties.of(Material.STONE).sound(SoundType.STONE).hardnessAndResistance(1.75F)),
|
||||||
new BlockStairsNA("infused_stairs", "infused_stone", temp::getDefaultState, Block.Properties.from(temp)),
|
new BlockStairsNA("infused_stairs", "infused_stone", temp::defaultBlockState, Block.Properties.from(temp)),
|
||||||
new Slab("infused_slab", "infused_stone", Block.Properties.from(temp)),
|
new Slab("infused_slab", "infused_stone", Block.Properties.from(temp)),
|
||||||
temp = new BlockImpl("infused_brick", Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(1.5F)),
|
temp = new BlockImpl("infused_brick", Block.Properties.of(Material.STONE).sound(SoundType.STONE).hardnessAndResistance(1.5F)),
|
||||||
new BlockStairsNA("infused_brick_stairs", "infused_brick", temp::getDefaultState, Block.Properties.from(temp)),
|
new BlockStairsNA("infused_brick_stairs", "infused_brick", temp::defaultBlockState, Block.Properties.from(temp)),
|
||||||
new Slab("infused_brick_slab", "infused_brick", Block.Properties.from(temp)),
|
new Slab("infused_brick_slab", "infused_brick", Block.Properties.from(temp)),
|
||||||
new BlockFurnaceHeater(),
|
new BlockFurnaceHeater(),
|
||||||
new BlockPotionGenerator(),
|
new BlockPotionGenerator(),
|
||||||
new BlockAuraDetector(),
|
new BlockAuraDetector(),
|
||||||
new BlockCatalyst("conversion_catalyst", Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(2.5F)),
|
new BlockCatalyst("conversion_catalyst", Block.Properties.of(Material.STONE).sound(SoundType.STONE).hardnessAndResistance(2.5F)),
|
||||||
new BlockCatalyst("crushing_catalyst", Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(2.5F)),
|
new BlockCatalyst("crushing_catalyst", Block.Properties.of(Material.STONE).sound(SoundType.STONE).hardnessAndResistance(2.5F)),
|
||||||
new BlockFlowerGenerator(),
|
new BlockFlowerGenerator(),
|
||||||
new BlockPlacer(),
|
new BlockPlacer(),
|
||||||
new BlockHopperUpgrade(),
|
new BlockHopperUpgrade(),
|
||||||
new BlockFieldCreator(),
|
new BlockFieldCreator(),
|
||||||
new BlockOakGenerator(),
|
new BlockOakGenerator(),
|
||||||
new BlockImpl("infused_iron_block", Block.Properties.create(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(3F)),
|
new BlockImpl("infused_iron_block", Block.Properties.of(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(3F)),
|
||||||
new BlockOfferingTable(),
|
new BlockOfferingTable(),
|
||||||
new BlockPickupStopper(),
|
new BlockPickupStopper(),
|
||||||
new BlockSpawnLamp(),
|
new BlockSpawnLamp(),
|
||||||
|
@ -115,8 +114,8 @@ public final class ModRegistry {
|
||||||
new BlockGratedChute(),
|
new BlockGratedChute(),
|
||||||
new BlockAnimalSpawner(),
|
new BlockAnimalSpawner(),
|
||||||
new BlockAutoCrafter(),
|
new BlockAutoCrafter(),
|
||||||
new BlockImpl("gold_brick", Block.Properties.from(Blocks.STONE_BRICKS)),
|
new BlockImpl("gold_brick", Block.Properties.copy(Blocks.STONE_BRICKS)),
|
||||||
new BlockImpl("gold_nether_brick", Block.Properties.from(Blocks.NETHER_BRICKS)),
|
new BlockImpl("gold_nether_brick", Block.Properties.copy(Blocks.NETHER_BRICKS)),
|
||||||
new BlockMossGenerator(),
|
new BlockMossGenerator(),
|
||||||
new BlockTimeChanger(),
|
new BlockTimeChanger(),
|
||||||
new BlockGeneratorLimitRemover(),
|
new BlockGeneratorLimitRemover(),
|
||||||
|
@ -124,11 +123,11 @@ public final class ModRegistry {
|
||||||
new BlockPowderPlacer(),
|
new BlockPowderPlacer(),
|
||||||
new BlockFireworkGenerator(),
|
new BlockFireworkGenerator(),
|
||||||
new BlockProjectileGenerator(),
|
new BlockProjectileGenerator(),
|
||||||
new BlockDimensionRail("overworld", Level.field_234918_g_, Level.field_234919_h_, Level.field_234920_i_),
|
new BlockDimensionRail("overworld", Level.OVERWORLD, Level.NETHER, Level.END),
|
||||||
new BlockDimensionRail("nether", Level.field_234919_h_, Level.field_234918_g_),
|
new BlockDimensionRail("nether", Level.NETHER, Level.OVERWORLD),
|
||||||
new BlockDimensionRail("end", Level.field_234920_i_, Level.field_234918_g_),
|
new BlockDimensionRail("end", Level.END, Level.OVERWORLD),
|
||||||
new BlockBlastFurnaceBooster(),
|
new BlockBlastFurnaceBooster(),
|
||||||
new BlockImpl("nether_wart_mushroom", Block.Properties.from(Blocks.RED_MUSHROOM_BLOCK)),
|
new BlockImpl("nether_wart_mushroom", Block.Properties.copy(Blocks.RED_MUSHROOM_BLOCK)),
|
||||||
new BlockAnimalContainer(),
|
new BlockAnimalContainer(),
|
||||||
new BlockSnowCreator(),
|
new BlockSnowCreator(),
|
||||||
new BlockItemDistributor(),
|
new BlockItemDistributor(),
|
||||||
|
@ -142,7 +141,7 @@ public final class ModRegistry {
|
||||||
createFlowerPot(temp),
|
createFlowerPot(temp),
|
||||||
temp = new BlockAuraBloom("aura_mushroom", Blocks.MYCELIUM),
|
temp = new BlockAuraBloom("aura_mushroom", Blocks.MYCELIUM),
|
||||||
createFlowerPot(temp),
|
createFlowerPot(temp),
|
||||||
new BlockImpl("tainted_gold_block", Block.Properties.create(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(3F)),
|
new BlockImpl("tainted_gold_block", Block.Properties.of(Material.METAL).sound(SoundType.METAL).strength(3F)),
|
||||||
new BlockNetherGrass(),
|
new BlockNetherGrass(),
|
||||||
new BlockLight(),
|
new BlockLight(),
|
||||||
new BlockChorusGenerator(),
|
new BlockChorusGenerator(),
|
||||||
|
@ -173,10 +172,10 @@ public final class ModRegistry {
|
||||||
new ItemShovel("infused_iron_shovel", ModItemTier.INFUSED, 1.5F, -3.0F),
|
new ItemShovel("infused_iron_shovel", ModItemTier.INFUSED, 1.5F, -3.0F),
|
||||||
new ItemHoe("infused_iron_hoe", ModItemTier.INFUSED, -1),
|
new ItemHoe("infused_iron_hoe", ModItemTier.INFUSED, -1),
|
||||||
new ItemSword("infused_iron_sword", ModItemTier.INFUSED, 3, -2.4F),
|
new ItemSword("infused_iron_sword", ModItemTier.INFUSED, 3, -2.4F),
|
||||||
new ItemArmor("infused_iron_helmet", ModArmorMaterial.INFUSED, EquipmentSlotType.HEAD),
|
new ItemArmor("infused_iron_helmet", ModArmorMaterial.INFUSED, EquipmentSlot.HEAD),
|
||||||
new ItemArmor("infused_iron_chest", ModArmorMaterial.INFUSED, EquipmentSlotType.CHEST),
|
new ItemArmor("infused_iron_chest", ModArmorMaterial.INFUSED, EquipmentSlot.CHEST),
|
||||||
new ItemArmor("infused_iron_pants", ModArmorMaterial.INFUSED, EquipmentSlotType.LEGS),
|
new ItemArmor("infused_iron_pants", ModArmorMaterial.INFUSED, EquipmentSlot.LEGS),
|
||||||
new ItemArmor("infused_iron_shoes", ModArmorMaterial.INFUSED, EquipmentSlotType.FEET),
|
new ItemArmor("infused_iron_shoes", ModArmorMaterial.INFUSED, EquipmentSlot.FEET),
|
||||||
new ItemEye("eye"),
|
new ItemEye("eye"),
|
||||||
new ItemEye("eye_improved"),
|
new ItemEye("eye_improved"),
|
||||||
new ItemGoldFiber(),
|
new ItemGoldFiber(),
|
||||||
|
@ -218,13 +217,13 @@ public final class ModRegistry {
|
||||||
new ItemShovel("sky_shovel", ModItemTier.SKY, 1.5F, -3.0F),
|
new ItemShovel("sky_shovel", ModItemTier.SKY, 1.5F, -3.0F),
|
||||||
new ItemHoe("sky_hoe", ModItemTier.SKY, -1),
|
new ItemHoe("sky_hoe", ModItemTier.SKY, -1),
|
||||||
new ItemSword("sky_sword", ModItemTier.SKY, 3, -2.4F),
|
new ItemSword("sky_sword", ModItemTier.SKY, 3, -2.4F),
|
||||||
new ItemArmor("sky_helmet", ModArmorMaterial.SKY, EquipmentSlotType.HEAD),
|
new ItemArmor("sky_helmet", ModArmorMaterial.SKY, EquipmentSlot.HEAD),
|
||||||
new ItemArmor("sky_chest", ModArmorMaterial.SKY, EquipmentSlotType.CHEST),
|
new ItemArmor("sky_chest", ModArmorMaterial.SKY, EquipmentSlot.CHEST),
|
||||||
new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlotType.LEGS),
|
new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlot.LEGS),
|
||||||
new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlotType.FEET),
|
new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlot.FEET),
|
||||||
new ItemStructureFinder("fortress_finder", Structure.field_236378_n_, 0xba2800, 1024),
|
new ItemStructureFinder("fortress_finder", StructureFeature.NETHER_BRIDGE, 0xba2800, 1024),
|
||||||
new ItemStructureFinder("end_city_finder", Structure.field_236379_o_, 0xca5cd6, 1024),
|
new ItemStructureFinder("end_city_finder", StructureFeature.END_CITY, 0xca5cd6, 1024),
|
||||||
new ItemStructureFinder("outpost_finder", Structure.field_236366_b_, 0xab9f98, 2048),
|
new ItemStructureFinder("outpost_finder", StructureFeature.PILLAGER_OUTPOST, 0xab9f98, 2048),
|
||||||
new ItemBreakPrevention(),
|
new ItemBreakPrevention(),
|
||||||
new ItemPetReviver(),
|
new ItemPetReviver(),
|
||||||
new ItemNetheriteFinder()
|
new ItemNetheriteFinder()
|
||||||
|
@ -238,8 +237,8 @@ public final class ModRegistry {
|
||||||
add(new ModTileType<>(BlockEntityAuraBloom::new, "aura_bloom", ALL_ITEMS.stream().filter(i -> i instanceof BlockAuraBloom).toArray(IModItem[]::new)));
|
add(new ModTileType<>(BlockEntityAuraBloom::new, "aura_bloom", ALL_ITEMS.stream().filter(i -> i instanceof BlockAuraBloom).toArray(IModItem[]::new)));
|
||||||
|
|
||||||
for (IModItem item : ALL_ITEMS) {
|
for (IModItem item : ALL_ITEMS) {
|
||||||
if (item instanceof ModTileType)
|
if (item instanceof ModTileType type)
|
||||||
event.getRegistry().register(((ModTileType) item).type);
|
event.getRegistry().register(type.type);
|
||||||
}
|
}
|
||||||
Helper.populateObjectHolders(ModTileEntities.class, event.getRegistry());
|
Helper.populateObjectHolders(ModTileEntities.class, event.getRegistry());
|
||||||
}
|
}
|
||||||
|
@ -281,21 +280,21 @@ public final class ModRegistry {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
|
public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
|
||||||
event.getRegistry().registerAll(
|
event.getRegistry().registerAll(
|
||||||
EntityType.Builder.create(EntityMoverMinecart::new, EntityClassification.MISC)
|
EntityType.Builder.of(EntityMoverMinecart::new, MobCategory.MISC)
|
||||||
.size(1, 1).setShouldReceiveVelocityUpdates(true)
|
.sized(1, 1).setShouldReceiveVelocityUpdates(true)
|
||||||
.setTrackingRange(64).setUpdateInterval(3).immuneToFire().build(NaturesAura.MOD_ID + ":mover_minecart")
|
.setTrackingRange(64).setUpdateInterval(3).fireImmune().build(NaturesAura.MOD_ID + ":mover_minecart")
|
||||||
.setRegistryName("mover_cart"),
|
.setRegistryName("mover_cart"),
|
||||||
EntityType.Builder.create(EntityEffectInhibitor::new, EntityClassification.MISC)
|
EntityType.Builder.of(EntityEffectInhibitor::new, MobCategory.MISC)
|
||||||
.size(1, 1).setShouldReceiveVelocityUpdates(true)
|
.sized(1, 1).setShouldReceiveVelocityUpdates(true)
|
||||||
.setTrackingRange(64).setUpdateInterval(20).immuneToFire().build(NaturesAura.MOD_ID + ":effect_inhibitor")
|
.setTrackingRange(64).setUpdateInterval(20).fireImmune().build(NaturesAura.MOD_ID + ":effect_inhibitor")
|
||||||
.setRegistryName("effect_inhibitor"),
|
.setRegistryName("effect_inhibitor"),
|
||||||
EntityType.Builder.<EntityLightProjectile>create(EntityLightProjectile::new, EntityClassification.MISC)
|
EntityType.Builder.<EntityLightProjectile>of(EntityLightProjectile::new, MobCategory.MISC)
|
||||||
.size(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true)
|
.sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true)
|
||||||
.setTrackingRange(64).setUpdateInterval(3).immuneToFire().build(NaturesAura.MOD_ID + ":light_projectile")
|
.setTrackingRange(64).setUpdateInterval(3).fireImmune().build(NaturesAura.MOD_ID + ":light_projectile")
|
||||||
.setRegistryName("light_projectile"),
|
.setRegistryName("light_projectile"),
|
||||||
EntityType.Builder.create(EntityStructureFinder::new, EntityClassification.MISC)
|
EntityType.Builder.of(EntityStructureFinder::new, MobCategory.MISC)
|
||||||
.size(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true)
|
.sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true)
|
||||||
.setTrackingRange(64).setUpdateInterval(2).immuneToFire().build(NaturesAura.MOD_ID + ":structure_finder")
|
.setTrackingRange(64).setUpdateInterval(2).fireImmune().build(NaturesAura.MOD_ID + ":structure_finder")
|
||||||
.setRegistryName("structure_finder")
|
.setRegistryName("structure_finder")
|
||||||
);
|
);
|
||||||
Helper.populateObjectHolders(ModEntities.class, event.getRegistry());
|
Helper.populateObjectHolders(ModEntities.class, event.getRegistry());
|
||||||
|
@ -351,7 +350,7 @@ public final class ModRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Block createFlowerPot(Block block) {
|
public static Block createFlowerPot(Block block) {
|
||||||
Block.Properties props = Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0F);
|
Block.Properties props = Block.Properties.of(Material.MISCELLANEOUS).hardnessAndResistance(0F);
|
||||||
Block potted = new BlockFlowerPot(() -> (FlowerPotBlock) Blocks.FLOWER_POT, block::getBlock, props);
|
Block potted = new BlockFlowerPot(() -> (FlowerPotBlock) Blocks.FLOWER_POT, block::getBlock, props);
|
||||||
((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(block.getRegistryName(), () -> potted);
|
((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(block.getRegistryName(), () -> potted);
|
||||||
return potted;
|
return potted;
|
||||||
|
|
Loading…
Reference in a new issue