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