Skip to content

Commit

Permalink
Updated Dependencies. Bug fixes and BumbleBeast tweaks. Fixes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoni7 committed Nov 18, 2022
1 parent 95a016e commit 376492f
Show file tree
Hide file tree
Showing 35 changed files with 192 additions and 89 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ gradle.cache.push=false

modName=Dreamland
modId=dreamland
mod_version=1.2.0.5
mod_version=1.2.0.6

minecraft_version=1.19.2
forge_version=43.1.43
jei_version=11.+
terrablender_version=2.0.1.128
geckolib_version=3.1.28
geckolib_version=3.1.37
patchouli_version = 76
3 changes: 0 additions & 3 deletions src/main/java/com/github/dragoni7/dreamland/Dreamland.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@
public class Dreamland
{
public static final String MODID = "dreamland";

public static final Logger LOGGER = LogManager.getLogger();

public Dreamland() {

ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Config.SERVER_CONFIG);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_CONFIG);

Expand Down Expand Up @@ -74,7 +72,6 @@ public Dreamland() {
if(FMLEnvironment.dist == Dist.CLIENT) {
DreamlandClientEventHandler.init(modBus);
}

}

private void commonSetup(FMLCommonSetupEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void setLivingAnimations(BumbleBeastEntity entity, Integer uniqueID, Anim
IBone head = this.getAnimationProcessor().getBone("head");

EntityModelData extraData = (EntityModelData) customPredicate.getExtraDataOfType(EntityModelData.class).get(0);
head.setRotationY((extraData.netHeadYaw) * ((float) Math.PI / 340F));
head.setRotationY((extraData.netHeadYaw) * ((float) Math.PI / 300F));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.dragoni7.dreamland.client.render;

import com.github.dragoni7.dreamland.common.entities.mobs.BumbleBeastEntity;

import net.minecraft.client.renderer.entity.EntityRendererProvider.Context;
import software.bernie.geckolib3.model.AnimatedGeoModel;
import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer;

public class BumbleBeastEyeEntityRenderer extends GeoEntityRenderer<BumbleBeastEntity> {
public BumbleBeastEyeEntityRenderer(Context renderManager, AnimatedGeoModel<BumbleBeastEntity> modelProvider) {
super(renderManager, modelProvider);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.github.dragoni7.dreamland.client.render;

import com.github.dragoni7.dreamland.common.entities.mobs.BumbleBeastEntity;
import com.github.dragoni7.dreamland.util.DreamlandLoc;
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import software.bernie.geckolib3.renderers.geo.GeoLayerRenderer;
import software.bernie.geckolib3.renderers.geo.IGeoRenderer;

public class BumbleBeastEyeFeatureRenderer extends GeoLayerRenderer<BumbleBeastEntity> {
private final BumbleBeastEyeEntityRenderer bumbleBeastEyeRenderer;
private ResourceLocation bumbleBeastAngryLayer = DreamlandLoc.createLoc("textures/entity/bumble_beast_angry_layer.png");

public BumbleBeastEyeFeatureRenderer(IGeoRenderer<BumbleBeastEntity> entityRendererIn, BumbleBeastEyeEntityRenderer eyesEntityRenderer) {
super(entityRendererIn);
this.bumbleBeastEyeRenderer = eyesEntityRenderer;
}

@Override
public void render(PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn, BumbleBeastEntity bumbleBeastEntity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
if (bumbleBeastEntity.isAngry()) {
bumbleBeastEyeRenderer.render(getEntityModel().getModel(getEntityModel().getModelResource(bumbleBeastEntity)),
bumbleBeastEntity, partialTicks, RenderType.eyes(bumbleBeastAngryLayer), matrixStackIn, bufferIn, bufferIn.getBuffer(RenderType.eyes(bumbleBeastAngryLayer)), 15728640, OverlayTexture.RED_OVERLAY_V, 1.0F, 1.0F, 1.0F, 1.0F);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class BumbleBeastRender extends GeoEntityRenderer<BumbleBeastEntity> {

public BumbleBeastRender(Context renderManager) {
super(renderManager, new BumbleBeastModel());
this.addLayer(new BumbleBeastEyeFeatureRenderer(this, new BumbleBeastEyeEntityRenderer(renderManager, new BumbleBeastModel())));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import software.bernie.geckolib3.model.AnimatedGeoModel;
import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer;

public class LarvaEyesEntityRenderer extends GeoEntityRenderer<LarvaEntity>{
public class LarvaEyesEntityRenderer extends GeoEntityRenderer<LarvaEntity> {

public LarvaEyesEntityRenderer(Context renderManager, AnimatedGeoModel<LarvaEntity> modelProvider) {
super(renderManager, modelProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ public void render(PoseStack matrixStackIn, MultiBufferSource bufferIn, int pack
larvaEyesEntityRenderer.render(getEntityModel().getModel(getEntityModel().getModelResource(larvaEntity)),
larvaEntity, partialTicks, RenderType.eyes(txt), matrixStackIn, bufferIn, bufferIn.getBuffer(RenderType.eyes(txt)), 15728640, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import net.minecraft.world.level.block.state.BlockState;

public class AncientEggBlock extends Block implements EntityBlock {


// WIP
public AncientEggBlock(Properties properties) {
super(properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ protected Block getBodyBlock() {
}

public static ToIntFunction<BlockState> emission(int lightLevel) {
return (light) -> {
return lightLevel;
};
return (light) -> { return lightLevel; };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ protected GrowingPlantHeadBlock getHeadBlock() {
}

public static ToIntFunction<BlockState> emission(int lightLevel) {
return (light) -> {
return lightLevel;
};
return (light) -> { return lightLevel; };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public EmissiveHiveBlock(Properties properties) {
}

public static ToIntFunction<BlockState> emission(int lightLevel) {
return (light) -> {
return lightLevel;
};
return (light) -> { return lightLevel; };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public PushReaction getPistonPushReaction(BlockState state) {
return PushReaction.DESTROY;
}

public VoxelShape getShape(BlockState p_54889_, BlockGetter p_54890_, BlockPos p_54891_, CollisionContext p_54892_) {
return SHAPE;
public VoxelShape getShape(BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context) {
return SHAPE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ public GroundPlantBlock(Properties properties) {
public VoxelShape getShape(BlockState state, BlockGetter blockGetter, BlockPos pos, CollisionContext context) {
return SHAPE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player

}

@Override
public boolean biomeCheck() {
return true;
}

private void buildMembrane(BlockState state, Level level, BlockPos pos) {
int radius = getLevel(state) + 1;
Direction direction = state.getValue(HorizontalDirectionalBlock.FACING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import javax.annotation.Nullable;

import com.github.dragoni7.dreamland.Config;
import com.github.dragoni7.dreamland.common.world.biome.BiomeKeys;
import com.github.dragoni7.dreamland.core.registry.DreamlandEffects;

import net.minecraft.core.BlockPos;
Expand All @@ -26,12 +27,9 @@ public void playerDestroy(Level level, Player player, BlockPos pos, BlockState s

MobEffect antagonized = DreamlandEffects.ANTAGONIZED.get();

if (!biomeCheck()) {
// Only apply effect in Hive biome
if (level.getBiome(pos).is(BiomeKeys.HIVE)) {
player.addEffect(new MobEffectInstance(antagonized, Config.ANTAGONIZED_DURATION.get()));
}
}

public boolean biomeCheck() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public boolean isPathfindable(BlockState state, BlockGetter getter, BlockPos pos
}

public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource rand) {

if (counter % 60 == 0) {
level.addParticle(ParticleTypes.ELECTRIC_SPARK, pos.getX() + rand.nextDouble(), pos.getY() + 0.75D, pos.getZ() + rand.nextDouble(), 0.0D, 0.0D, 0.0D);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
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.EDefaultLoopTypes;
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 AncientEggTile extends BlockEntity implements IAnimatable {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,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.EDefaultLoopTypes;
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 BumbleBeastEntity extends Animal implements IAnimatable, NeutralMob {

private AnimationFactory factory = new AnimationFactory(this);
private AnimationFactory factory = GeckoLibUtil.createFactory(this);
private UUID persistentAngerTarget;
private static final Item EXCHANGE_ITEM = Items.HONEY_BLOCK;
private static final EntityDataAccessor<Boolean> HAS_HONEY = SynchedEntityData.defineId(BumbleBeastEntity.class, EntityDataSerializers.BOOLEAN);
Expand All @@ -79,11 +81,11 @@ public class BumbleBeastEntity extends Animal implements IAnimatable, NeutralMob
private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {

if(event.isMoving()) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bumble_beast.walk", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bumble_beast.walk", EDefaultLoopTypes.LOOP));
return PlayState.CONTINUE;
}

event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bumble_beast.idle", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bumble_beast.idle", EDefaultLoopTypes.LOOP));

return PlayState.CONTINUE;
}
Expand Down Expand Up @@ -114,21 +116,22 @@ public static AttributeSupplier.Builder customAttributes() {
.add(Attributes.ATTACK_DAMAGE, 5.0D)
.add(Attributes.JUMP_STRENGTH, 3.0D)
.add(Attributes.FOLLOW_RANGE, 48.0D)
.add(Attributes.KNOCKBACK_RESISTANCE, 2.0D)
.add(Attributes.KNOCKBACK_RESISTANCE, 4.0D)
.add(Attributes.ARMOR, 3.0D);
}

@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new BumbleBeastEntity.BumbleBeastAttackGoal(this, 1.3D, true));
this.goalSelector.addGoal(0, new BumbleBeastEntity.BumbleBeastAttackGoal(this));
this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.goalSelector.addGoal(2, new RandomLookAroundGoal(this));
this.goalSelector.addGoal(3, new WaterAvoidingRandomStrollGoal(this, 1.0F));
this.goalSelector.addGoal(4, new FloatGoal(this));
this.goalSelector.addGoal(5, new LeapAtTargetGoal(this, 0.4F));
this.targetSelector.addGoal(1, (new HurtByTargetGoal(this)).setAlertOthers());
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt));
this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true));

this.targetSelector.addGoal(1, (new BumbleBeastEntity.BumbleBeastHurtByOtherGoal(this)));
this.targetSelector.addGoal(2, (new BumbleBeastEntity.BumbleBeastBecomeAngryTargetGoal(this)));
this.targetSelector.addGoal(4, new ResetUniversalAngerTargetGoal<>(this, true));
}

public void addAdditionalSaveData(CompoundTag tag) {
Expand All @@ -141,6 +144,12 @@ public void readAdditionalSaveData(CompoundTag tag) {
this.setHasHoney(tag.getBoolean("HasHoney"));
}

protected void customServerAiStep() {
if (!this.level.isClientSide) {
this.updatePersistentAnger((ServerLevel)this.level, false);
}
}

public boolean requiresUpdateEveryTick() {
return true;
}
Expand Down Expand Up @@ -200,7 +209,12 @@ public MobType getMobType() {

@Override
protected float getStandingEyeHeight(Pose pose, EntityDimensions entityDimensions) {
return 1.25F;
return 1.25F;
}

@Override
public boolean isInvulnerableTo(DamageSource source) {
return source.isProjectile() || super.isInvulnerableTo(source);
}

@Override
Expand All @@ -221,6 +235,12 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) {
if (honeyAmount == 0) {
this.setHasHoney(false);
}

// Chance to target player when taking honey
if (RollBoolean.roll(6, random)) {
this.setTarget(player);
}

return InteractionResult.sidedSuccess(this.level.isClientSide);
} else {
return super.mobInteract(player, hand);
Expand Down Expand Up @@ -284,12 +304,57 @@ public AnimationFactory getFactory() {

class BumbleBeastAttackGoal extends MeleeAttackGoal {

public BumbleBeastAttackGoal(BumbleBeastEntity entity, double speedMult, boolean mustSee) {
super(entity, speedMult, mustSee);
public BumbleBeastAttackGoal(BumbleBeastEntity entity) {
super(entity, 1.4, true);
}

public boolean canUse() {
return super.canUse() && !this.mob.isVehicle() && BumbleBeastEntity.this.isAngry();
}

public boolean canContinueToUse() {
return super.canContinueToUse() && !this.mob.isVehicle() && BumbleBeastEntity.this.isAngry();
}

protected double getAttackReachSqr(LivingEntity entity) {
return (double)(10.0F + entity.getBbWidth());
return (double)(11.0F + entity.getBbWidth());
}
}

class BumbleBeastHurtByOtherGoal extends HurtByTargetGoal {

BumbleBeastHurtByOtherGoal(BumbleBeastEntity entity) {
super(entity);
}

public boolean canContinueToUse() {
return BumbleBeastEntity.this.isAngry() && super.canContinueToUse();
}
}

static class BumbleBeastBecomeAngryTargetGoal extends NearestAttackableTargetGoal<LivingEntity> {

BumbleBeastBecomeAngryTargetGoal(BumbleBeastEntity entity) {
super(entity, LivingEntity.class, 10, false, false, entity::isAngryAt);
}

public boolean canUse() {
return this.canTarget() && super.canUse();
}

public boolean canContinueToUse() {
boolean flag = this.canTarget();
if (flag && this.mob.getTarget() != null) {
return super.canContinueToUse();
} else {
this.targetMob = null;
return false;
}
}

private boolean canTarget() {
BumbleBeastEntity entity = (BumbleBeastEntity)this.mob;
return entity.isAngry();
}
}
}
Loading

0 comments on commit 376492f

Please sign in to comment.