Fix models

This commit is contained in:
Runemoro 2017-12-17 03:10:32 -05:00
parent d9c2c70616
commit cc952a642f
14 changed files with 64 additions and 61 deletions

View file

@ -1,32 +1,29 @@
package com.zixiken.dimdoors.client;
import com.zixiken.dimdoors.client.sound.DDSounds;
import com.zixiken.dimdoors.shared.DDProxyCommon;
import com.zixiken.dimdoors.shared.ModelManager;
import com.zixiken.dimdoors.shared.entities.MobMonolith;
import com.zixiken.dimdoors.shared.entities.RenderMobObelisk;
import com.zixiken.dimdoors.shared.entities.EntityMonolith;
import com.zixiken.dimdoors.shared.entities.RenderMonolith;
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
import com.zixiken.dimdoors.shared.tileentities.TileEntityFloatingRift;
import com.zixiken.dimdoors.shared.tileentities.TileEntityHorizontalEntranceRift;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class DDProxyClient extends DDProxyCommon {
@Override
public void onPreInitialization(FMLPreInitializationEvent event) {
super.onPreInitialization(event);
MinecraftForge.EVENT_BUS.register(DDSounds.class);
//ModelManager.addCustomStateMappers();
ModelManager.registerModelVariants();
ModelManager.addCustomStateMappers();
registerRenderers();
}
@ -40,7 +37,7 @@ public class DDProxyClient extends DDProxyCommon {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVerticalEntranceRift.class, new TileEntityVerticalEntranceRiftRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHorizontalEntranceRift.class, new TileEntityHorizontalEntranceRiftRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFloatingRift.class, new TileEntityFloatingRiftRenderer());
RenderingRegistry.registerEntityRenderingHandler(MobMonolith.class, manager -> new RenderMobObelisk(manager, 0.5f));
RenderingRegistry.registerEntityRenderingHandler(EntityMonolith.class, manager -> new RenderMonolith(manager, 0.5f));
}
@Override

View file

@ -1,7 +1,8 @@
package com.zixiken.dimdoors.shared;
package com.zixiken.dimdoors.client;
import com.zixiken.dimdoors.shared.blocks.ModBlocks;
import com.zixiken.dimdoors.shared.items.ModItems;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelBakery;
@ -10,9 +11,12 @@ import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import static net.minecraft.item.Item.getItemFromBlock;
@SideOnly(Side.CLIENT)
public class ModelManager {
public static void registerModels() {
@ -41,7 +45,7 @@ public class ModelManager {
}
public static void registerModelVariants() {
ModelBakery.registerItemVariants(getItemFromBlock(ModBlocks.FABRIC),
ModelBakery.registerItemVariants(ModItems.FABRIC, // we can't use getItemForBlock yet since items have not yet been registered (and this can't be run later)
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_reality"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_ancient"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_altered"),

View file

@ -25,7 +25,6 @@ public class CraftingManager {
index++;
recipeLoc = new ResourceLocation(DimDoors.MODID, baseLoc.getResourcePath() + "_" + index);
}
DimDoors.log(CraftingManager.class, "Registered recipe " + recipeLoc);
return recipeLoc;
}
@ -41,7 +40,6 @@ public class CraftingManager {
ResourceLocation location = getNameForRecipe(output);
ShapedOreRecipe recipe = new ShapedOreRecipe(location, output, params);
recipe.setRegistryName(location);
GameData.register_impl(recipe);
return recipe;
}
@ -73,7 +71,7 @@ public class CraftingManager {
event.getRegistry().register(makeShapedOreRecipe(new ItemStack(ModItems.QUARTZ_DOOR, 1),
"yy", "yy", "yy", 'y', "quartz"));
event.getRegistry().register(makeShapedRecipe(new ItemStack(ModItems.RIFT_BLADE),
"y", "y", "x", 'y', ModItems.STABLE_FABRIC, 'x', Items.IRON_SWORD));

View file

@ -1,19 +1,14 @@
package com.zixiken.dimdoors.shared;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.blocks.BlockDimDoorBase;
import com.zixiken.dimdoors.shared.blocks.ModBlocks;
import com.zixiken.dimdoors.shared.entities.MobMonolith;
import com.zixiken.dimdoors.shared.entities.EntityMonolith;
import com.zixiken.dimdoors.shared.items.ModItems;
import com.zixiken.dimdoors.shared.sound.ModSounds;
import com.zixiken.dimdoors.shared.tileentities.*;
import com.zixiken.dimdoors.shared.util.DefaultSchematicGenerator;
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@ -27,7 +22,8 @@ public abstract class DDProxyCommon implements IDDProxy {
MinecraftForge.EVENT_BUS.register(new DDEventHandler());
MinecraftForge.EVENT_BUS.register(ModBlocks.class);
MinecraftForge.EVENT_BUS.register(ModItems.class);
MinecraftForge.EVENT_BUS.register(CraftingManager.class);
MinecraftForge.EVENT_BUS.register(CraftingManager.class); // TODO: ModRecipes?
MinecraftForge.EVENT_BUS.register(ModSounds.class);
DimDoorDimensions.init();
@ -35,7 +31,7 @@ public abstract class DDProxyCommon implements IDDProxy {
GameRegistry.registerTileEntity(TileEntityFloatingRift.class, "TileEntityFloatingRift");
GameRegistry.registerTileEntity(TileEntityHorizontalEntranceRift.class, "TileEntityHorizontalEntranceRift");
EntityRegistry.registerModEntity(new ResourceLocation(DimDoors.MODID, "mob_monolith"), MobMonolith.class, "monolith", 0, DimDoors.instance, 70, 1, true);
EntityRegistry.registerModEntity(new ResourceLocation(DimDoors.MODID, "mob_monolith"), EntityMonolith.class, "monolith", 0, DimDoors.instance, 70, 1, true);
EntityRegistry.registerEgg(new ResourceLocation(DimDoors.MODID, "mob_monolith"), 0, 0xffffff);
}

View file

@ -1,6 +1,6 @@
package com.zixiken.dimdoors.shared.entities;
import com.zixiken.dimdoors.client.sound.DDSounds;
import com.zixiken.dimdoors.shared.sound.ModSounds;
import com.zixiken.dimdoors.shared.DDConfig;
import com.zixiken.dimdoors.shared.util.Location;
import com.zixiken.dimdoors.shared.util.TeleportUtils;
@ -27,7 +27,7 @@ import java.util.List;
import static net.minecraft.network.datasync.DataSerializers.*;
public class MobMonolith extends EntityFlying implements IMob {
public class EntityMonolith extends EntityFlying implements IMob {
private static final int MAX_AGGRO = 250;
private static final int MAX_AGGRO_CAP = 100;
@ -35,7 +35,7 @@ public class MobMonolith extends EntityFlying implements IMob {
private static final int MAX_TEXTURE_STATE = 18;
private static final int MAX_SOUND_COOLDOWN = 200;
private static final int MAX_AGGRO_RANGE = 35;
private static final DataParameter<Integer> AGGRO = EntityDataManager.createKey(MobMonolith.class, VARINT);
private static final DataParameter<Integer> AGGRO = EntityDataManager.createKey(EntityMonolith.class, VARINT);
private static final float WIDTH = 3f;
private static final float HEIGHT = 3f;
@ -46,7 +46,7 @@ public class MobMonolith extends EntityFlying implements IMob {
private int soundTime = 0;
private final int aggroCap;
public MobMonolith(World world)
public EntityMonolith(World world)
{
super(world);
setSize(WIDTH, HEIGHT);
@ -160,7 +160,7 @@ public class MobMonolith extends EntityFlying implements IMob {
aggro = 0;
Location destination = WorldProviderLimbo.getLimboSkySpawn(player); // TODO: teleportToLimbo method
TeleportUtils.teleport(player, destination, 0, 0);
player.world.playSound(player, player.getPosition(), DDSounds.CRACK, SoundCategory.HOSTILE, 13, 1);
player.world.playSound(player, player.getPosition(), ModSounds.CRACK, SoundCategory.HOSTILE, 13, 1);
}
}
}
@ -220,16 +220,16 @@ public class MobMonolith extends EntityFlying implements IMob {
float aggroPercent = getAggroProgress();
if (soundTime <= 0)
{
playSound(DDSounds.MONK, 1F, 1F);
playSound(ModSounds.MONK, 1F, 1F);
soundTime = 100;
}
if (aggroPercent > 0.70 && soundTime < 100)
{
world.playSound(entityPlayer, entityPlayer.getPosition(), DDSounds.TEARING, SoundCategory.HOSTILE, 1F, (float) (1 + rand.nextGaussian()));
world.playSound(entityPlayer, entityPlayer.getPosition(), ModSounds.TEARING, SoundCategory.HOSTILE, 1F, (float) (1 + rand.nextGaussian()));
soundTime = 100 + rand.nextInt(75);
}
if (aggroPercent > 0.80 && soundTime < MAX_SOUND_COOLDOWN) {
world.playSound(entityPlayer, entityPlayer.getPosition(), DDSounds.TEARING, SoundCategory.HOSTILE, 7, 1F);
world.playSound(entityPlayer, entityPlayer.getPosition(), ModSounds.TEARING, SoundCategory.HOSTILE, 7, 1F);
soundTime = 250;
}
soundTime--;

View file

@ -11,12 +11,12 @@ import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT)
public class ModelMobObelisk extends ModelBase {
public class ModelMonolith extends ModelBase {
ModelRenderer wholeMonolith;
Random rand = new Random();
public ModelMobObelisk() {
public ModelMonolith() {
textureWidth = 256;
textureHeight = 256;
@ -26,7 +26,7 @@ public class ModelMobObelisk extends ModelBase {
@Override
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
MobMonolith monolith = (MobMonolith) entityIn;
EntityMonolith monolith = (EntityMonolith) entityIn;
setRotationAngles(0, 0, 0, 0, 0,0, monolith);
GL11.glScalef(monolith.getRenderSizeModifier(), monolith.getRenderSizeModifier(), monolith.getRenderSizeModifier());

View file

@ -17,9 +17,9 @@ import java.util.Arrays;
import java.util.List;
@SideOnly(Side.CLIENT)
public class RenderMobObelisk extends RenderLiving<MobMonolith> {
public class RenderMonolith extends RenderLiving<EntityMonolith> {
protected ModelMobObelisk obeliskModel;
protected ModelMonolith obeliskModel;
protected static final List<ResourceLocation> monolith_textures = Arrays.asList(
new ResourceLocation(DimDoors.MODID + ":textures/mobs/monolith/monolith0.png"),
@ -42,13 +42,13 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith> {
new ResourceLocation(DimDoors.MODID + ":textures/mobs/monolith/monolith17.png"),
new ResourceLocation(DimDoors.MODID + ":textures/mobs/monolith/monolith18.png"));
public RenderMobObelisk(RenderManager manager, float f) {
super(manager, new ModelMobObelisk(), f);
obeliskModel = (ModelMobObelisk) mainModel;
public RenderMonolith(RenderManager manager, float f) {
super(manager, new ModelMonolith(), f);
obeliskModel = (ModelMonolith) mainModel;
}
@Override
public void doRender(MobMonolith monolith, double x, double y, double z, float entityYaw, float partialTicks) {
public void doRender(EntityMonolith monolith, double x, double y, double z, float entityYaw, float partialTicks) {
final float minScaling = 0;
final float maxScaling = 0.1f;
@ -71,7 +71,7 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith> {
//this.renderLeash(entity, x, y, z, par8, par9);
}
public void render(MobMonolith par1EntityLivingBase, double x, double y, double z, float par8, float par9)
public void render(EntityMonolith par1EntityLivingBase, double x, double y, double z, float par8, float par9)
{
if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre<>(par1EntityLivingBase, this, 1, x, y, z))) return;
GL11.glPushMatrix();
@ -122,7 +122,7 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith> {
}
@Override
protected ResourceLocation getEntityTexture(MobMonolith monolith) {
protected ResourceLocation getEntityTexture(EntityMonolith monolith) {
return monolith_textures.get(monolith.getTextureState()); //return new ResourceLocation(DimDoors.MODID + ":textures/mobs/monolith/monolith" + monolith.getTextureState() + ".png");
}
}

View file

@ -27,6 +27,9 @@ public class ModItems {
public static final ItemRiftConnectionTool RIFT_CONNECTION_TOOL = new ItemRiftConnectionTool();
public static final ItemRiftBlade RIFT_BLADE = new ItemRiftBlade();
// This needs to exist to be used in ModelManager.java before items are registered (preinitialization)
public static final ItemBlockFabric FABRIC = new ItemBlockFabric();
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
event.getRegistry().registerAll(
@ -44,7 +47,7 @@ public class ModItems {
// ItemBlocks
event.getRegistry().registerAll(
new ItemBlockFabric(),
FABRIC,
new ItemBlock(ModBlocks.DIMENSIONAL_TRAPDOOR).setRegistryName(ModBlocks.DIMENSIONAL_TRAPDOOR.getRegistryName()),
new ItemBlock(ModBlocks.RIFT).setRegistryName(ModBlocks.RIFT.getRegistryName()));
}

View file

@ -67,7 +67,7 @@ public class RiftRegistry extends WorldSavedData {
@Override
public void readFromNBT(NBTTagCompound nbt) {
NBTTagList availableLinksNBT = (NBTTagList) nbt.getTag("availableLinks");
NBTTagList availableLinksNBT = (NBTTagList) nbt.getTag("availableLinks"); // TODO: figure out why this is sometimes null
for (NBTBase availableLinkNBT : availableLinksNBT) {
AvailableLinkInfo link = new AvailableLinkInfo();
link.readFromNBT((NBTTagCompound) availableLinkNBT);

View file

@ -26,6 +26,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import java.util.*;
@ -451,6 +453,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
}
@Override
@SideOnly(Side.CLIENT)
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
deserializeNBT(pkt.getNbtCompound());
}

View file

@ -1,4 +1,4 @@
package com.zixiken.dimdoors.client.sound;
package com.zixiken.dimdoors.shared.sound;
import com.zixiken.dimdoors.DimDoors;
import net.minecraft.util.ResourceLocation;
@ -6,13 +6,14 @@ import net.minecraft.util.SoundEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class DDSounds {
public class ModSounds {
// Don't forget to change sounds.json too if you're changing an ID!
public static final SoundEvent CRACK = create("crack");
public static final SoundEvent CREEPY = create("creepy");
public static final SoundEvent DOOR_LOCKED = create("door_locked");
public static final SoundEvent DOOR_LOCK_REMOVED = create("door_lock_removed");
public static final SoundEvent KEY_LOCK = create("key");
public static final SoundEvent KEY_LOCK = create("key_lock");
public static final SoundEvent KEY_UNLOCKED = create("key_unlock");
public static final SoundEvent MONK = create("monk");
public static final SoundEvent RIFT = create("rift");

View file

@ -30,19 +30,20 @@ public class DimDoorDimensions {
@Getter private static int dungeonDimID;
public static void init() {
// Lowercase names because all minecraft dimensions are lowercase, _pockets suffix to make it clear what the world is
minPocketDimID = DDConfig.getBaseDimID();
int dimID = minPocketDimID;
LIMBO = DimensionType.register("Limbo", "_limbo", dimID, WorldProviderLimbo.class, false);
LIMBO = DimensionType.register("limbo", "_limbo", dimID, WorldProviderLimbo.class, false);
limboDimID = dimID++;
pocketTypes.add(EnumPocketType.PRIVATE);
pocketDimensionTypes.put(EnumPocketType.PRIVATE, DimensionType.register("Private", "_private", dimID, WorldProviderPersonalPocket.class, false));
pocketDimensionTypes.put(EnumPocketType.PRIVATE, DimensionType.register("private_pockets", "_private", dimID, WorldProviderPersonalPocket.class, false));
privateDimID = dimID++;
pocketTypes.add(EnumPocketType.PUBLIC);
pocketDimensionTypes.put(EnumPocketType.PUBLIC, DimensionType.register("Public", "_public", dimID, WorldProviderPublicPocket.class, false));
pocketDimensionTypes.put(EnumPocketType.PUBLIC, DimensionType.register("public_pockets", "_public", dimID, WorldProviderPublicPocket.class, false));
publicDimID = dimID++;
maxPocketDimID = dimID;
pocketTypes.add(EnumPocketType.DUNGEON);
pocketDimensionTypes.put(EnumPocketType.DUNGEON, DimensionType.register("Dungeon", "_dungeon", dimID, WorldProviderDungeonPocket.class, false));
pocketDimensionTypes.put(EnumPocketType.DUNGEON, DimensionType.register("dungeon_pockets", "_dungeon", dimID, WorldProviderDungeonPocket.class, false));
dungeonDimID = dimID;
registerDimension(LIMBO);

View file

@ -1,3 +1,3 @@
{
"parent": "builtin/missing"
"parent": "builtin/generated"
}

View file

@ -1,15 +1,15 @@
{
"crack" : { "sounds" : [ "dimdoors:crack"] },
"creepy" : { "sounds" : ["dimdoors:creepy" ] },
"doorLocked": { "sounds": [ "dimdoors:door_locked" ] },
"doorLockRemoved": { "sounds": [ "dimdoors:door_lock_removed" ] },
"keyLock" : { "sounds" : [ "dimdoors:key_lock" ] },
"keyUnlock" : { "sounds": [ "dimdoors:key_unlock" ] },
"door_locked": { "sounds": [ "dimdoors:door_locked" ] },
"door_lock_removed": { "sounds": [ "dimdoors:door_lock_removed" ] },
"key_lock" : { "sounds" : [ "dimdoors:key_lock" ] },
"key_unlock" : { "sounds": [ "dimdoors:key_unlock" ] },
"monk" : { "sounds" : [ "dimdoors:monk" ] },
"rift" : { "sounds" : [ "dimdoors:rift" ] },
"riftClose" : { "sounds" : [ "dimdoors:rift_close" ] },
"riftDoor": { "sounds" : [ "dimdoors:rift_door" ] },
"riftEnd": { "sounds" : [ "dimdoors:rift_end" ] },
"riftStart": { "sounds" : [ "dimdoors:rift_start" ] },
"rift_close" : { "sounds" : [ "dimdoors:rift_close" ] },
"rift_door": { "sounds" : [ "dimdoors:rift_door" ] },
"rift_end": { "sounds" : [ "dimdoors:rift_end" ] },
"rift_start": { "sounds" : [ "dimdoors:rift_start" ] },
"tearing": { "sounds" : [ "dimdoors:tearing"] }
}