Search in sources :

Example 6 with ITakumiEntity

use of com.tntmodders.takumi.entity.ITakumiEntity in project takumicraft by TNTModders.

the class TakumiEvents method checkSpawn.

@SubscribeEvent
public void checkSpawn(LivingSpawnEvent.CheckSpawn e) {
    if (e.getWorld().provider.getDimensionType() == TakumiWorldCore.TAKUMI_WORLD) {
        if (!(e.getEntityLiving() instanceof ITakumiEntity)) {
            e.setResult(Result.DENY);
        }
    }
    if (e.getEntityLiving().getClass() == EntityCreeper.class) {
        ((EntityLiving) e.getEntityLiving()).tasks.addTask(0, new EntityAIFollowCatCreeper((EntityCreeper) e.getEntityLiving()));
    }
    if (!e.getWorld().isRemote) {
        if (e.getEntityLiving().getRNG().nextInt(5) == 0 && e.getEntityLiving() instanceof EntitySlime) {
            EntitySlimeCreeper slimeCreeper = new EntitySlimeCreeper(e.getWorld());
            slimeCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            slimeCreeper.setSlimeSize(e.getEntityLiving().getRNG().nextBoolean() ? 1 : e.getEntityLiving().getRNG().nextBoolean() ? 2 : 4, false);
            if (slimeCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(slimeCreeper);
                e.setResult(Result.DENY);
            }
        }
        if (e.getEntityLiving().getRNG().nextInt(10) == 0 && e.getEntityLiving() instanceof EntityFishCreeper) {
            EntityBigFishCreeper bigFishCreeper = new EntityBigFishCreeper(e.getWorld());
            bigFishCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            if (bigFishCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(bigFishCreeper);
                e.setResult(Result.DENY);
            }
        } else if (e.getEntityLiving().getRNG().nextInt(10) == 0 && e.getEntityLiving() instanceof EntitySquid) {
            EntitySquidCreeper squidCreeper = new EntitySquidCreeper(e.getWorld());
            squidCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            if (squidCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(squidCreeper);
                e.setResult(Result.DENY);
            }
        } else if ((e.getEntityLiving().getClass() == EntityZombieCreeper.class || e.getEntityLiving().getClass() == EntityZombieVillagerCreeper.class) && (e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.DESERT || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.DESERT_HILLS || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.MUTATED_DESERT)) {
            EntityHuskCreeper huskCreeper = new EntityHuskCreeper(e.getWorld());
            huskCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            if (huskCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(huskCreeper);
                e.setResult(Result.DENY);
            }
        } else if (e.getEntityLiving().getClass() == EntitySkeletonCreeper.class && (e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.ICE_MOUNTAINS || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.ICE_PLAINS || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.COLD_BEACH || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.COLD_TAIGA || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.COLD_TAIGA_HILLS || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.FROZEN_OCEAN || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.FROZEN_RIVER)) {
            EntityStrayCreeper strayCreeper = new EntityStrayCreeper(e.getWorld());
            strayCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            if (strayCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(strayCreeper);
                e.setResult(Result.DENY);
            }
        } else if (e.getEntityLiving().getRNG().nextInt(5) == 0 && e.getEntityLiving() instanceof EntityBat) {
            EntityBatCreeper batCreeper = new EntityBatCreeper(e.getWorld());
            batCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            if (batCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(batCreeper);
                e.setResult(Result.DENY);
            }
        }
    }
}
Also used : ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) EntityAIFollowCatCreeper(com.tntmodders.takumi.entity.ai.EntityAIFollowCatCreeper) EntitySlime(net.minecraft.entity.monster.EntitySlime) EntitySquid(net.minecraft.entity.passive.EntitySquid) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityBat(net.minecraft.entity.passive.EntityBat) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with ITakumiEntity

use of com.tntmodders.takumi.entity.ITakumiEntity in project takumicraft by TNTModders.

the class EntityCreativeCreeper method buildHouse.

private void buildHouse(int ox, int oy, int oz) {
    int r = this.rand.nextInt(4);
    switch(r) {
        /*豆腐*/
        case 0:
            for (int x = ox - 4; x <= ox + 4; x++) {
                for (int z = oz - 4; z <= oz + 4; z++) {
                    for (int y = oy; y <= oy + 5; y++) {
                        if (this.world.getBlockState(new BlockPos(x, y, z)).getBlockHardness(this.world, new BlockPos(x, y, z)) > 0) {
                            this.world.setBlockState(new BlockPos(x, y, z), TakumiBlockCore.CREEPER_GLASS.getDefaultState());
                        }
                    }
                }
            }
            if (this.world.getBlockState(new BlockPos(ox + 4, oy + 1, oz - 3)).getBlockHardness(this.world, new BlockPos(ox + 4, oy + 1, oz - 3)) > 0 || this.world.isAirBlock(new BlockPos(ox + 4, oy + 1, oz - 3))) {
                this.world.setBlockState(new BlockPos(ox + 4, oy + 1, oz - 3), Blocks.AIR.getDefaultState());
            }
            if (this.world.getBlockState(new BlockPos(ox + 4, oy + 2, oz - 3)).getBlockHardness(this.world, new BlockPos(ox + 4, oy + 2, oz - 3)) > 0 || this.world.isAirBlock(new BlockPos(ox + 4, oy + 2, oz - 3))) {
                this.world.setBlockState(new BlockPos(ox + 4, oy + 2, oz - 3), Blocks.AIR.getDefaultState());
            }
            for (int x = ox - 3; x <= ox + 3; x++) {
                for (int z = oz - 3; z <= oz + 3; z++) {
                    for (int y = oy + 1; y <= oy + 4; y++) {
                        if (this.world.getBlockState(new BlockPos(x, y, z)).getBlockHardness(this.world, new BlockPos(x, y, z)) > 0 || this.world.isAirBlock(new BlockPos(x, y, z))) {
                            this.world.setBlockState(new BlockPos(x, y, z), Blocks.AIR.getDefaultState());
                        }
                    }
                }
            }
            break;
        /*TNTハウス*/
        case 1:
            for (int x = ox - 4; x <= ox + 4; x++) {
                for (int z = oz - 4; z <= oz + 4; z++) {
                    for (int y = oy; y <= oy + 5; y++) {
                        if (this.world.getBlockState(new BlockPos(x, y, z)).getBlockHardness(this.world, new BlockPos(x, y, z)) > 0 || this.world.isAirBlock(new BlockPos(x, y, z))) {
                            this.world.setBlockState(new BlockPos(x, y, z), Blocks.PLANKS.getDefaultState());
                        }
                    }
                }
            }
            if (this.world.getBlockState(new BlockPos(ox + 4, oy + 1, oz - 3)).getBlockHardness(this.world, new BlockPos(ox + 4, oy + 1, oz - 3)) > 0 || this.world.isAirBlock(new BlockPos(ox + 4, oy + 1, oz - 3))) {
                this.world.setBlockState(new BlockPos(ox + 4, oy + 1, oz - 3), Blocks.AIR.getDefaultState());
            }
            if (this.world.getBlockState(new BlockPos(ox + 4, oy + 2, oz - 3)).getBlockHardness(this.world, new BlockPos(ox + 4, oy + 2, oz - 3)) > 0 || this.world.isAirBlock(new BlockPos(ox + 4, oy + 2, oz - 3))) {
                this.world.setBlockState(new BlockPos(ox + 4, oy + 2, oz - 3), Blocks.AIR.getDefaultState());
            }
            for (int x = ox - 3; x <= ox + 3; x++) {
                for (int z = oz - 3; z <= oz + 3; z++) {
                    for (int y = oy + 1; y <= oy + 4; y++) {
                        if (this.world.getBlockState(new BlockPos(x, y, z)).getBlockHardness(this.world, new BlockPos(x, y, z)) > 0 || this.world.isAirBlock(new BlockPos(x, y, z))) {
                            if (y >= oy + 4) {
                                this.world.setBlockState(new BlockPos(x, y, z), Blocks.FIRE.getDefaultState());
                            } else {
                                this.world.setBlockState(new BlockPos(x, y, z), Blocks.TNT.getDefaultState());
                            }
                        }
                    }
                }
            }
            break;
        /*高性能爆弾*/
        case 2:
            for (int x = ox - 4; x <= ox + 4; x++) {
                for (int z = oz - 4; z <= oz + 4; z++) {
                    for (int y = oy; y <= oy + 5; y++) {
                        if (this.world.getBlockState(new BlockPos(x, y, z)).getBlockHardness(this.world, new BlockPos(x, y, z)) > 0 || this.world.isAirBlock(new BlockPos(x, y, z))) {
                            this.world.setBlockState(new BlockPos(x, y, z), TakumiBlockCore.CREEPER_BOMB.getDefaultState());
                        }
                    }
                }
            }
            if (this.world.getBlockState(new BlockPos(ox + 4, oy + 1, oz - 3)).getBlockHardness(this.world, new BlockPos(ox + 4, oy + 1, oz - 3)) > 0 || this.world.isAirBlock(new BlockPos(ox + 4, oy + 1, oz - 3))) {
                this.world.setBlockState(new BlockPos(ox + 4, oy + 1, oz - 3), Blocks.AIR.getDefaultState());
            }
            if (this.world.getBlockState(new BlockPos(ox + 4, oy + 2, oz - 3)).getBlockHardness(this.world, new BlockPos(ox + 4, oy + 2, oz - 3)) > 0 || this.world.isAirBlock(new BlockPos(ox + 4, oy + 2, oz - 3))) {
                this.world.setBlockState(new BlockPos(ox + 4, oy + 2, oz - 3), Blocks.AIR.getDefaultState());
            }
            for (int x = ox - 3; x <= ox + 3; x++) {
                for (int z = oz - 3; z <= oz + 3; z++) {
                    for (int y = oy + 1; y <= oy + 4; y++) {
                        if (this.world.getBlockState(new BlockPos(x, y, z)).getBlockHardness(this.world, new BlockPos(x, y, z)) > 0 || this.world.isAirBlock(new BlockPos(x, y, z))) {
                            if (y >= oy + 4) {
                                this.world.setBlockState(new BlockPos(x, y, z), Blocks.AIR.getDefaultState());
                                EntityTNTPrimed tnt = new EntityTNTPrimed(this.world, x, y, z, this);
                                this.world.spawnEntity(tnt);
                            } else {
                                this.world.setBlockState(new BlockPos(x, y, z), Blocks.TNT.getDefaultState());
                            }
                        }
                    }
                }
            }
            break;
        /*モンスターハウス*/
        case 3:
            for (int x = ox - 4; x <= ox + 4; x++) {
                for (int z = oz - 4; z <= oz + 4; z++) {
                    for (int y = oy; y <= oy + 5; y++) {
                        if (this.world.getBlockState(new BlockPos(x, y, z)).getBlockHardness(this.world, new BlockPos(x, y, z)) > 0 || this.world.isAirBlock(new BlockPos(x, y, z))) {
                            this.world.setBlockState(new BlockPos(x, y, z), TakumiBlockCore.CREEPER_BRICK.getDefaultState());
                        }
                    }
                }
            }
            if (this.world.getBlockState(new BlockPos(ox + 4, oy + 1, oz - 3)).getBlockHardness(this.world, new BlockPos(ox + 4, oy + 1, oz - 3)) > 0 || this.world.isAirBlock(new BlockPos(ox + 4, oy + 1, oz - 3))) {
                this.world.setBlockState(new BlockPos(ox + 4, oy + 1, oz - 3), Blocks.AIR.getDefaultState());
            }
            if (this.world.getBlockState(new BlockPos(ox + 4, oy + 2, oz - 3)).getBlockHardness(this.world, new BlockPos(ox + 4, oy + 2, oz - 3)) > 0 || this.world.isAirBlock(new BlockPos(ox + 4, oy + 2, oz - 3))) {
                this.world.setBlockState(new BlockPos(ox + 4, oy + 2, oz - 3), Blocks.AIR.getDefaultState());
            }
            for (int x = ox - 2; x <= ox + 2; x++) {
                for (int z = oz - 2; z <= oz + 2; z++) {
                    for (int y = oy + 2; y >= oy + 1; y--) {
                        for (int i = 0; i < (this.getPowered() ? 4 : 2); i++) {
                            this.world.setBlockState(new BlockPos(x, y, z), Blocks.AIR.getDefaultState());
                            if (this.world.getBlockState(new BlockPos(x, y, z)).getBlock() == Blocks.AIR && this.world.getBlockState(new BlockPos(x, y + 1, z)).getBlock() == Blocks.AIR && this.rand.nextInt(5) == 0) {
                                Class<? extends ITakumiEntity> clazz = TakumiEntityCore.getEntityList().get(this.rand.nextInt(TakumiEntityCore.getEntityList().size())).getClass();
                                try {
                                    Entity creeper = (Entity) clazz.getConstructor(World.class).newInstance(this.world);
                                    if (((ITakumiEntity) creeper).takumiRank() == EnumTakumiRank.LOW || ((ITakumiEntity) creeper).takumiRank() == EnumTakumiRank.MID) {
                                        creeper.world = this.world;
                                        creeper.setPosition(x, y, z);
                                        this.world.spawnEntity(creeper);
                                    }
                                } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }
                }
            }
            break;
    }
}
Also used : Entity(net.minecraft.entity.Entity) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) EntityTNTPrimed(net.minecraft.entity.item.EntityTNTPrimed) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) BlockPos(net.minecraft.util.math.BlockPos) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 8 with ITakumiEntity

use of com.tntmodders.takumi.entity.ITakumiEntity in project takumicraft by TNTModders.

the class TakumiASMHooks method TakumiExplodeHook.

public static void TakumiExplodeHook(EntityCreeper creeper) {
    try {
        if (creeper instanceof EntityTakumiAbstractCreeper) {
            int i = ((ITakumiEntity) creeper).getExplosionPower();
            Field field = TakumiASMNameMap.getField(EntityCreeper.class, "explosionRadius");
            field.setAccessible(true);
            field.set(creeper, i);
            ((ITakumiEntity) creeper).takumiExplode();
        }
    } catch (IllegalAccessException | NoSuchFieldException e) {
        e.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) EntityTakumiAbstractCreeper(com.tntmodders.takumi.entity.EntityTakumiAbstractCreeper)

Example 9 with ITakumiEntity

use of com.tntmodders.takumi.entity.ITakumiEntity in project takumicraft by TNTModders.

the class GuiTakumiBook method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    this.drawDefaultBackground();
    if (this.currPage != Integer.MAX_VALUE) {
        GL11.glPushMatrix();
        ITakumiEntity takumiEntity = TakumiEntityCore.getEntityList().get(this.currPage);
        boolean flg = false;
        if (TakumiUtils.getAdvancementUnlocked(new ResourceLocation(TakumiCraftCore.MODID, "slay/slay_" + takumiEntity.getRegisterName()))) {
            flg = true;
        }
        EntityLivingBase base = this.getEntity(takumiEntity, flg);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        int i = (this.width - 192) / 2;
        int j = 2;
        this.mc.getTextureManager().bindTexture(BOOK_GUI_TEXTURES);
        this.drawTexturedModalRect(i, 2, 0, 0, this.bookImage, this.bookImage);
        ResourceLocation location = flg && takumiEntity.takumiType().getId() < 8 ? new ResourceLocation(TakumiCraftCore.MODID, "textures/book/" + takumiEntity.takumiType().getName() + ".png") : new ResourceLocation(TakumiCraftCore.MODID, "textures/book/underfound.png");
        this.mc.getTextureManager().bindTexture(location);
        this.drawTexturedModalRect(i, 2, 0, 0, this.bookImage, this.bookImage);
        if (flg) {
            if (takumiEntity.takumiType().isMagic()) {
                ResourceLocation location2 = new ResourceLocation(TakumiCraftCore.MODID, "textures/book/magic.png");
                this.mc.getTextureManager().bindTexture(location2);
                this.drawTexturedModalRect(i, 2, 0, 0, this.bookImage, this.bookImage);
            }
            if (takumiEntity.takumiType().isDest()) {
                ResourceLocation location2 = new ResourceLocation(TakumiCraftCore.MODID, "textures/book/dest.png");
                this.mc.getTextureManager().bindTexture(location2);
                this.drawTexturedModalRect(i, 2, 0, 0, this.bookImage, this.bookImage);
            }
        }
        String s4 = I18n.format("book.pageIndicator", this.currPage + 1, this.bookTotalPages);
        String s5 = "???";
        String s6 = "???";
        if (flg && this.currPage >= 0 && this.currPage < TakumiEntityCore.getEntityList().size()) {
            s5 = TakumiUtils.takumiTranslate("entity." + TakumiEntityCore.getEntityList().get(this.currPage).getRegisterName() + ".name");
            s6 = TakumiUtils.takumiTranslate("entity." + TakumiEntityCore.getEntityList().get(this.currPage).getRegisterName() + ".desc");
            if (TakumiEntityCore.getEntityList().get(this.currPage) instanceof EntityShootingCreeper && EntityShootingCreeper.useChoco(Minecraft.getMinecraft().world)) {
                s6 = TakumiUtils.takumiTranslate("entity." + TakumiEntityCore.getEntityList().get(this.currPage).getRegisterName() + ".desc" + ".choco");
            }
        }
        int j1 = this.fontRenderer.getStringWidth(s4);
        this.fontRenderer.drawString(s4, i - j1 + 192 - 44, 18, 0);
        this.fontRenderer.drawSplitString(s5, i + 80, 34, 70, 0);
        this.fontRenderer.drawSplitString(s6, i + 40, 100, 116, 0);
        super.drawScreen(mouseX, mouseY, partialTicks);
        int k = (this.width - this.bookImage) / 2;
        byte b0 = 2;
        if (base != null) {
            this.renderEntity(k + 51, b0 + 75, 30, (float) (k + 51) - this.bookImage, (float) (b0 + 75 - 50) - this.bookImage, base, flg);
        }
        GL11.glPopMatrix();
    } else {
        this.mc.getTextureManager().bindTexture(BOOK_GUI_TEXTURES_SP);
        GL11.glPushMatrix();
        GL11.glScaled(1.9, 1, 1);
        this.drawTexturedModalRect(2, 2, 0, 0, 256, 256);
        GL11.glPopMatrix();
        super.drawScreen(mouseX, mouseY, partialTicks);
    }
}
Also used : ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) ResourceLocation(net.minecraft.util.ResourceLocation) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 10 with ITakumiEntity

use of com.tntmodders.takumi.entity.ITakumiEntity in project takumicraft by TNTModders.

the class TakumiEntityCore method register.

public static void register() {
    // CREATURE_TAKUMI = EnumHelper.addCreatureType("creature_takumi", EntityTakumiAbstractCreeper.class, 100, Material.AIR, false, true);
    // WATER_TAKUMI = EnumHelper.addCreatureType("water_takumi", EntityTakumiAbstractCreeper.class, 25, Material.WATER, false, false);
    Biome.REGISTRY.iterator().forEachRemaining(biome -> biomes.add(biome));
    biomes.remove(Biomes.HELL);
    biomes.remove(Biomes.VOID);
    /*List<Class> files = TakumiUtils.getListClass("com/tntmodders/takumi/entity/mobs/");*/
    ArrayList<EntityHolder> entityHolders = new ArrayList<>();
    for (Class clazz : CLASS_LIST) {
        try {
            /*ClassLoader loader = TakumiCraftCore.class.getClassLoader();
                //Class clazz = loader.loadClass("com.tntmodders.takumi.entity.mobs." + file.getName().replaceAll(".class", ""));*/
            ITakumiEntity entity = (ITakumiEntity) clazz.getConstructor(World.class).newInstance((World) null);
            entityHolders.add(new EntityHolder(clazz, entity));
        } catch (Exception e) {
        // e.printStackTrace();
        }
    }
    // List <File> files = TakumiUtils.getListFile("com/tntmodders/takumi/entity/mobs/");
    /*for (File file : files) {
            try {
                ClassLoader loader = TakumiCraftCore.class.getClassLoader();
                Class clazz = loader.loadClass("com.tntmodders.takumi.entity.mobs." + file.getName().replaceAll(".class", ""));
                ITakumiEntity entity = (ITakumiEntity) clazz.getConstructor(World.class).newInstance((World) null);
                entityHolders.add(new EntityHolder(clazz, entity));
            } catch (Exception e) {
                //e.printStackTrace();
            }
        }*/
    entityHolders.sort(new EntityComparator());
    for (EntityHolder holder : entityHolders) {
        Class clazz = holder.clazz;
        ITakumiEntity entity = holder.entity;
        if (!entity.canRegister()) {
            break;
        }
        ResourceLocation location = new ResourceLocation(TakumiCraftCore.MODID, entity.getRegisterName());
        EntityRegistry.registerModEntity(location, clazz, location.getResourcePath(), entity.getRegisterID(), TakumiCraftCore.TakumiInstance, 64, 2, true, entity.getPrimaryColor(), entity.getSecondaryColor());
        if (entity.isCustomSpawn()) {
            try {
                entity.customSpawn();
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (entity.takumiRank().getSpawnWeight() != 0 && !entity.isAnimal()) {
            Biome.REGISTRY.iterator().forEachRemaining(biome -> {
                if (!(biome instanceof BiomeOcean) && biome != Biomes.HELL && biome != Biomes.VOID && biome != Biomes.SKY) {
                    EntityRegistry.addSpawn(clazz, entity.takumiRank().getSpawnWeight(), 10, 30, EnumCreatureType.MONSTER, biome);
                }
            });
            entity.additionalSpawn();
        }
        if (FMLCommonHandler.instance().getSide().isClient()) {
            TakumiClientCore.registerEntityRender(clazz, entity);
        }
        entityList.add(entity);
        TakumiCraftCore.LOGGER.info("Registered entity on ID " + entity.getRegisterID() + " : " + location.getResourcePath() + " , " + entity.takumiRank().name() + " and " + entity.takumiType().name());
        File packFile = FMLCommonHandler.instance().findContainerFor(TakumiCraftCore.TakumiInstance).getSource();
        File oldFile = null;
        String assetS = "assets/takumicraft/advancements/slay";
        for (File f : TakumiUtils.getListFile(assetS)) {
            if (f.getName().contains("slay_.json")) {
                oldFile = f;
                break;
            }
        }
        if (oldFile != null) {
            ClassLoader loader = TakumiCraftCore.class.getClassLoader();
            URL url = loader.getResource(assetS);
            if (!Objects.equals(url.getProtocol(), "jar")) {
                String[] strings = { oldFile.getAbsolutePath().replaceAll(".json", ""), oldFile.getAbsolutePath().split("out")[0] + "src" + oldFile.getAbsolutePath().split("out")[1].replaceAll("production", "main").replaceAll("minecraft", "resources").replaceAll(".json", "") };
                for (String sPath : strings) {
                    String sResource = sPath + entity.getRegisterName() + ".json";
                    File file = new File(sResource);
                    try {
                        file.createNewFile();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    FileReader h_fr;
                    String buf = "";
                    String h_s;
                    try {
                        h_fr = new FileReader(oldFile);
                        BufferedReader h_br = new BufferedReader(h_fr);
                        while (true) {
                            h_s = h_br.readLine();
                            if (h_s == null) {
                                break;
                            }
                            h_s = h_s.replaceAll("minecraft:creeper", "takumicraft:" + entity.getRegisterName());
                            h_s = h_s.replaceAll("creeper_hoge", entity.getRegisterName());
                            buf = buf + h_s;
                        }
                        h_fr.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    try {
                        FileWriter writer = new FileWriter(file);
                        writer.write(buf);
                        writer.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
    itemRegister();
    if (FMLCommonHandler.instance().getSide().isClient()) {
        renderRegister();
    }
}
Also used : java.util(java.util) TakumiClientCore(com.tntmodders.takumi.core.client.TakumiClientCore) EntityTransCreeper(com.tntmodders.takumi.entity.mobs.boss.EntityTransCreeper) URL(java.net.URL) RenderLlamaCreeperSpit(com.tntmodders.takumi.client.render.RenderLlamaCreeperSpit) RenderTakumiTNTPrimed(com.tntmodders.takumi.client.render.RenderTakumiTNTPrimed) FMLCommonHandler(net.minecraftforge.fml.common.FMLCommonHandler) RenderAttackBlock(com.tntmodders.takumi.client.render.RenderAttackBlock) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) EntityShulkerBullet(net.minecraft.entity.projectile.EntityShulkerBullet) EntityArrow(net.minecraft.entity.projectile.EntityArrow) RenderSnowball(net.minecraft.client.renderer.entity.RenderSnowball) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) RenderShulkerBullet(net.minecraft.client.renderer.entity.RenderShulkerBullet) RenderingRegistry(net.minecraftforge.fml.client.registry.RenderingRegistry) com.tntmodders.takumi.entity.item(com.tntmodders.takumi.entity.item) EntityKingCreeper(com.tntmodders.takumi.entity.mobs.boss.EntityKingCreeper) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) RenderArrow(net.minecraft.client.renderer.entity.RenderArrow) EnumHelper(net.minecraftforge.common.util.EnumHelper) TakumiUtils(com.tntmodders.takumi.utils.TakumiUtils) Items(net.minecraft.init.Items) World(net.minecraft.world.World) TakumiCraftCore(com.tntmodders.takumi.TakumiCraftCore) EnumCreatureType(net.minecraft.entity.EnumCreatureType) java.io(java.io) Material(net.minecraft.block.material.Material) IMob(net.minecraft.entity.monster.IMob) BiomeOcean(net.minecraft.world.biome.BiomeOcean) com.tntmodders.takumi.entity.mobs(com.tntmodders.takumi.entity.mobs) Biomes(net.minecraft.init.Biomes) ResourceLocation(net.minecraft.util.ResourceLocation) RenderDarkVillager(com.tntmodders.takumi.client.render.RenderDarkVillager) EntityDarkVillager(com.tntmodders.takumi.entity.mobs.noncreeper.EntityDarkVillager) Biome(net.minecraft.world.biome.Biome) EntityRegistry(net.minecraftforge.fml.common.registry.EntityRegistry) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) World(net.minecraft.world.World) URL(java.net.URL) BiomeOcean(net.minecraft.world.biome.BiomeOcean) ResourceLocation(net.minecraft.util.ResourceLocation)

Aggregations

ITakumiEntity (com.tntmodders.takumi.entity.ITakumiEntity)10 Entity (net.minecraft.entity.Entity)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 BlockPos (net.minecraft.util.math.BlockPos)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 TakumiCraftCore (com.tntmodders.takumi.TakumiCraftCore)2 EntityKingCreeper (com.tntmodders.takumi.entity.mobs.boss.EntityKingCreeper)2 Material (net.minecraft.block.material.Material)2 IBlockState (net.minecraft.block.state.IBlockState)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 RenderAttackBlock (com.tntmodders.takumi.client.render.RenderAttackBlock)1 RenderDarkVillager (com.tntmodders.takumi.client.render.RenderDarkVillager)1 RenderLlamaCreeperSpit (com.tntmodders.takumi.client.render.RenderLlamaCreeperSpit)1 RenderTakumiTNTPrimed (com.tntmodders.takumi.client.render.RenderTakumiTNTPrimed)1 TakumiBlockCore (com.tntmodders.takumi.core.TakumiBlockCore)1 TakumiEntityCore (com.tntmodders.takumi.core.TakumiEntityCore)1 TakumiClientCore (com.tntmodders.takumi.core.client.TakumiClientCore)1