Skip to content

Commit

Permalink
Re-implemented Bandit spawning
Browse files Browse the repository at this point in the history
Started on getting all other spawns working
Fixed Camel rendering
Other stuff
  • Loading branch information
GirafiStudios committed Oct 10, 2020
1 parent 88677e4 commit 09a6d57
Show file tree
Hide file tree
Showing 21 changed files with 269 additions and 247 deletions.
2 changes: 0 additions & 2 deletions src/main/java/com/teammetallurgy/atum/Atum.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.teammetallurgy.atum.misc.AtumConfig;
import com.teammetallurgy.atum.misc.AtumItemGroup;
import com.teammetallurgy.atum.network.NetworkHandler;
import com.teammetallurgy.atum.world.biome.AtumBiomeMaker;
import com.teammetallurgy.atum.world.biome.AtumBiomeProvider;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.RegistryKey;
Expand Down Expand Up @@ -52,7 +51,6 @@ private void setupCommon(FMLCommonSetupEvent event) {
MinecraftForge.EVENT_BUS.register(AtumStructures.PYRAMID_STRUCTURE);
KhnumiteFaceBlock.addDispenserSupport();
NetworkHandler.initialize();
AtumConfig.Mobs.ENTITY_TYPE.forEach(AtumBiomeMaker::initMobSpawns);
IntegrationHandler.INSTANCE.setup();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,67 +30,67 @@ public class CamelModel<T extends CamelEntity> extends EntityModel<T> {
public final ModelRenderer saddle1;
public final ModelRenderer saddle2;

public CamelModel() {
public CamelModel(float size) {
this.textureWidth = 128;
this.textureHeight = 64;
this.chestLeft = new ModelRenderer(this, 45, 41);
this.chestLeft.setRotationPoint(5.5F, 3.0F, 3.0F);
this.chestLeft.addBox(-3.0F, 0.0F, 0.0F, 8, 8, 3, 0.0F);
this.setRotateAngle(chestLeft, 0.0F, 1.5707963267948966F, 0.0F);
this.chestLeft.addBox(-3.0F, 0.0F, 0.0F, 8, 8, 3, size);
this.setRotateAngle(chestLeft, 0.0F, 1.5707963267948966F, size);
this.tail = new ModelRenderer(this, 94, 9);
this.tail.setRotationPoint(0.0F, 2.0F, 10.0F);
this.tail.addBox(-1.5F, -1.0F, 0.0F, 3, 1, 14, 0.0F);
this.tail.addBox(-1.5F, -1.0F, 0.0F, 3, 1, 14, size);
this.setRotateAngle(tail, -1.5707963267948966F, 0.0F, 0.0F);
this.snout = new ModelRenderer(this, 0, 0);
this.snout.setRotationPoint(0.0F, -10.0F, -8.0F);
this.snout.addBox(-3.0F, -5.0F, -6.0F, 6, 4, 6, 0.0F);
this.snout.addBox(-3.0F, -5.0F, -6.0F, 6, 4, 6, size);
this.body = new ModelRenderer(this, 29, 0);
this.body.setRotationPoint(0.0F, 5.0F, 2.0F);
this.body.addBox(-6.0F, -10.0F, -7.0F, 12, 18, 10, 0.0F);
this.body.addBox(-6.0F, -10.0F, -7.0F, 12, 18, 10, size);
this.setRotateAngle(body, 1.5707963267948966F, 0.0F, 0.0F);
this.hump2 = new ModelRenderer(this, 74, 16);
this.hump2.setRotationPoint(0.0F, 0.0F, 0.0F);
this.hump2.addBox(-3.0F, -5.0F, 6.0F, 6, 10, 2, 0.0F);
this.hump2.addBox(-3.0F, -5.0F, 6.0F, 6, 10, 2, size);
this.headModel = new ModelRenderer(this, 0, 14);
this.headModel.setRotationPoint(0.0F, 7.0F, -8.0F);
this.headModel.addBox(-3.0F, -16.0F, -8.0F, 6, 14, 6, 0.0F);
this.headModel.addBox(-3.0F, -16.0F, -8.0F, 6, 14, 6, size);
this.earRight = new ModelRenderer(this, 30, 0);
this.earRight.setRotationPoint(0.0F, 0.0F, 0.0F);
this.earRight.addBox(-4.0F, -16.0F, -6.0F, 1, 3, 2, 0.0F);
this.earRight.addBox(-4.0F, -16.0F, -6.0F, 1, 3, 2, size);
this.setRotateAngle(earRight, -0.08726646259971647F, 0.0F, 0.0F);
this.earLeft = new ModelRenderer(this, 30, 5);
this.earLeft.setRotationPoint(0.0F, 0.0F, 0.0F);
this.earLeft.addBox(3.0F, -16.0F, -6.0F, 1, 3, 2, 0.0F);
this.earLeft.addBox(3.0F, -16.0F, -6.0F, 1, 3, 2, size);
this.setRotateAngle(earLeft, -0.08726646259971647F, 0.0F, 0.0F);
this.chestRight = new ModelRenderer(this, 45, 28);
this.chestRight.setRotationPoint(-8.5F, 3.0F, 3.0F);
this.chestRight.addBox(-3.0F, 0.0F, 0.0F, 8, 8, 3, 0.0F);
this.chestRight.addBox(-3.0F, 0.0F, 0.0F, 8, 8, 3, size);
this.setRotateAngle(chestRight, 0.0F, 1.5707963267948966F, 0.0F);
this.neckheadModelLower = new ModelRenderer(this, 68, 30);
this.neckheadModelLower.setRotationPoint(0.0F, 0.0F, 0.0F);
this.neckheadModelLower.addBox(-4.0F, -4.0F, -5.0F, 8, 6, 6, 0.0F);
this.neckheadModelLower.addBox(-4.0F, -4.0F, -5.0F, 8, 6, 6, size);
this.hump1 = new ModelRenderer(this, 74, 0);
this.hump1.setRotationPoint(0.0F, 0.0F, 0.0F);
this.hump1.addBox(-4.0F, -6.0F, 3.0F, 8, 12, 3, 0.0F);
this.hump1.addBox(-4.0F, -6.0F, 3.0F, 8, 12, 3, size);
this.legBackRight = new ModelRenderer(this, 29, 29);
this.legBackRight.setRotationPoint(3.5F, 10.0F, -5.0F);
this.legBackRight.addBox(-2.0F, 0.0F, -2.0F, 4, 14, 4, 0.0F);
this.legBackRight.addBox(-2.0F, 0.0F, -2.0F, 4, 14, 4, size);
this.legBackLeft = new ModelRenderer(this, 29, 29);
this.legBackLeft.setRotationPoint(-3.5F, 10.0F, -5.0F);
this.legBackLeft.addBox(-2.0F, 0.0F, -2.0F, 4, 14, 4, 0.0F);
this.legBackLeft.addBox(-2.0F, 0.0F, -2.0F, 4, 14, 4, size);
this.legFrontRight = new ModelRenderer(this, 29, 29);
this.legFrontRight.setRotationPoint(3.5F, 10.0F, 6.0F);
this.legFrontRight.addBox(-2.0F, 0.0F, -2.0F, 4, 14, 4, 0.0F);
this.legFrontRight.addBox(-2.0F, 0.0F, -2.0F, 4, 14, 4, size);
this.legFrontLeft = new ModelRenderer(this, 29, 29);
this.legFrontLeft.setRotationPoint(-3.5F, 10.0F, 6.0F);
this.legFrontLeft.addBox(-2.0F, 0.0F, -2.0F, 4, 14, 4, 0.0F);
this.legFrontLeft.addBox(-2.0F, 0.0F, -2.0F, 4, 14, 4, size);
this.saddle1 = new ModelRenderer(this, 101, 32);
this.saddle1.setRotationPoint(0.0F, 4.9F, 2.0F);
this.saddle1.addBox(-4.0F, -6.0F, 6.0F, 8, 12, 2, 0.0F);
this.saddle1.addBox(-4.0F, -6.0F, 6.0F, 8, 12, 2, size);
this.setRotateAngle(saddle1, 1.5707963267948966F, 0.0F, 0.0F);
this.saddle2 = new ModelRenderer(this, 100, 48);
this.saddle2.setRotationPoint(0.0F, 5.0F, 2.0F);
this.saddle2.addBox(-5.0F, 2.0F, 8.0F, 10, 4, 4, 0.0F);
this.saddle2.addBox(-5.0F, 2.0F, 8.0F, 10, 4, 4, size);
this.setRotateAngle(saddle2, 1.5707963267948966F, 0.0F, 0.0F);
this.headModel.addChild(this.snout);
this.headModel.addChild(this.earRight);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.teammetallurgy.atum.client.render.entity.layer;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.teammetallurgy.atum.Atum;
import com.teammetallurgy.atum.client.model.entity.CamelModel;
import com.teammetallurgy.atum.entity.animal.CamelEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.IEntityRenderer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

import javax.annotation.Nonnull;

public class CamelArmorLayer extends LayerRenderer<CamelEntity, CamelModel<CamelEntity>> {
private final CamelModel<CamelEntity> model = new CamelModel<>(0.1F);

public CamelArmorLayer(IEntityRenderer<CamelEntity, CamelModel<CamelEntity>> entityRenderer) {
super(entityRenderer);
}

@Override
public void render(@Nonnull MatrixStack matrixStack, @Nonnull IRenderTypeBuffer buffer, int packedLight, CamelEntity camel, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
ItemStack armor = camel.getArmor();
if (!armor.isEmpty()) {
CamelEntity.ArmorType armorType = CamelEntity.ArmorType.getByItemStack(armor);
this.getEntityModel().copyModelAttributesTo(this.model);
this.model.setLivingAnimations(camel, limbSwing, limbSwingAmount, partialTicks);
this.model.setRotationAngles(camel, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
IVertexBuilder ivertexbuilder = buffer.getBuffer(RenderType.getEntityCutoutNoCull(armorType.getTexture()));
this.model.render(matrixStack, ivertexbuilder, packedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.teammetallurgy.atum.client.render.entity.layer;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.teammetallurgy.atum.Atum;
import com.teammetallurgy.atum.client.model.entity.CamelModel;
import com.teammetallurgy.atum.entity.animal.CamelEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.IEntityRenderer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.item.DyeColor;
import net.minecraft.util.ResourceLocation;

import javax.annotation.Nonnull;

public class CamelDecorLayer extends LayerRenderer<CamelEntity, CamelModel<CamelEntity>> {
private static final ResourceLocation[] CAMEL_DECOR_TEXTURES = new ResourceLocation[]{new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_white.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_orange.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_magenta.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_light_blue.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_yellow.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_lime.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_pink.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_gray.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_light_gray.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_cyan.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_purple.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_blue.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_brown.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_green.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_red.png"), new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_black.png")};
private final CamelModel<CamelEntity> model = new CamelModel<>(0.5F);

public CamelDecorLayer(IEntityRenderer<CamelEntity, CamelModel<CamelEntity>> entityRenderer) {
super(entityRenderer);
}

@Override
public void render(@Nonnull MatrixStack matrixStack, @Nonnull IRenderTypeBuffer buffer, int packedLight, CamelEntity camel, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
DyeColor dyeColor = camel.getColor();
ResourceLocation location;
if (dyeColor != null) {
location = CAMEL_DECOR_TEXTURES[dyeColor.getId()];

this.getEntityModel().copyModelAttributesTo(this.model);
this.model.setRotationAngles(camel, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
IVertexBuilder ivertexbuilder = buffer.getBuffer(RenderType.getEntityCutoutNoCull(location));
this.model.render(matrixStack, ivertexbuilder, packedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.google.common.collect.Maps;
import com.teammetallurgy.atum.Atum;
import com.teammetallurgy.atum.client.model.entity.CamelModel;
import com.teammetallurgy.atum.client.render.entity.layer.CamelArmorLayer;
import com.teammetallurgy.atum.client.render.entity.layer.CamelDecorLayer;
import com.teammetallurgy.atum.entity.animal.CamelEntity;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
Expand All @@ -18,10 +18,11 @@
@OnlyIn(Dist.CLIENT)
public class CamelRender extends MobRenderer<CamelEntity, CamelModel<CamelEntity>> {
private static final Map<String, ResourceLocation> CACHE = Maps.newHashMap();
private static final ResourceLocation GIRAFI = new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_girafi.png");

public CamelRender(EntityRendererManager renderManager) {
super(renderManager, new CamelModel<>(), 0.7F);
super(renderManager, new CamelModel<>(0.0F), 0.7F);
this.addLayer(new CamelDecorLayer(this));
this.addLayer(new CamelArmorLayer(this));
}

@Override
Expand All @@ -31,27 +32,16 @@ public ResourceLocation getEntityTexture(@Nonnull CamelEntity camel) {

ResourceLocation location = CACHE.get(textureName);
if (location == null) {
location = new ResourceLocation(textureName);
String[] texturePath = new String[3];
texturePath[0] = new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_" + camel.getVariant()) + ".png";
if (camel.hasCustomName() && camel.getCustomName() != null) {
String customName = camel.getCustomName().getString();
if (customName.equalsIgnoreCase("girafi")) {
texturePath[0] = GIRAFI.toString();
}
}
location = new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_" + textureName + ".png");

/*String[] texturePath = new String[3];
ItemStack armor = camel.getArmor();
if (!armor.isEmpty()) {
CamelEntity.ArmorType armorType = CamelEntity.ArmorType.getByItemStack(armor);
texturePath[1] = armorType.getTextureName();
}

DyeColor color = camel.getColor();
if (color != null) {
texturePath[2] = new ResourceLocation(Atum.MOD_ID, "textures/entity/camel_carpet/camel_carpet_" + color.getString()) + ".png";
}
//Minecraft.getInstance().getTextureManager().loadTexture(location, new LayeredTexture(texturePath)); //TODO Test if z-fighting is present without this
}*/
CACHE.put(textureName, location);
System.out.println(location);
}
return location;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void registerData() {
}

public static AttributeModifierMap.MutableAttribute getAttributes() {
return MobEntity.func_233666_p_().createMutableAttribute(Attributes.MAX_HEALTH, 20.0F).createMutableAttribute(Attributes.FOLLOW_RANGE, 36.0D).createMutableAttribute(Attributes.HORSE_JUMP_STRENGTH, 0.0D);
return MobEntity.func_233666_p_().createMutableAttribute(Attributes.MAX_HEALTH, 20.0F).createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.225F).createMutableAttribute(Attributes.FOLLOW_RANGE, 36.0D).createMutableAttribute(Attributes.HORSE_JUMP_STRENGTH, 0.0D);
}

private float getCamelMaxHealth() {
Expand Down Expand Up @@ -118,6 +118,7 @@ protected void registerGoals() {
this.goalSelector.addGoal(3, new PanicGoal(this, 1.2D));
this.goalSelector.addGoal(4, new BreedGoal(this, 1.0D));
this.goalSelector.addGoal(5, new FollowParentGoal(this, 1.0D));
this.goalSelector.addGoal(5, new FollowParentGoal(this, 1.0D));
this.goalSelector.addGoal(6, new WaterAvoidingRandomWalkingGoal(this, 0.7D));
this.goalSelector.addGoal(7, new LookAtGoal(this, PlayerEntity.class, 6.0F));
this.goalSelector.addGoal(8, new LookRandomlyGoal(this));
Expand Down Expand Up @@ -190,7 +191,7 @@ private int getCamelVariantBiome() {
Biome biome = this.world.getBiome(this.getPosition());
int chance = this.rand.nextInt(100);

Optional<RegistryKey<Biome>> optional = world.func_241828_r().getRegistry(Registry.BIOME_KEY).getOptionalKey(biome); //TODO Test
Optional<RegistryKey<Biome>> optional = world.func_241828_r().getRegistry(Registry.BIOME_KEY).getOptionalKey(biome);

if (optional.isPresent()) {
RegistryKey<Biome> biomeKey = optional.get();
Expand Down Expand Up @@ -220,17 +221,6 @@ public String getTexture() {
this.textureName = "girafi";
}
}

ItemStack armor = this.getArmor();
if (!armor.isEmpty()) {
CamelEntity.ArmorType armorType = CamelEntity.ArmorType.getByItemStack(armor);
this.textureName += "_" + armorType.getName();
}

DyeColor color = this.getColor();
if (color != null) {
this.textureName += "_" + color.getString();
}
}
return this.textureName;
}
Expand Down Expand Up @@ -717,7 +707,7 @@ public enum ArmorType {
GOLD(7, "gold"),
DIAMOND(11, "diamond");

private final String textureName;
private final ResourceLocation textureName;
private final String typeName;
private final int protection;

Expand All @@ -730,7 +720,7 @@ public enum ArmorType {
ArmorType(int armorStrength, String typeName) {
this.protection = armorStrength;
this.typeName = typeName;
this.textureName = new ResourceLocation(Atum.MOD_ID, "textures/entity/armor/camel_armor_" + typeName) + ".png";
this.textureName = new ResourceLocation(Atum.MOD_ID, "textures/entity/armor/camel_armor_" + typeName + ".png");
}

public int getProtection() {
Expand All @@ -741,7 +731,7 @@ public String getName() {
return typeName;
}

public String getTextureName() {
public ResourceLocation getTexture() {
return textureName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ protected ResourceLocation getLootTable() {
}

@Override
protected int getRandomRabbitType(IWorld world) { //TODO
protected int getRandomRabbitType(IWorld world) {
Biome biome = world.getBiome(this.getPosition());
int i = this.rand.nextInt(100);

Optional<RegistryKey<Biome>> optional = world.func_241828_r().getRegistry(Registry.BIOME_KEY).getOptionalKey(biome); //TODO Test
Optional<RegistryKey<Biome>> optional = world.func_241828_r().getRegistry(Registry.BIOME_KEY).getOptionalKey(biome);

if (optional.isPresent()) {
RegistryKey<Biome> biomeKey = optional.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ public void readAdditional(@Nonnull CompoundNBT compound) {
this.setVariant(compound.getInt("Variant"));
}
this.canPatrol = compound.getBoolean("CanPatrol");
this.leadingEntity = compound.getUniqueId("LeadingEntity");
if (compound.hasUniqueId("LeadingEntity")) {
this.leadingEntity = compound.getUniqueId("LeadingEntity");
}
}

public static class BanditPatrolGoal<T extends BanditBaseEntity> extends Goal {
Expand Down

0 comments on commit 09a6d57

Please sign in to comment.