Skip to content

Commit

Permalink
Updated Java to 0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-MacLean authored Apr 5, 2020
1 parent ac7de9f commit 6f12b17
Show file tree
Hide file tree
Showing 13 changed files with 373 additions and 52 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/herobrine/mod/HerobrineMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public static void registerEntities(@NotNull final RegistryEvent.Register<Entity
EntityRegistry.INFECTED_PIG_ENTITY,
EntityRegistry.INFECTED_CHICKEN_ENTITY,
EntityRegistry.INFECTED_SHEEP_ENTITY,
EntityRegistry.INFECTED_COW_ENTITY
EntityRegistry.INFECTED_COW_ENTITY,
EntityRegistry.INFECTED_MOOSHROOM_ENTITY
);
EntityRegistry.registerEntityWorldSpawns();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.herobrine.mod.client.renders;

import com.google.common.collect.Maps;
import com.herobrine.mod.HerobrineMod;
import com.herobrine.mod.client.renders.layers.InfectedMooshroomMushroomLayer;
import com.herobrine.mod.entities.InfectedCowEntity;
import com.herobrine.mod.entities.InfectedMooshroomEntity;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.client.renderer.entity.model.CowModel;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import org.jetbrains.annotations.NotNull;

import java.util.Map;

@OnlyIn(Dist.CLIENT)
public class InfectedMooshroomEntityRender extends MobRenderer<InfectedMooshroomEntity, CowModel<InfectedMooshroomEntity>> {
private static final Map<InfectedMooshroomEntity.Type, ResourceLocation> field_217774_a = Util.make(Maps.newHashMap(), (p_217773_0_) -> {
p_217773_0_.put(InfectedMooshroomEntity.Type.BROWN, HerobrineMod.location("textures/entity/infected_brown_mooshroom.png"));
p_217773_0_.put(InfectedMooshroomEntity.Type.RED, HerobrineMod.location("textures/entity/infected_red_mooshroom.png"));
});

public InfectedMooshroomEntityRender(EntityRendererManager renderManagerIn) {
super(renderManagerIn, new CowModel<>(), 0.7F);
this.addLayer(new InfectedMooshroomMushroomLayer<>(this));
}

@NotNull
public ResourceLocation getEntityTexture(@NotNull InfectedMooshroomEntity entity) {
return field_217774_a.get(entity.getMooshroomType());
}

public static class RenderFactory implements IRenderFactory {
@Override
public EntityRenderer<? super InfectedMooshroomEntity> createRenderFor(EntityRendererManager manager) {
return new InfectedMooshroomEntityRender(manager);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public static void registerEntityRenders() {
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_CHICKEN_ENTITY, new InfectedChickenEntityRender.RenderFactory());
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_SHEEP_ENTITY, new InfectedSheepEntityRender.RenderFactory());
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_COW_ENTITY, new InfectedCowEntityRender.RenderFactory());
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_MOOSHROOM_ENTITY, new InfectedMooshroomEntityRender.RenderFactory());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.herobrine.mod.client.renders.layers;

import com.herobrine.mod.entities.InfectedMooshroomEntity;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.entity.IEntityRenderer;
import net.minecraft.client.renderer.entity.LivingRenderer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.client.renderer.entity.model.CowModel;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;

@OnlyIn(Dist.CLIENT)
public class InfectedMooshroomMushroomLayer<T extends InfectedMooshroomEntity> extends LayerRenderer<T, CowModel<T>> {
public InfectedMooshroomMushroomLayer(IEntityRenderer<T, CowModel<T>> rendererIn) {
super(rendererIn);
}

public void render(@NotNull MatrixStack matrixStackIn, @NotNull IRenderTypeBuffer bufferIn, int packedLightIn, @NotNull T entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
if (!entitylivingbaseIn.isChild() && !entitylivingbaseIn.isInvisible()) {
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
BlockState blockstate = entitylivingbaseIn.getMooshroomType().getRenderState();
int i = LivingRenderer.getPackedOverlay(entitylivingbaseIn, 0.0F);
matrixStackIn.push();
matrixStackIn.translate(0.2F, -0.35F, 0.5D);
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-48.0F));
matrixStackIn.scale(-1.0F, -1.0F, 1.0F);
matrixStackIn.translate(-0.5D, -0.5D, -0.5D);
blockrendererdispatcher.renderBlock(blockstate, matrixStackIn, bufferIn, packedLightIn, i);
matrixStackIn.pop();
matrixStackIn.push();
matrixStackIn.translate(0.2F, -0.35F, 0.5D);
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(42.0F));
matrixStackIn.translate(0.1F, 0.0D, -0.6F);
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-48.0F));
matrixStackIn.scale(-1.0F, -1.0F, 1.0F);
matrixStackIn.translate(-0.5D, -0.5D, -0.5D);
blockrendererdispatcher.renderBlock(blockstate, matrixStackIn, bufferIn, packedLightIn, i);
matrixStackIn.pop();
matrixStackIn.push();
this.getEntityModel().getHead().translateRotate(matrixStackIn);
matrixStackIn.translate(0.0D, -0.7F, -0.2F);
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-78.0F));
matrixStackIn.scale(-1.0F, -1.0F, 1.0F);
matrixStackIn.translate(-0.5D, -0.5D, -0.5D);
blockrendererdispatcher.renderBlock(blockstate, matrixStackIn, bufferIn, packedLightIn, i);
matrixStackIn.pop();
}
}
}
18 changes: 11 additions & 7 deletions src/main/java/com/herobrine/mod/entities/HerobrineEntity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.herobrine.mod.entities;

import com.herobrine.mod.util.entities.EntityRegistry;
import com.herobrine.mod.util.entities.GenericSummoningRequiredEntityOnUpdateTick;
import com.herobrine.mod.util.entities.SummoningEntitySpawnSettings;
import com.herobrine.mod.util.entities.HerobrineEntityOnUpdateTick;
import com.herobrine.mod.util.misc.Variables;
import com.herobrine.mod.util.items.ItemList;
Expand All @@ -14,7 +14,6 @@
import net.minecraft.entity.projectile.PotionEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
Expand Down Expand Up @@ -160,22 +159,27 @@ public boolean attackEntityAsMob(Entity entityIn) {
return flag;
}

@Override
public void baseTick() {
@Override
public void baseTick() {
super.baseTick();
Entity entity = this;
{
Variables.WorldVariables.get(world).syncData(world);
java.util.HashMap<String, Object> $_dependencies = new java.util.HashMap<>();
$_dependencies.put("entity", entity);
$_dependencies.put("world", world);
GenericSummoningRequiredEntityOnUpdateTick.executeProcedure($_dependencies);
HerobrineEntityOnUpdateTick.executeProcedure($_dependencies);
}
}

@Override
public ILivingEntityData onInitialSpawn(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) {
Entity entity = this;
{
Variables.WorldVariables.get(world).syncData(world);
java.util.HashMap<String, Object> $_dependencies = new java.util.HashMap<>();
$_dependencies.put("entity", entity);
$_dependencies.put("world", world);
SummoningEntitySpawnSettings.executeProcedure($_dependencies);
}
spawnDataIn = super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag);
this.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(ItemList.bedrock_sword));
this.inventoryHandsDropChances[EquipmentSlotType.MAINHAND.getIndex()] = 0.0F;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
package com.herobrine.mod.entities;

import com.herobrine.mod.util.entities.EntityRegistry;
import com.herobrine.mod.util.entities.GenericSummoningRequiredEntityOnUpdateTick;
import com.herobrine.mod.util.entities.SummoningEntitySpawnSettings;
import com.herobrine.mod.util.misc.Variables;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.DamageSource;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;

public class InfectedChickenEntity extends MonsterEntity {
public float wingRotation;
public float destPos;
Expand Down Expand Up @@ -84,16 +87,16 @@ public void livingTick() {
}

@Override
public void baseTick() {
super.baseTick();
public ILivingEntityData onInitialSpawn(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) {
Entity entity = this;
{
Variables.WorldVariables.get(world).syncData(world);
java.util.HashMap<String, Object> $_dependencies = new java.util.HashMap<>();
$_dependencies.put("entity", entity);
$_dependencies.put("world", world);
GenericSummoningRequiredEntityOnUpdateTick.executeProcedure($_dependencies);
SummoningEntitySpawnSettings.executeProcedure($_dependencies);
}
return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag);
}

@Override
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/com/herobrine/mod/entities/InfectedCowEntity.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
package com.herobrine.mod.entities;

import com.herobrine.mod.util.entities.EntityRegistry;
import com.herobrine.mod.util.entities.GenericSummoningRequiredEntityOnUpdateTick;
import com.herobrine.mod.util.entities.SummoningEntitySpawnSettings;
import com.herobrine.mod.util.misc.Variables;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;

public class InfectedCowEntity extends MonsterEntity {
public InfectedCowEntity(EntityType<? extends InfectedCowEntity> type, World worldIn) {
super(type, worldIn);
Expand Down Expand Up @@ -59,16 +62,16 @@ public boolean attackEntityFrom(@NotNull DamageSource source, float amount) {
}

@Override
public void baseTick() {
super.baseTick();
public ILivingEntityData onInitialSpawn(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) {
Entity entity = this;
{
Variables.WorldVariables.get(world).syncData(world);
java.util.HashMap<String, Object> $_dependencies = new java.util.HashMap<>();
$_dependencies.put("entity", entity);
$_dependencies.put("world", world);
GenericSummoningRequiredEntityOnUpdateTick.executeProcedure($_dependencies);
SummoningEntitySpawnSettings.executeProcedure($_dependencies);
}
return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag);
}

@Override
Expand Down
Loading

0 comments on commit 6f12b17

Please sign in to comment.