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);
}
}
}
}
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;
}
}
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();
}
}
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);
}
}
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();
}
}
Aggregations