Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
NewJumper committed May 26, 2023
1 parent edb4c2a commit a5f1541
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public ResourceLocation getAnimationResource(EchoerEntity animatable) {
}

@Override
public void setLivingAnimations(EchoerEntity entity, Integer uniqueID, AnimationEvent customPredicate) {
super.setLivingAnimations(entity, uniqueID, customPredicate);
EntityModelData extraData = (EntityModelData) customPredicate.getExtraDataOfType(EntityModelData.class).get(0);
public void setCustomAnimations(EchoerEntity animatable, int instanceId, AnimationEvent animationEvent) {
super.setCustomAnimations(animatable, instanceId, animationEvent);
EntityModelData extraData = (EntityModelData) animationEvent.getExtraDataOfType(EntityModelData.class).get(0);
IBone head = getBone("head");
head.setRotationX(extraData.headPitch * ((float)Math.PI / 180F));
head.setRotationY(extraData.netHeadYaw * ((float)Math.PI / 180F));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ public void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockP


@Override
public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext
pContext) {
public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
if (!pState.is(DDBlocks.SCULK_JAW.get())) return super.getCollisionShape(pState, pLevel, pPos, pContext);

if (pState.getValue(ACTIVATED))
return Block.box(0, 0, 0, 0, 0, 0);
if (pState.getValue(ACTIVATED)) return Block.box(0, 0, 0, 0, 0, 0);

return super.getCollisionShape(pState, pLevel, pPos, pContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public void tick() {

@Override
public void registerControllers(AnimationData data) {
data.addAnimationController(new AnimationController<AncientChestEntity>
(this, "controller", 13, this::predicate));
data.addAnimationController(new AnimationController<>(this, "controller", 13, this::predicate));
}

private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
event.getController().transitionLengthTicks = 13;
if(this.wiggleTicks != 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.kyanite.deeperdarker.registry.enchantments;

import com.kyanite.deeperdarker.DeeperAndDarker;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ public class DDEntities {
public static final Supplier<EntityType<ShatteredEntity>> SHATTERED = RegistryHelper.registerEntity("shattered", ShatteredEntity::new, MobCategory.MONSTER, 0.85f, 2.45f, 10);
public static final Supplier<EntityType<SculkLeechEntity>> SCULK_LEECH = RegistryHelper.registerEntity("sculk_leech", SculkLeechEntity::new, MobCategory.MONSTER, 0.3f, 0.2f, 10);
public static final Supplier<EntityType<SculkSnapperEntity>> SCULK_SNAPPER = RegistryHelper.registerEntity("sculk_snapper", SculkSnapperEntity::new, MobCategory.MONSTER, 1, 1, 10);

public static final Supplier<EntityType<EchoerEntity>> ECHOER = RegistryHelper.registerEntity("echoer", EchoerEntity::new, MobCategory.MONSTER, 0.85f, 2.45f, 10);

// public static final Supplier<EntityType<ScavengerEntity>> SCAVENGER = RegistryHelper.registerEntity(
// "scavenger",
// ScavengerEntity::new, MobCategory.MONSTER, 1, 1, 10
// );
// public static final Supplier<EntityType<ScavengerEntity>> SCAVENGER = RegistryHelper.registerEntity("scavenger", ScavengerEntity::new, MobCategory.MONSTER, 1, 1, 10);

public static final Supplier<EntityType<SculkWormEntity>> SCULK_WORM = RegistryHelper.registerEntity("shriek_worm", SculkWormEntity::new, MobCategory.MONSTER, 1.5f, 5.7f, 10);
public static final Supplier<EntityType<DDBoat>> BOAT = RegistryHelper.registerEntity("boat", DDBoat::new, MobCategory.MISC, 1.375F, 0.5625F, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.npc.AbstractVillager;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.EnchantedBookItem;
import net.minecraft.world.item.ItemStack;
Expand All @@ -39,9 +38,7 @@
import software.bernie.geckolib3.core.manager.AnimationFactory;
import software.bernie.geckolib3.util.GeckoLibUtil;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class EchoerEntity extends AbstractVillager implements IAnimatable {
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
Expand All @@ -62,7 +59,7 @@ public static AttributeSupplier.Builder attributes() {

@Override
public void registerControllers(AnimationData data) {
data.addAnimationController(new AnimationController(this, "controller", 5, this::predicate));
data.addAnimationController(new AnimationController<>(this, "controller", 5, this::predicate));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static AttributeSupplier.Builder attributes() {

@Override
public void registerControllers(AnimationData data) {
data.addAnimationController(new AnimationController(this, "controller", 5, this::predicate));
data.addAnimationController(new AnimationController<>(this, "controller", 5, this::predicate));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import net.minecraft.world.phys.*;
import net.minecraft.world.phys.shapes.VoxelShape;

import java.util.Iterator;

public class ShriekProjectile extends AbstractArrow {
private final SculkSpreader sculkSpreader;

Expand Down Expand Up @@ -73,10 +71,8 @@ public void tick() {
VoxelShape voxelShape = blockState.getCollisionShape(this.level, blockPos);
if (!voxelShape.isEmpty()) {
vec32 = this.position();
Iterator var7 = voxelShape.toAabbs().iterator();

while(var7.hasNext()) {
AABB aABB = (AABB)var7.next();
for (AABB aABB : voxelShape.toAabbs()) {
if (aABB.move(blockPos).contains(vec32)) {
this.inGround = true;
break;
Expand All @@ -100,8 +96,8 @@ public void tick() {
Vec3 vec33 = this.position();
vec32 = vec33.add(vec3);
HitResult hitResult = this.level.clip(new ClipContext(vec33, vec32, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this));
if (((HitResult)hitResult).getType() != HitResult.Type.MISS) {
vec32 = ((HitResult)hitResult).getLocation();
if (hitResult.getType() != HitResult.Type.MISS) {
vec32 = hitResult.getLocation();
}

while(!this.isRemoved()) {
Expand All @@ -110,7 +106,7 @@ public void tick() {
hitResult = entityHitResult;
}

if (hitResult != null && ((HitResult)hitResult).getType() == HitResult.Type.ENTITY) {
if (hitResult != null && hitResult.getType() == HitResult.Type.ENTITY) {
Entity entity = ((EntityHitResult)hitResult).getEntity();
Entity entity2 = this.getOwner();
if (entity instanceof Player && entity2 instanceof Player && !((Player)entity2).canHarmPlayer((Player)entity)) {
Expand Down Expand Up @@ -155,17 +151,15 @@ public void tick() {
this.setXRot(lerpRotation(this.xRotO, this.getXRot()));
this.setYRot(lerpRotation(this.yRotO, this.getYRot()));
float m = 0.99F;
float n = 0.05F;
if (this.isInWater()) {
for(int o = 0; o < 4; ++o) {
float p = 0.25F;
this.level.addParticle(ParticleTypes.BUBBLE, h - e * 0.25, j - f * 0.25, k - g * 0.25, e, f, g);
}

m = this.getWaterInertia();
}

this.setDeltaMovement(vec3.scale((double)m));
this.setDeltaMovement(vec3.scale(m));
if (!this.isNoGravity() && !bl) {
Vec3 vec34 = this.getDeltaMovement();
this.setDeltaMovement(vec34.x, vec34.y - 0.05000000074505806, vec34.z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera

if (!level.isClientSide()) {
ShriekProjectile abstractarrowentity = new ShriekProjectile(level, player);
abstractarrowentity.shootFromRotation(player, player.getXRot(), player.getYRot(),
0.0F, 1.0F * 5.0F, 1.0F);
abstractarrowentity.shootFromRotation(player, player.getXRot(), player.getYRot(), 0, 5, 1);

abstractarrowentity.tickCount = 35;
abstractarrowentity.isNoGravity();

level.addFreshEntity(abstractarrowentity);
player.playSound(SoundEvents.WARDEN_SONIC_BOOM, 3.0F, 1.0F);
player.playSound(SoundEvents.WARDEN_SONIC_BOOM, 3, 1);
}
return InteractionResultHolder.consume(player.getItemInHand(interactionHand));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void onInitializeClient() {
BlockRenderLayerMap.INSTANCE.putBlock(DDBlocks.GLOOMY_GRASS.get(), RenderType.cutout());
BlockRenderLayerMap.INSTANCE.putBlock(DDBlocks.GLOOM_CACTUS.get(), RenderType.cutout());

EntityRendererRegistry.register(DDEntities.SHRIEK_PROJECTILE.get(), context -> new ShriekRenderer(context));
EntityRendererRegistry.register(DDEntities.SHRIEK_PROJECTILE.get(), ShriekRenderer::new);
EntityRendererRegistry.register(DDEntities.SHATTERED.get(), ShatteredRenderer::new);
EntityRendererRegistry.register(DDEntities.SCULK_LEECH.get(), SculkLeechRenderer::new);
EntityRendererRegistry.register(DDEntities.SCULK_SNAPPER.get(), SculkSnapperRenderer::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ public ResourceLocation getTextureResource(AncientChestEntity entity) {
}

@Override
public RenderType getRenderType(AncientChestEntity animatable, float partialTicks, PoseStack stack,
@Nullable MultiBufferSource renderTypeBuffer, @Nullable VertexConsumer vertexBuilder,
int packedLightIn, ResourceLocation textureLocation) {
public RenderType getRenderType(AncientChestEntity animatable, float partialTicks, PoseStack stack, @Nullable MultiBufferSource renderTypeBuffer, @Nullable VertexConsumer vertexBuilder, int packedLightIn, ResourceLocation textureLocation) {
return RenderType.entityTranslucent(this.getTextureResource(animatable));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
@Environment(EnvType.CLIENT)
public class SoulElytraArmorStandLayer extends ElytraLayer<ArmorStand, ArmorStandArmorModel> {
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation(DeeperAndDarker.MOD_ID, "textures/entity/soul_elytra.png");
private final ElytraModel elytraModel;
private final ElytraModel<ArmorStand> elytraModel;

public SoulElytraArmorStandLayer(ArmorStandRenderer rendererIn, EntityModelSet modelSet) {
super(rendererIn, modelSet);
this.elytraModel = new ElytraModel(modelSet.bakeLayer(ModelLayers.ELYTRA));
this.elytraModel = new ElytraModel<>(modelSet.bakeLayer(ModelLayers.ELYTRA));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
@Environment(EnvType.CLIENT)
public class SoulElytraLayer extends ElytraLayer<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> {
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation(DeeperAndDarker.MOD_ID, "textures/entity/soul_elytra.png");
private final ElytraModel elytraModel;
private final ElytraModel<AbstractClientPlayer> elytraModel;

public SoulElytraLayer(RenderLayerParent<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> renderLayerParent, EntityModelSet entityModelSet) {
super(renderLayerParent, entityModelSet);
this.elytraModel = new ElytraModel(entityModelSet.bakeLayer(ModelLayers.ELYTRA));
this.elytraModel = new ElytraModel<>(entityModelSet.bakeLayer(ModelLayers.ELYTRA));
}

@Override
@SuppressWarnings("unchecked")
public void render(@NotNull PoseStack poseStack, @NotNull MultiBufferSource multiBufferSource, int i, AbstractClientPlayer livingEntity, float f, float g, float h, float j, float k, float l) {
ItemStack itemStack = livingEntity.getItemBySlot(EquipmentSlot.CHEST);
if(itemStack.is(DDItems.SOUL_ELYTRA.get())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.concurrent.ConcurrentHashMap;

public class ArmorRenderer<T extends ArmorItem & IAnimatable> implements IGeoRenderer<T>, net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderer {
public static final Map<Class<? extends ArmorItem>, ArmorRenderer> renderers = new ConcurrentHashMap<>();
public static final Map<Class<? extends ArmorItem>, ArmorRenderer<?>> renderers = new ConcurrentHashMap<>();

static {
AnimationController.addModelFetcher((IAnimatable object) -> {
Expand Down Expand Up @@ -127,7 +127,7 @@ public void render(float partialTicks, PoseStack stack, VertexConsumer bufferIn,
AnimationEvent<T> itemEvent = new AnimationEvent<T>(this.currentArmorItem, 0, 0,
Minecraft.getInstance().getFrameTime(), false,
Arrays.asList(this.itemStack, this.entityLiving, this.armorSlot));
modelProvider.setLivingAnimations(currentArmorItem, this.getUniqueID(this.currentArmorItem), itemEvent);
modelProvider.setCustomAnimations(currentArmorItem, this.getInstanceId(this.currentArmorItem), itemEvent);

this.fitToBiped();
this.applySlot(armorSlot);
Expand Down Expand Up @@ -156,7 +156,7 @@ public void render(PoseStack stack, MultiBufferSource bufferIn, int packedLightI
AnimationEvent<T> itemEvent = new AnimationEvent<T>(this.currentArmorItem, 0, 0,
Minecraft.getInstance().getFrameTime(), false,
Arrays.asList(this.itemStack, this.entityLiving, this.armorSlot));
modelProvider.setLivingAnimations(currentArmorItem, this.getUniqueID(this.currentArmorItem), itemEvent);
modelProvider.setCustomAnimations(currentArmorItem, this.getInstanceId(this.currentArmorItem), itemEvent);

this.fitToBiped();
this.applySlot(armorSlot);
Expand Down Expand Up @@ -329,8 +329,7 @@ protected IBone getAndHideBone(String boneName) {
}

@Override
public Integer getUniqueID(T animatable) {
return Objects.hash(this.armorSlot, itemStack.getItem(), itemStack.getCount(),
itemStack.hasTag() ? itemStack.getTag().toString() : 1, this.entityLiving.getUUID().toString());
public int getInstanceId(T animatable) {
return Objects.hash(this.armorSlot, itemStack.getItem(), itemStack.getCount(), itemStack.hasTag() ? itemStack.getTag().toString() : 1, this.entityLiving.getUUID().toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.PlayState;
import software.bernie.geckolib3.core.builder.AnimationBuilder;
import software.bernie.geckolib3.core.builder.ILoopType;
import software.bernie.geckolib3.core.controller.AnimationController;
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
import software.bernie.geckolib3.util.GeckoLibUtil;

public class WardenArmorItem extends ArmorItem implements IAnimatable {

private final AnimationFactory factory = new AnimationFactory(this);
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);

public WardenArmorItem(ArmorMaterial pMaterial, EquipmentSlot pSlot, Properties pProperties) {
super(pMaterial, pSlot, pProperties);
Expand Down Expand Up @@ -49,7 +51,7 @@ public void registerControllers(AnimationData data) {
}

private <P extends IAnimatable> PlayState predicate(AnimationEvent<P> event) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("idle", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("idle", ILoopType.EDefaultLoopTypes.LOOP));
return PlayState.CONTINUE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -18,7 +17,6 @@
import java.util.function.Supplier;

@Mod.EventBusSubscriber(modid = DeeperAndDarker.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ForgeBoatModels {
private static boolean isInitialized = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,18 @@
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;

@OnlyIn(Dist.CLIENT)
public class SoulElytraArmorStandLayer extends ElytraLayer<ArmorStand, ArmorStandArmorModel> {
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation(DeeperAndDarker.MOD_ID, "textures/entity/soul_elytra.png");
private final ElytraModel elytraModel;
private final ElytraModel<ArmorStand> elytraModel;

public SoulElytraArmorStandLayer(ArmorStandRenderer rendererIn, EntityModelSet modelSet) {
super(rendererIn, modelSet);
this.elytraModel = new ElytraModel(modelSet.bakeLayer(ModelLayers.ELYTRA));
this.elytraModel = new ElytraModel<>(modelSet.bakeLayer(ModelLayers.ELYTRA));
}

@Override
@SuppressWarnings("unchecked")
public void render(@NotNull PoseStack poseStack, @NotNull MultiBufferSource multiBufferSource, int i, ArmorStand livingEntity, float f, float g, float h, float j, float k, float l) {
ItemStack itemStack = livingEntity.getItemBySlot(EquipmentSlot.CHEST);
if(itemStack.is(DDItems.SOUL_ELYTRA.get())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class SoulElytraLayer extends ElytraLayer<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> {
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation(DeeperAndDarker.MOD_ID, "textures/entity/soul_elytra.png");
private final ElytraModel elytraModel;
private final ElytraModel<AbstractClientPlayer> elytraModel;

public SoulElytraLayer(RenderLayerParent<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> arg, EntityModelSet entityModelSet) {
super(arg, entityModelSet);
this.elytraModel = new ElytraModel(entityModelSet.bakeLayer(ModelLayers.ELYTRA));
this.elytraModel = new ElytraModel<>(entityModelSet.bakeLayer(ModelLayers.ELYTRA));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ archives_base_name=deeperdarker
mod_version=1.1.6
maven_group=com.kyanite

architectury_version=6.3.56
architectury_version=6.5.82
forge_version=1.19.2-43.1.65
fabric_loader_version=0.14.11
fabric_api_version=0.68.0+1.19.2
Expand Down

0 comments on commit a5f1541

Please sign in to comment.