Code readability improvements

- Read through most of the code, fixing small issues, renaming variables to clearer names, explaining less clear things
 - Remove many fixed todos and remove feature-suggestion todos in favor of the Github issue tracker
 - class CommonProxy -> interface IProxy (even the name CommonProxy makes no sense, why would you need to proxy something common to both the client and the server!)
 - Match minecraft naming convention
 - Autoformat classes

A few issues fixed:
 - Make rift work in both top and bottom door block
 - Change transient portal material to "portal" for correct vanilla logic
 - Make doors ignore closeAfterPassThrough (that made no sense lore-wise, dimensional portals close because they are fragile and the player passing through breaks them)
This commit is contained in:
Runemoro 2018-04-07 01:28:02 -04:00
parent a2e7689935
commit e080ddaa4a
65 changed files with 632 additions and 706 deletions

View file

@ -1,26 +1,40 @@
package org.dimdev.dimdoors;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.text.TextComponentTranslation;
import org.dimdev.dimdoors.shared.ModConfig;
import org.dimdev.dimdoors.shared.commands.CommandFabricConvert;
import org.dimdev.dimdoors.shared.commands.CommandPocket;
import org.dimdev.dimdoors.shared.commands.CommandDimTeleport;
import org.dimdev.dimdoors.shared.CommonProxy;
import org.dimdev.dimdoors.shared.commands.CommandSaveSchem;
import org.dimdev.dimdoors.shared.items.ModItems;
import org.dimdev.dimdoors.shared.world.gateways.GatewayGenerator;
import lombok.Getter;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.*;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.proxy.IProxy;
import org.dimdev.dimdoors.shared.EventHandler;
import org.dimdev.dimdoors.shared.ModConfig;
import org.dimdev.dimdoors.shared.ModRecipes;
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
import org.dimdev.dimdoors.shared.commands.CommandDimTeleport;
import org.dimdev.dimdoors.shared.commands.CommandFabricConvert;
import org.dimdev.dimdoors.shared.commands.CommandPocket;
import org.dimdev.dimdoors.shared.commands.CommandSaveSchem;
import org.dimdev.dimdoors.shared.entities.EntityMonolith;
import org.dimdev.dimdoors.shared.items.ModItems;
import org.dimdev.dimdoors.shared.pockets.SchematicHandler;
import org.dimdev.dimdoors.shared.rifts.RiftDestination;
import org.dimdev.dimdoors.shared.rifts.destinations.*;
import org.dimdev.dimdoors.shared.sound.ModSounds;
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
import org.dimdev.dimdoors.shared.world.ModBiomes;
import org.dimdev.dimdoors.shared.world.ModDimensions;
import org.dimdev.dimdoors.shared.world.gateways.GatewayGenerator;
import java.io.File;
@ -33,51 +47,84 @@ public class DimDoors {
public static final String MODNAME = "Dimensional Doors";
public static final String MCVERSIONS = "[1.12,1.13)";
public static final String VERSION = "${version}";
public static final String DEPENDENCIES = "required-after:forge@[14.21.0.2320,);after:csb_ench_table";
// after:csb_ench_table as a workaround for https://github.com/crazysnailboy/EnchantingTable/issues/7
public static final String DEPENDENCIES = "required-after:forge@[14.21.0.2320,)";
@Mod.Instance(DimDoors.MODID)
public static DimDoors instance;
public static Logger log;
@SidedProxy(clientSide = "org.dimdev.dimdoors.client.ClientProxy",
serverSide = "org.dimdev.dimdoors.server.ServerProxy")
public static CommonProxy proxy;
@SidedProxy(clientSide = "org.dimdev.dimdoors.proxy.ClientProxy",
serverSide = "org.dimdev.dimdoors.proxy.ServerProxy")
public static IProxy proxy;
public static final CreativeTabs DIM_DOORS_CREATIVE_TAB = new CreativeTabs("dimensional_doors_creative_tab") {
@Override
@SideOnly(Side.CLIENT)
public ItemStack getTabIconItem() {
return new ItemStack(ModItems.IRON_DIMENSIONAL_DOOR);
}
};
@Getter private GatewayGenerator gatewayGenerator;
@Getter public static File configurationFolder;
// Initialization
@Mod.EventHandler
public void onPreInitialization(FMLPreInitializationEvent event) {
log = event.getModLog();
proxy.onPreInitialization(event);
// Register event handlers
MinecraftForge.EVENT_BUS.register(EventHandler.class);
MinecraftForge.EVENT_BUS.register(ModBlocks.class);
MinecraftForge.EVENT_BUS.register(ModItems.class);
MinecraftForge.EVENT_BUS.register(ModRecipes.class);
MinecraftForge.EVENT_BUS.register(ModSounds.class);
MinecraftForge.EVENT_BUS.register(ModBiomes.class);
MinecraftForge.EVENT_BUS.register(ModConfig.class);
// Register rift destinations
RiftDestination.destinationRegistry.put("available_link", AvailableLinkDestination.class);
RiftDestination.destinationRegistry.put("escape", EscapeDestination.class);
RiftDestination.destinationRegistry.put("global", GlobalDestination.class);
RiftDestination.destinationRegistry.put("limbo", LimboDestination.class);
RiftDestination.destinationRegistry.put("local", LocalDestination.class);
RiftDestination.destinationRegistry.put("public_pocket", PublicPocketDestination.class);
RiftDestination.destinationRegistry.put("pocket_entrance", PocketEntranceMarker.class);
RiftDestination.destinationRegistry.put("pocket_exit", PocketExitMarker.class);
RiftDestination.destinationRegistry.put("private", PrivateDestination.class);
RiftDestination.destinationRegistry.put("private_pocket_exit", PrivatePocketExitDestination.class);
RiftDestination.destinationRegistry.put("relative", RelativeDestination.class);
// Register entities
EntityRegistry.registerModEntity(new ResourceLocation(DimDoors.MODID, "mob_monolith"), EntityMonolith.class, "monoliths", 0, DimDoors.instance, 70, 1, true);
EntityRegistry.registerEgg(new ResourceLocation(DimDoors.MODID, "mob_monolith"), 0, 0xffffff);
// Register tile entities
GameRegistry.registerTileEntity(TileEntityEntranceRift.class, "dimdoors:entrance_rift");
GameRegistry.registerTileEntity(TileEntityFloatingRift.class, "dimdoors:floating_rift");
// Register dimensions
ModDimensions.registerDimensions();
// Make config folder and check if config needs to be regenerated TODO
configurationFolder = new File(event.getModConfigurationDirectory(), "/DimDoors");
if (configurationFolder.exists()) {
configurationFolder.mkdirs();
}
configurationFolder.mkdirs();
proxy.onPreInitialization(event);
}
@Mod.EventHandler
public void onInitialization(FMLInitializationEvent event) {
// Register loot tables
LootTableList.register(new ResourceLocation(DimDoors.MODID, "dungeon_chest"));
LootTableList.register(new ResourceLocation(DimDoors.MODID, "dispenser_projectiles"));
LootTableList.register(new ResourceLocation(DimDoors.MODID, "dispenser_splash_potions"));
LootTableList.register(new ResourceLocation(DimDoors.MODID, "dispenser_potion_arrows"));
// Load schematics
SchematicHandler.INSTANCE.loadSchematics();
// Register world generators
GameRegistry.registerWorldGenerator(new GatewayGenerator(), 0);
proxy.onInitialization(event);
gatewayGenerator = new GatewayGenerator(); //TODO put this in a proxy and structure this modularly instead of writing whole new classes per gateway type...
GameRegistry.registerWorldGenerator(gatewayGenerator, 0);
}
@Mod.EventHandler
public void serverLoad(FMLServerStartingEvent event) {
registerCommands(event);
}
private void registerCommands(FMLServerStartingEvent event) {
// Register commands
event.registerServerCommand(new CommandDimTeleport());
event.registerServerCommand(new CommandPocket());
event.registerServerCommand(new CommandSaveSchem());

View file

@ -14,13 +14,15 @@ import org.lwjgl.opengl.GL11;
import java.nio.FloatBuffer;
public final class DimensionalWallRenderer {
public final class DimensionalPortalRenderer {
private static final FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
private static final ResourceLocation warpPath = new ResourceLocation(DimDoors.MODID + ":textures/other/warp.png");
// TODO: any render angle
/**
* Renders a dimensional portal, for use in various situations. Code is mostly based
* on vanilla's TileEntityEndGatewayRenderer.
*
* @param x The x coordinate of the wall's center.
* @param y The y coordinate of the wall's center.
* @param z The z coordinate of the wall's center.
@ -31,7 +33,7 @@ public final class DimensionalWallRenderer {
* @param height The height of the wall.
* @param colors An array containing the color to use on each pass. Its length determines the number of passes to do.
*/
public static void renderDimensionalWall(double x, double y, double z, EnumFacing orientation, double width, double height, RGBA[] colors) {
public static void renderDimensionalPortal(double x, double y, double z, EnumFacing orientation, double width, double height, RGBA[] colors) { // TODO: Make this work at any angle
GlStateManager.disableLighting();
GlStateManager.disableCull();
@ -71,7 +73,7 @@ public final class DimensionalWallRenderer {
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_LINEAR);
}
switch (orientation) {
switch (orientation) { // TODO: Why 0.15F? Is that a door's thickness? If yes, don't hardcode that.
case SOUTH:
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
@ -103,7 +105,11 @@ public final class DimensionalWallRenderer {
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
break;
case DOWN:
// TODO: logic for DOWN
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
break;
}
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
@ -183,9 +189,9 @@ public final class DimensionalWallRenderer {
GlStateManager.enableLighting();
}
private static FloatBuffer getBuffer(float par1, float par2, float par3, float par4) {
private static FloatBuffer getBuffer(float f1, float f2, float f3, float f4) {
buffer.clear();
buffer.put(par1).put(par2).put(par3).put(par4);
buffer.put(f1).put(f2).put(f3).put(f4);
buffer.flip();
return buffer;
}

View file

@ -1,36 +1,32 @@
package org.dimdev.dimdoors.client;
import net.minecraft.item.EnumDyeColor;
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
import org.dimdev.dimdoors.shared.items.ModItems;
import net.minecraft.block.BlockDoor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import static net.minecraft.item.Item.getItemFromBlock;
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
import org.dimdev.dimdoors.shared.items.ModItems;
@SideOnly(Side.CLIENT)
public final class ModelManager {
public static void registerModels() {
for (EnumDyeColor color : EnumDyeColor.values()) {
register(getItemFromBlock(ModBlocks.FABRIC), color.getMetadata(), color.getName());
register(getItemFromBlock(ModBlocks.ANCIENT_FABRIC), color.getMetadata(), color.getName());
}
register(getItemFromBlock(ModBlocks.UNRAVELLED_FABRIC));
register(getItemFromBlock(ModBlocks.ETERNAL_FABRIC));
register(getItemFromBlock(ModBlocks.RIFT));
register(getItemFromBlock(ModBlocks.WOOD_DIMENSIONAL_TRAPDOOR));
//Item registration
//@SubscribeEvent
public static void registerItemModels() {
// Register item models
registerColored(ModItems.FABRIC);
registerColored(ModItems.ANCIENT_FABRIC);
register(ModItems.UNRAVELLED_FABRIC);
register(ModItems.ETERNAL_FABRIC);
register(ModItems.WOOD_DIMENSIONAL_TRAPDOOR);
register(ModItems.IRON_DIMENSIONAL_DOOR);
register(ModItems.GOLD_DIMENSIONAL_DOOR);
register(ModItems.GOLD_DOOR);
@ -52,43 +48,22 @@ public final class ModelManager {
register(ModItems.WOVEN_WORLD_THREAD_LEGGINGS);
}
public static void registerModelVariants() {
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event) {
// Register item variants
registerColoredVariants(ModItems.FABRIC);
registerColoredVariants(ModItems.ANCIENT_FABRIC);
ModelBakery.registerItemVariants(ModItems.FABRIC,
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_white"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_orange"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_magenta"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_light_blue"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_yellow"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_lime"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_pink"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_gray"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_silver"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_cyan"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_purple"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_blue"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_brown"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_green"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_red"),
new ResourceLocation(ModBlocks.FABRIC.getRegistryName() + "_black"));
// Register state mappers
StateMap ignorePowered = new StateMap.Builder().ignore(BlockDoor.POWERED).build();
ModelLoader.setCustomStateMapper(ModBlocks.GOLD_DOOR, ignorePowered);
ModelLoader.setCustomStateMapper(ModBlocks.QUARTZ_DOOR, ignorePowered);
ModelLoader.setCustomStateMapper(ModBlocks.GOLD_DIMENSIONAL_DOOR, ignorePowered);
ModelLoader.setCustomStateMapper(ModBlocks.IRON_DIMENSIONAL_DOOR, ignorePowered);
ModelLoader.setCustomStateMapper(ModBlocks.PERSONAL_DIMENSIONAL_DOOR, ignorePowered);
ModelLoader.setCustomStateMapper(ModBlocks.WARP_DIMENSIONAL_DOOR, ignorePowered);
ModelBakery.registerItemVariants(ModItems.ANCIENT_FABRIC,
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_white"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_orange"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_magenta"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_light_blue"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_yellow"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_lime"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_pink"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_gray"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_silver"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_cyan"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_purple"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_blue"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_brown"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_green"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_red"),
new ResourceLocation(ModBlocks.ANCIENT_FABRIC.getRegistryName() + "_black"));
ModelLoader.setCustomStateMapper(ModBlocks.DIMENSIONAL_PORTAL, new StateMap.Builder().ignore(BlockDoor.FACING, BlockDoor.HALF, BlockDoor.HINGE, BlockDoor.OPEN, BlockDoor.POWERED).build());
}
private static void register(Item item) {
@ -101,16 +76,19 @@ public final class ModelManager {
new ModelResourceLocation(item.getRegistryName() + "_" + name, "inventory"));
}
public static void addCustomStateMappers() {
StateMap map = new StateMap.Builder().ignore(BlockDoor.POWERED).build();
private static void registerColored(Item item) {
for (EnumDyeColor color : EnumDyeColor.values()) {
register(item, color.getMetadata(), color.getName());
}
}
ModelLoader.setCustomStateMapper(ModBlocks.GOLD_DOOR, map);
ModelLoader.setCustomStateMapper(ModBlocks.QUARTZ_DOOR, map);
ModelLoader.setCustomStateMapper(ModBlocks.GOLD_DIMENSIONAL_DOOR, map);
ModelLoader.setCustomStateMapper(ModBlocks.IRON_DIMENSIONAL_DOOR, map);
ModelLoader.setCustomStateMapper(ModBlocks.PERSONAL_DIMENSIONAL_DOOR, map);
ModelLoader.setCustomStateMapper(ModBlocks.WARP_DIMENSIONAL_DOOR, map);
private static void registerColoredVariants(Item item) {
ResourceLocation itemName = item.getRegistryName();
ResourceLocation[] variants = new ResourceLocation[16];
for (EnumDyeColor color : EnumDyeColor.values()) {
variants[color.getMetadata()] = new ResourceLocation(itemName + "_" + color.getName());
}
ModelLoader.setCustomStateMapper(ModBlocks.DIMENSIONAL_PORTAL, new StateMap.Builder().ignore(BlockDoor.FACING, BlockDoor.HALF, BlockDoor.HINGE, BlockDoor.OPEN, BlockDoor.POWERED).build());
ModelBakery.registerItemVariants(item, variants);
}
}

View file

@ -1,25 +1,24 @@
package org.dimdev.dimdoors.client;
import net.minecraft.client.renderer.GlStateManager;
import org.dimdev.dimdoors.shared.entities.EntityMonolith;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.shared.entities.EntityMonolith;
@SideOnly(Side.CLIENT)
public class ModelMonolith extends ModelBase {
private final ModelRenderer wholeMonolith;
private final ModelRenderer monolith;
public ModelMonolith() {
textureWidth = 256;
textureHeight = 256;
wholeMonolith = new ModelRenderer(this, 0, 0);
wholeMonolith.addBox(-24F, -108F / 1.3F, -6F, 48, 108, 12);
monolith = new ModelRenderer(this, 0, 0);
monolith.addBox(-24F, -108F / 1.3F, -6F, 48, 108, 12);
}
@Override
@ -28,6 +27,6 @@ public class ModelMonolith extends ModelBase {
setRotationAngles(0, 0, 0, 0, 0, 0, monolith);
GlStateManager.scale(monolith.getRenderSizeModifier(), monolith.getRenderSizeModifier(), monolith.getRenderSizeModifier());
wholeMonolith.render(scale);
this.monolith.render(scale);
}
}

View file

@ -1,9 +1,7 @@
package org.dimdev.dimdoors.client;
import net.minecraft.client.renderer.GlStateManager;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.entities.EntityMonolith;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
@ -12,6 +10,8 @@ import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.entities.EntityMonolith;
import org.lwjgl.opengl.GL11;
import java.util.Arrays;
@ -20,9 +20,7 @@ import java.util.List;
@SideOnly(Side.CLIENT)
public class RenderMonolith extends RenderLiving<EntityMonolith> {
protected ModelMonolith monolithModel;
protected static final List<ResourceLocation> monolith_textures = Arrays.asList(
protected static final List<ResourceLocation> MONOLITH_TEXTURES = Arrays.asList(
new ResourceLocation(DimDoors.MODID + ":textures/mobs/monolith/monolith0.png"),
new ResourceLocation(DimDoors.MODID + ":textures/mobs/monolith/monolith1.png"),
new ResourceLocation(DimDoors.MODID + ":textures/mobs/monolith/monolith2.png"),
@ -45,7 +43,6 @@ public class RenderMonolith extends RenderLiving<EntityMonolith> {
public RenderMonolith(RenderManager manager, float f) {
super(manager, new ModelMonolith(), f);
monolithModel = (ModelMonolith) mainModel;
}
@Override
@ -53,52 +50,51 @@ public class RenderMonolith extends RenderLiving<EntityMonolith> {
final float minScaling = 0;
final float maxScaling = 0.1f;
float aggroScaling = 0;
float jitterScale = 0;
if (monolith.isDangerous()) {
// Use linear interpolation to scale how much jitter we want for our given aggro level
aggroScaling = minScaling + (maxScaling - minScaling) * monolith.getAggroProgress();
jitterScale = minScaling + (maxScaling - minScaling) * monolith.getAggroProgress();
}
// Calculate jitter - include entity ID to give Monoliths individual jitters
float time = ((Minecraft.getSystemTime() + 0xF1234568 * monolith.getEntityId()) % 200000) / 50.0F;
// We use random constants here on purpose just to get different wave forms
double xJitter = aggroScaling * Math.sin(1.1f * time) * Math.sin(0.8f * time);
double yJitter = aggroScaling * Math.sin(1.2f * time) * Math.sin(0.9f * time);
double zJitter = aggroScaling * Math.sin(1.3f * time) * Math.sin(0.7f * time);
double xJitter = jitterScale * Math.sin(1.1f * time) * Math.sin(0.8f * time);
double yJitter = jitterScale * Math.sin(1.2f * time) * Math.sin(0.9f * time);
double zJitter = jitterScale * Math.sin(1.3f * time) * Math.sin(0.7f * time);
// Render with jitter
render(monolith, x + xJitter, y + yJitter, z + zJitter, entityYaw, partialTicks);
//this.renderLeash(entity, x, y, z, par8, par9);
}
public void render(EntityMonolith monolith, double x, double y, double z, float par8, float partialTickTime) {
public void render(EntityMonolith monolith, double x, double y, double z, float entityYaw, float partialTicks) {
if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre<>(monolith, this, 1, x, y, z))) return;
GlStateManager.pushMatrix();
GlStateManager.disableCull();
GlStateManager.disableLighting();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mainModel.swingProgress = getSwingProgress(monolith, partialTickTime);
mainModel.swingProgress = getSwingProgress(monolith, partialTicks);
try {
float interpolatedYaw = interpolateRotation(monolith.prevRenderYawOffset, monolith.renderYawOffset, partialTickTime);
float interpolatedYaw = interpolateRotation(monolith.prevRenderYawOffset, monolith.renderYawOffset, partialTicks);
float rotation;
float pitch = monolith.prevRotationPitch + (monolith.rotationPitch - monolith.prevRotationPitch) * partialTickTime;
float pitch = monolith.prevRotationPitch + (monolith.rotationPitch - monolith.prevRotationPitch) * partialTicks;
renderLivingAt(monolith, x, y, z);
rotation = handleRotationFloat(monolith, partialTickTime);
applyRotations(monolith, rotation, interpolatedYaw, partialTickTime);
rotation = handleRotationFloat(monolith, partialTicks);
applyRotations(monolith, rotation, interpolatedYaw, partialTicks);
float f6 = 0.0625F;
float scaleFactor = 0.0625F;
GlStateManager.enableRescaleNormal();
GlStateManager.scale(-1.0F, -1.0F, 1.0F);
preRenderCallback(monolith, partialTickTime);
preRenderCallback(monolith, partialTicks);
GlStateManager.rotate(monolith.pitchLevel, 1.0F, 0.0F, 0.0F);
GlStateManager.translate(0.0F, 24.0F * f6 - 0.0078125F, 0.0F);
GlStateManager.translate(0.0F, 24.0F * scaleFactor - 0.0078125F, 0.0F);
renderModel(monolith, 0, 0, rotation, interpolatedYaw, pitch, f6);
renderModel(monolith, 0, 0, rotation, interpolatedYaw, pitch, scaleFactor);
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GlStateManager.disableTexture2D();
@ -106,7 +102,7 @@ public class RenderMonolith extends RenderLiving<EntityMonolith> {
GlStateManager.disableRescaleNormal();
} catch (Exception e) {
DimDoors.log.error(e);
DimDoors.log.error("Couldn't render entity", e);
}
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
@ -121,6 +117,6 @@ public class RenderMonolith extends RenderLiving<EntityMonolith> {
@Override
protected ResourceLocation getEntityTexture(EntityMonolith monolith) {
return monolith_textures.get(monolith.getTextureState());
return MONOLITH_TEXTURES.get(monolith.getTextureState());
}
}

View file

@ -6,7 +6,7 @@ import org.dimdev.ddutils.lsystem.LSystem;
import org.dimdev.dimdoors.shared.ModConfig;
import org.lwjgl.opengl.GL11;
import java.awt.Point; // TODO: wrong point class!
import java.awt.*;
import static org.lwjgl.opengl.GL11.*;
@ -16,59 +16,57 @@ public final class RiftCrackRenderer {
// Calculate the proper size for the rift render
double scale = size / (poly.maxX - poly.minX);
// Calculate the midpoint of the fractal bounding box
// Calculate the midpoint of the fractal's bounding box
double offsetX = (poly.maxX + poly.minX) / 2d;
double offsetY = (poly.maxY + poly.minY) / 2d;
double offsetZ = 0;
// Changes how far the triangles move
// TODO: Actually seems to control the glow around the rift
float motionMagnitude = 0.6F;
// Jitters that make rifts shake
float jitterSpeed = 0.014f; // Changes how quickly the rift jitters
// Changes how quickly the triangles move
float motionSpeed = 0.014f;
// Number of individual jitter waveforms to generate
// changes how "together" the overall motions are
int jCount = 10;
// Calculate jitter like for monoliths
// Used to be: 0xF1234568 * hashCode(), this is probably to avoid syncing all rifts
long riftRandom = 0;//(long) (0xF1234568L * (xWorld + yWorld * (2L << 21) + zWorld * (2L << 42)));
float time = ((Minecraft.getSystemTime() + riftRandom) % 2000000) * motionSpeed;
double[] jitters = new double[jCount];
// Calculate jitter like for monoliths, depending x, y and z coordinates to avoid all rifts syncing
long riftRandom = (long) (0xF1234568L * (xWorld + yWorld * (2L << 21) + zWorld * (2L << 42)));
float time = (Minecraft.getSystemTime() + riftRandom) % 2000000;
double jitterScale = ModConfig.graphics.riftJitter * size * size * size / 2000f;
// We use random constants here on purpose just to get different wave forms
double xJitter = jitterScale * Math.sin(1.1f * time*size) * Math.sin(0.8f * time);
double yJitter = jitterScale * Math.sin(1.2f * time*size) * Math.sin(0.9f * time);
double zJitter = jitterScale * Math.sin(1.3f * time*size) * Math.sin(0.7f * time);
double xJitter = jitterScale * Math.sin(1.1f * time * size * jitterSpeed) * Math.sin(0.8f * time * jitterSpeed);
double yJitter = jitterScale * Math.sin(1.2f * time * size * jitterSpeed) * Math.sin(0.9f * time * jitterSpeed);
double zJitter = jitterScale * Math.sin(1.3f * time * size * jitterSpeed) * Math.sin(0.7f * time * jitterSpeed);
// generate a series of waveforms
for (int i = 0; i < jCount; i += 1) {
jitters[i] = Math.sin((1F + i / 10F) * time) * Math.cos(1F - i / 10F * time) * motionMagnitude;
// Flutters in the rift's triangles (most noticed in the edges)
float flutterMagnitude = 0.6F; // Changes how far the triangles move
int flutterModulo = 10; // Changes how "together" the overall motions are
float flutterSpeed = 0.014f; // Changes the speed at which the rift flutters
double[] flutters = new double[flutterModulo];
for (int i = 0; i < flutterModulo; i += 1) {
flutters[i] = Math.sin((1F + i / 10F) * time * flutterSpeed) * Math.cos(1F - i / 10F * time * flutterSpeed) * flutterMagnitude;
}
// Set color (nearly black, but inverts background)
GlStateManager.color(0.08f, 0.08f, 0.08f, .3F);
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); // Invert the backgrounds
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
// Draw the next set of triangles to form a background and change their color slightly over time
// Draw the rift
GlStateManager.glBegin(GL11.GL_TRIANGLES);
for (Point p : poly.points) {
int jIndex = Math.abs((p.x + p.y) * (p.x + p.y + 1) / 2 + p.y);
// Reduces most overlap between triangles inside the rift's center
int flutterIndex = Math.abs((p.x + p.y) * (p.x + p.y + 1) / 2 + p.y);
double x = (p.x + jitters[(jIndex + 1) % jCount] - offsetX) * Math.cos(Math.toRadians(riftRotation)) - jitters[(jIndex + 2) % jCount] * Math.sin(Math.toRadians(riftRotation));
double y = p.y + jitters[jIndex % jCount] - offsetY;
double z = (p.x + jitters[(jIndex + 2) % jCount] - offsetZ) * Math.sin(Math.toRadians(riftRotation)) + jitters[(jIndex + 2) % jCount] * Math.cos(Math.toRadians(riftRotation));
// Apply flutter and jitter
double x = (p.x + flutters[(flutterIndex + 1) % flutterModulo] - offsetX) * Math.cos(Math.toRadians(riftRotation)) - flutters[(flutterIndex + 2) % flutterModulo] * Math.sin(Math.toRadians(riftRotation));
double y = p.y + flutters[flutterIndex % flutterModulo] - offsetY;
double z = (p.x + flutters[(flutterIndex + 2) % flutterModulo] - offsetZ) * Math.sin(Math.toRadians(riftRotation)) + flutters[(flutterIndex + 2) % flutterModulo] * Math.cos(Math.toRadians(riftRotation));
// Scale the rift
x *= scale;
y *= scale;
z *= scale;
// Draw the vertex
GL11.glVertex3d(xWorld + x + xJitter, yWorld + y + yJitter, zWorld + z + zJitter);
}
// Stop drawing triangles
GlStateManager.glEnd();
}
}

View file

@ -6,15 +6,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.shared.world.ModDimensions;
// This has exactly the same appearence as the 1.6.4 mod.
@SideOnly(Side.CLIENT)
public class ParticleRiftEffect extends ParticleSimpleAnimated { // TODO: colors, density
public class RiftParticle extends ParticleSimpleAnimated {
private float colorMultiplier;
public ParticleRiftEffect(World world, double x, double y, double z, double motionX, double motionY, double motionZ, float nonPocketColorMultiplier, float pocketColorMultiplier, float scale, int averageAge, int ageSpread) {
public RiftParticle(World world, double x, double y, double z, double motionX, double motionY, double motionZ, float color, float scale, int averageAge, int ageSpread) {
super(world, x, y, z, 160, 8, 0);
this.motionX = motionX;
this.motionY = motionY;
@ -22,19 +18,13 @@ public class ParticleRiftEffect extends ParticleSimpleAnimated { // TODO: colors
particleScale *= scale;
particleMaxAge = averageAge - ageSpread / 2 + rand.nextInt(ageSpread);
colorMultiplier = ModDimensions.isDimDoorsPocketDimension(world) ? pocketColorMultiplier : nonPocketColorMultiplier;
setRBGColorF(color, color, color);
}
@Override
public void renderParticle(BufferBuilder buffer, Entity entity, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float oldRed = particleRed;
float oldGreen = particleGreen;
float oldBlue = particleBlue;
float oldAlpha = particleAlpha;
setRBGColorF(colorMultiplier * particleRed, colorMultiplier * particleGreen, colorMultiplier * particleBlue);
setAlphaF(1 - (float) particleAge / particleMaxAge);
super.renderParticle(buffer, entity, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
setRBGColorF(oldRed, oldGreen, oldBlue);
setAlphaF(oldAlpha);
}
}

View file

@ -10,30 +10,15 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.ddutils.RGBA;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
@SideOnly(Side.CLIENT)
public class TileEntityEntranceRiftRenderer extends TileEntitySpecialRenderer<TileEntityEntranceRift> { // TODO: see TileEntityEndGatewayRenderer
public class TileEntityEntranceRiftRenderer extends TileEntitySpecialRenderer<TileEntityEntranceRift> {
private final ResourceLocation keyPath = new ResourceLocation(DimDoors.MODID + ":textures/other/keyhole.png");
private final ResourceLocation keyholeLight = new ResourceLocation(DimDoors.MODID + ":textures/other/keyhole_light.png");
private final Map<TileEntityEntranceRift, RGBA[]> colorMap = new HashMap<>();
private RGBA[] getColors(TileEntityEntranceRift entrance) {
if (colorMap.containsKey(entrance)) return colorMap.get(entrance);
Random rand = new Random(31100L);
RGBA[] colors = new RGBA[16];
for (int i = 0; i < 16; i++) colors[i] = entrance.getEntranceRenderColor(rand);
colorMap.put(entrance, colors);
return colors;
}
private void renderKeyHole(TileEntityEntranceRift tile, double x, double y, double z, int i) {
EnumFacing rotation = EnumFacing.getHorizontal((tile.orientation.getHorizontalIndex() + 3) % 4);
@ -101,7 +86,7 @@ public class TileEntityEntranceRiftRenderer extends TileEntitySpecialRenderer<Ti
entrance.orientation == EnumFacing.NORTH ||
entrance.orientation == EnumFacing.WEST ||
entrance.orientation == EnumFacing.UP ? entrance.pushIn : entrance.pushIn - 1);
DimensionalWallRenderer.renderDimensionalWall(
DimensionalPortalRenderer.renderDimensionalPortal(
x + offset.x,
y + offset.y,
z + offset.z,
@ -110,7 +95,7 @@ public class TileEntityEntranceRiftRenderer extends TileEntitySpecialRenderer<Ti
entrance.orientation,
entrance.extendLeft + entrance.extendRight,
entrance.extendDown + entrance.extendUp,
getColors(entrance));
entrance.getColors(16));
if (entrance.lockStatus >= 1) {
for (int i = 0; i < 1 + entrance.lockStatus; i++) {

View file

@ -26,7 +26,7 @@ public class TileEntityFloatingRiftRenderer extends TileEntitySpecialRenderer<Ti
renderTesseract(rift, x, y, z, partialTicks);
} else {
long timeLeft = showRiftCoreUntil - System.currentTimeMillis();
if (timeLeft >= 0/*3000 || timeLeft >= 0 && timeLeft / 500 % 2 == 0*/) {
if (timeLeft >= 0) {
renderTesseract(rift, x, y, z, partialTicks);
}
}
@ -35,7 +35,6 @@ public class TileEntityFloatingRiftRenderer extends TileEntitySpecialRenderer<Ti
private void renderCrack(TileEntityFloatingRift rift, double x, double y, double z) {
GL11.glPushMatrix();
// TODO: Make the sky get dark when a player approaches a rift?
// Make the rift render on both sides, disable texture mapping and lighting
GlStateManager.disableLighting();

View file

@ -8,18 +8,18 @@ import org.dimdev.ddutils.RGBA;
public class Cube {
Plane[] planes = new Plane[6];
public Cube(Vector4f first, Vector4f second, Vector4f third, Vector4f fourth, Vector4f fifth, Vector4f sixth, Vector4f seventh, Vector4f eighth) {
planes[0] = new Plane(first, second, third, fourth);
planes[1] = new Plane(fifth, sixth, seventh, eighth);
planes[2] = new Plane(first, third, fifth, seventh);
planes[3] = new Plane(third, fourth, seventh, eighth);
planes[4] = new Plane(second, fourth, sixth, eighth);
planes[5] = new Plane(first, second, fifth, sixth);
public Cube(Vector4f vec1, Vector4f vec2, Vector4f vec3, Vector4f vec4, Vector4f vec5, Vector4f vec6, Vector4f vec7, Vector4f vec8) {
planes[0] = new Plane(vec1, vec2, vec3, vec4);
planes[1] = new Plane(vec5, vec6, vec7, vec8);
planes[2] = new Plane(vec1, vec3, vec5, vec7);
planes[3] = new Plane(vec3, vec4, vec7, vec8);
planes[4] = new Plane(vec2, vec4, vec6, vec8);
planes[5] = new Plane(vec1, vec2, vec5, vec6);
}
@SideOnly(Side.CLIENT)
public void draw(RGBA color, double radian) {
for(Plane plane : planes) {
for (Plane plane : planes) {
plane.draw(color, radian);
}
}

View file

@ -16,11 +16,10 @@ import static com.flowpowered.math.TrigMath.cos;
import static com.flowpowered.math.TrigMath.sin;
public class Plane {
Vector4f[] vectors;
public Plane(Vector4f first, Vector4f second, Vector4f third, Vector4f foruth) {
vectors = new Vector4f[] {first, second, third, foruth};
public Plane(Vector4f vec1, Vector4f vec2, Vector4f vec3, Vector4f vec4) {
vectors = new Vector4f[]{vec1, vec2, vec3, vec4};
}
@SideOnly(Side.CLIENT)
@ -30,57 +29,54 @@ public class Plane {
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
GlStateManager.color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
project(worldRenderer, rotYW(vectors[0], radian),0,0, color);
project(worldRenderer, rotYW(vectors[1], radian),0,1, color);
project(worldRenderer, rotYW(vectors[2], radian),1,1, color);
project(worldRenderer, rotYW(vectors[3], radian),1,0, color);
project(worldRenderer, rotYW(vectors[0], radian), 0, 0, color);
project(worldRenderer, rotYW(vectors[1], radian), 0, 1, color);
project(worldRenderer, rotYW(vectors[2], radian), 1, 1, color);
project(worldRenderer, rotYW(vectors[3], radian), 1, 0, color);
tessellator.draw();
}
private static Vector4f rotXW(Vector4f v, double angle) {
return Matrix4f.from(
cos(angle),0,0,sin(angle),
0,1,0,0,
0,0, 1, 0,
-sin(angle),0, 0,cos(angle))
cos(angle), 0, 0, sin(angle),
0, 1, 0, 0,
0, 0, 1, 0,
-sin(angle), 0, 0, cos(angle))
.transform(v);
}
private static Vector4f rotZW(Vector4f v, double angle) {
return Matrix4f.from(
1,0,0,0,
0,1,0,0,
0,0,cos(angle),-sin(angle),
0,0,sin(angle),cos(angle))
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, cos(angle), -sin(angle),
0, 0, sin(angle), cos(angle))
.transform(v);
}
private static Vector4f rotYW(Vector4f v, double angle) {
return Matrix4f.from(
1,0,0,0,
0,cos(angle),0,sin(angle),
0,0,1,0,
0,-sin(angle),0,cos(angle))
1, 0, 0, 0,
0, cos(angle), 0, sin(angle),
0, 0, 1, 0,
0, -sin(angle), 0, cos(angle))
.transform(v);
}
private static Vector4f rotXY(Vector4f v, double angle) {
return Matrix4f.from(
cos(angle),-sin(angle),0,0,
sin(angle),cos(angle),0,0,
0,0,1,0,
0,0,0,1)
cos(angle), -sin(angle), 0, 0,
sin(angle), cos(angle), 0, 0,
0, 0, 1, 0,
0, 0, 0, 1)
.transform(v);
}
@SideOnly(Side.CLIENT)
private static void project(BufferBuilder buffer, Vector4f vector, int u, int v, RGBA color) {
double scalar = 1d/(vector.getW()+1);
double scalar = 1d / (vector.getW() + 1);
Vector3f vector1 = vector.toVector3().mul(scalar);
buffer.pos(vector1.getX(), vector1.getY(), vector1.getZ()).tex(u,v).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).endVertex();
buffer.pos(vector1.getX(), vector1.getY(), vector1.getZ()).tex(u, v).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).endVertex();
}
}

View file

@ -12,172 +12,172 @@ public class Tesseract {
planes = new Plane[24];
planes[0] = new Plane(
new Vector4f(-0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,-0.5f,0.5f,-0.5f),
new Vector4f(-0.5f,-0.5f,0.5f,-0.5f)
);
new Vector4f(-0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, -0.5f),
new Vector4f(-0.5f, -0.5f, 0.5f, -0.5f)
);
planes[1] = new Plane(
new Vector4f(-0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,0.5f,0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,0.5f,-0.5f)
);
new Vector4f(-0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, -0.5f)
);
planes[2] = new Plane(
new Vector4f(-0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,-0.5f,-0.5f)
);
new Vector4f(-0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, -0.5f, -0.5f)
);
planes[3] = new Plane(
new Vector4f(-0.5f,-0.5f,0.5f,-0.5f),
new Vector4f(0.5f,-0.5f,0.5f,-0.5f),
new Vector4f(0.5f,0.5f,0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,0.5f,-0.5f)
);
new Vector4f(-0.5f, -0.5f, 0.5f, -0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, -0.5f)
);
planes[4] = new Plane(
new Vector4f(-0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,0.5f,-0.5f),
new Vector4f(-0.5f,-0.5f,0.5f,-0.5f)
);
new Vector4f(-0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, -0.5f),
new Vector4f(-0.5f, -0.5f, 0.5f, -0.5f)
);
planes[5] = new Plane(
new Vector4f(0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,0.5f,0.5f,-0.5f),
new Vector4f(0.5f,-0.5f,0.5f,-0.5f)
);
new Vector4f(0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, -0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, -0.5f)
);
planes[6] = new Plane(
new Vector4f(-0.5f,-0.5f,-0.5f,0.5f),
new Vector4f(0.5f,-0.5f,-0.5f,0.5f),
new Vector4f(0.5f,-0.5f,0.5f,0.5f),
new Vector4f(-0.5f,-0.5f,0.5f,0.5f)
);
new Vector4f(-0.5f, -0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, -0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, 0.5f),
new Vector4f(-0.5f, -0.5f, 0.5f, 0.5f)
);
planes[7] = new Plane(
new Vector4f(-0.5f,0.5f,-0.5f,0.5f),
new Vector4f(0.5f,0.5f,-0.5f,0.5f),
new Vector4f(0.5f,0.5f,0.5f,0.5f),
new Vector4f(-0.5f,0.5f,0.5f,0.5f)
);
new Vector4f(-0.5f, 0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, 0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, 0.5f)
);
planes[8] = new Plane(
new Vector4f(-0.5f,-0.5f,-0.5f,0.5f),
new Vector4f(0.5f,-0.5f,-0.5f,0.5f),
new Vector4f(0.5f,0.5f,-0.5f,0.5f),
new Vector4f(-0.5f,0.5f,-0.5f,0.5f)
);
new Vector4f(-0.5f, -0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, -0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, 0.5f),
new Vector4f(-0.5f, 0.5f, -0.5f, 0.5f)
);
planes[9] = new Plane(
new Vector4f(-0.5f,-0.5f,0.5f,0.5f),
new Vector4f(0.5f,-0.5f,0.5f,0.5f),
new Vector4f(0.5f,0.5f,0.5f,0.5f),
new Vector4f(-0.5f,0.5f,0.5f,0.5f)
);
new Vector4f(-0.5f, -0.5f, 0.5f, 0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, 0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, 0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, 0.5f)
);
planes[10] = new Plane(
new Vector4f(-0.5f,-0.5f,-0.5f,0.5f),
new Vector4f(-0.5f,0.5f,-0.5f,0.5f),
new Vector4f(-0.5f,0.5f,0.5f,0.5f),
new Vector4f(-0.5f,-0.5f,0.5f,0.5f)
);
new Vector4f(-0.5f, -0.5f, -0.5f, 0.5f),
new Vector4f(-0.5f, 0.5f, -0.5f, 0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, 0.5f),
new Vector4f(-0.5f, -0.5f, 0.5f, 0.5f)
);
planes[11] = new Plane(
new Vector4f(0.5f,-0.5f,-0.5f,0.5f),
new Vector4f(0.5f,0.5f,-0.5f,0.5f),
new Vector4f(0.5f,0.5f,0.5f,0.5f),
new Vector4f(0.5f,-0.5f,0.5f,0.5f)
);
new Vector4f(0.5f, -0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, 0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, 0.5f)
);
planes[12] = new Plane(
new Vector4f(-0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,-0.5f,0.5f),
new Vector4f(-0.5f,-0.5f,-0.5f,0.5f)
);
new Vector4f(-0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, -0.5f, 0.5f),
new Vector4f(-0.5f, -0.5f, -0.5f, 0.5f)
);
planes[13] = new Plane(
new Vector4f(-0.5f,-0.5f,0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,0.5f,0.5f),
new Vector4f(-0.5f,-0.5f,0.5f,0.5f)
);
new Vector4f(-0.5f, -0.5f, 0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, 0.5f),
new Vector4f(-0.5f, -0.5f, 0.5f, 0.5f)
);
planes[14] = new Plane(
new Vector4f(-0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,0.5f,-0.5f),
new Vector4f(-0.5f,-0.5f,0.5f,-0.5f)
);
new Vector4f(-0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, -0.5f),
new Vector4f(-0.5f, -0.5f, 0.5f, -0.5f)
);
planes[15] = new Plane(
new Vector4f(-0.5f,-0.5f,-0.5f,0.5f),
new Vector4f(-0.5f,0.5f,-0.5f,0.5f),
new Vector4f(-0.5f,0.5f,0.5f,0.5f),
new Vector4f(-0.5f,-0.5f,0.5f,0.5f)
);
new Vector4f(-0.5f, -0.5f, -0.5f, 0.5f),
new Vector4f(-0.5f, 0.5f, -0.5f, 0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, 0.5f),
new Vector4f(-0.5f, -0.5f, 0.5f, 0.5f)
);
planes[16] = new Plane(
new Vector4f(-0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(-0.5f,-0.5f,0.5f,-0.5f),
new Vector4f(-0.5f,-0.5f,0.5f,0.5f),
new Vector4f(-0.5f,-0.5f,-0.5f,0.5f)
);
new Vector4f(-0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(-0.5f, -0.5f, 0.5f, -0.5f),
new Vector4f(-0.5f, -0.5f, 0.5f, 0.5f),
new Vector4f(-0.5f, -0.5f, -0.5f, 0.5f)
);
planes[17] = new Plane(
new Vector4f(-0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,0.5f,-0.5f),
new Vector4f(-0.5f,0.5f,0.5f,0.5f),
new Vector4f(-0.5f,0.5f,-0.5f,0.5f)
);
new Vector4f(-0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, -0.5f),
new Vector4f(-0.5f, 0.5f, 0.5f, 0.5f),
new Vector4f(-0.5f, 0.5f, -0.5f, 0.5f)
);
planes[18] = new Plane(
new Vector4f(0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,0.5f,-0.5f,0.5f),
new Vector4f(0.5f,-0.5f,-0.5f,0.5f)
);
new Vector4f(0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, -0.5f, -0.5f, 0.5f)
);
planes[19] = new Plane(
new Vector4f(0.5f,-0.5f,0.5f,-0.5f),
new Vector4f(0.5f,0.5f,0.5f,-0.5f),
new Vector4f(0.5f,0.5f,0.5f,0.5f),
new Vector4f(0.5f,-0.5f,0.5f,0.5f)
);
new Vector4f(0.5f, -0.5f, 0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, 0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, 0.5f)
);
planes[20] = new Plane(
new Vector4f(0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,0.5f,0.5f,-0.5f),
new Vector4f(0.5f,-0.5f,0.5f,-0.5f)
);
new Vector4f(0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, -0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, -0.5f)
);
planes[21] = new Plane(
new Vector4f(0.5f,-0.5f,-0.5f,0.5f),
new Vector4f(0.5f,0.5f,-0.5f,0.5f),
new Vector4f(0.5f,0.5f,0.5f,0.5f),
new Vector4f(0.5f,-0.5f,0.5f,0.5f)
);
new Vector4f(0.5f, -0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, 0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, 0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, 0.5f)
);
planes[22] = new Plane(
new Vector4f(0.5f,-0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,-0.5f,0.5f,-0.5f),
new Vector4f(0.5f,-0.5f,0.5f,0.5f),
new Vector4f(0.5f,-0.5f,-0.5f,0.5f)
);
new Vector4f(0.5f, -0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, -0.5f),
new Vector4f(0.5f, -0.5f, 0.5f, 0.5f),
new Vector4f(0.5f, -0.5f, -0.5f, 0.5f)
);
planes[23] = new Plane(
new Vector4f(0.5f,0.5f,-0.5f,-0.5f),
new Vector4f(0.5f,0.5f,0.5f,-0.5f),
new Vector4f(0.5f,0.5f,0.5f,0.5f),
new Vector4f(0.5f,0.5f,-0.5f,0.5f)
);
new Vector4f(0.5f, 0.5f, -0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, -0.5f),
new Vector4f(0.5f, 0.5f, 0.5f, 0.5f),
new Vector4f(0.5f, 0.5f, -0.5f, 0.5f)
);
}
@SideOnly(Side.CLIENT)

View file

@ -1,50 +1,43 @@
package org.dimdev.dimdoors.client;
package org.dimdev.dimdoors.proxy;
import org.dimdev.dimdoors.shared.CommonProxy;
import org.dimdev.dimdoors.shared.entities.EntityMonolith;
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.client.IRenderHandler;
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;
import org.dimdev.dimdoors.client.ModelManager;
import org.dimdev.dimdoors.client.RenderMonolith;
import org.dimdev.dimdoors.client.TileEntityEntranceRiftRenderer;
import org.dimdev.dimdoors.client.TileEntityFloatingRiftRenderer;
import org.dimdev.dimdoors.shared.entities.EntityMonolith;
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy {
public class ClientProxy implements IProxy {
@Override
public void onPreInitialization(FMLPreInitializationEvent event) {
super.onPreInitialization(event);
registerRenderers();
}
// Register client-side event handlers
MinecraftForge.EVENT_BUS.register(ModelManager.class);
@Override
public void afterItemsRegistered() {
// Model variants can't be registered from onInitialization because that's too late (models have
// already been loaded by minecraft), but they can't be registered from the onPreInitialization
// event because that's too early (items haven't been registered yet, so RegistryDelegate.name == null.
// causing all item variants to be added to the same item (RegistryDelegate.equals compares the names
// of the delegates only).
ModelManager.registerModelVariants();
ModelManager.addCustomStateMappers();
// Register tile entity renderers
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEntranceRift.class, new TileEntityEntranceRiftRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFloatingRift.class, new TileEntityFloatingRiftRenderer());
// Register monolith renderers
RenderingRegistry.registerEntityRenderingHandler(EntityMonolith.class, manager -> new RenderMonolith(manager, 0.5f));
}
@Override
public void onInitialization(FMLInitializationEvent event) {
super.onInitialization(event);
ModelManager.registerModels();
}
public void registerRenderers() {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEntranceRift.class, new TileEntityEntranceRiftRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFloatingRift.class, new TileEntityFloatingRiftRenderer());
RenderingRegistry.registerEntityRenderingHandler(EntityMonolith.class, manager -> new RenderMonolith(manager, 0.5f));
ModelManager.registerItemModels();
}
@Override

View file

@ -0,0 +1,22 @@
package org.dimdev.dimdoors.proxy;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.client.IRenderHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public interface IProxy {
public void onPreInitialization(FMLPreInitializationEvent event);
public void onInitialization(FMLInitializationEvent event);
public boolean isClient();
public EntityPlayer getLocalPlayer();
public void setCloudRenderer(WorldProvider provider, IRenderHandler renderer);
public void setSkyRenderer(WorldProvider provider, IRenderHandler renderer);
}

View file

@ -1,14 +1,18 @@
package org.dimdev.dimdoors.server;
package org.dimdev.dimdoors.proxy;
import org.dimdev.dimdoors.shared.CommonProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.client.IRenderHandler;
/**
* @author Robijnvogel
*/
public class ServerProxy extends CommonProxy {
public class ServerProxy implements IProxy {
@Override
public void onPreInitialization(FMLPreInitializationEvent event) {}
@Override
public void onInitialization(FMLInitializationEvent event) {}
@Override
public boolean isClient() {

View file

@ -1,80 +0,0 @@
package org.dimdev.dimdoors.shared;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.client.IRenderHandler;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
import org.dimdev.dimdoors.shared.entities.EntityMonolith;
import org.dimdev.dimdoors.shared.items.ModItems;
import org.dimdev.dimdoors.shared.pockets.SchematicHandler;
import org.dimdev.dimdoors.shared.rifts.*;
import org.dimdev.dimdoors.shared.rifts.destinations.*;
import org.dimdev.dimdoors.shared.sound.ModSounds;
import org.dimdev.dimdoors.shared.tileentities.*;
import org.dimdev.dimdoors.shared.world.ModDimensions;
import org.dimdev.dimdoors.shared.world.ModBiomes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
public abstract class CommonProxy {
public void onPreInitialization(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(EventHandler.class);
MinecraftForge.EVENT_BUS.register(ModBlocks.class);
MinecraftForge.EVENT_BUS.register(ModItems.class);
MinecraftForge.EVENT_BUS.register(ModRecipes.class);
MinecraftForge.EVENT_BUS.register(ModSounds.class);
MinecraftForge.EVENT_BUS.register(ModBiomes.class);
registerTileEntities();
ModDimensions.registerDimensions();
EntityRegistry.registerModEntity(new ResourceLocation(DimDoors.MODID, "mob_monolith"), EntityMonolith.class, "monoliths", 0, DimDoors.instance, 70, 1, true);
EntityRegistry.registerEgg(new ResourceLocation(DimDoors.MODID, "mob_monolith"), 0, 0xffffff);
registerRiftDestinations();
}
public void afterItemsRegistered() {}
public void registerRiftDestinations() {
RiftDestination.destinationRegistry.put("available_link", AvailableLinkDestination.class);
RiftDestination.destinationRegistry.put("escape", EscapeDestination.class);
RiftDestination.destinationRegistry.put("global", GlobalDestination.class);
RiftDestination.destinationRegistry.put("limbo", LimboDestination.class);
RiftDestination.destinationRegistry.put("local", LocalDestination.class);
RiftDestination.destinationRegistry.put("public_pocket", PublicPocketDestination.class);
RiftDestination.destinationRegistry.put("pocket_entrance", PocketEntranceMarker.class);
RiftDestination.destinationRegistry.put("pocket_exit", PocketExitMarker.class);
RiftDestination.destinationRegistry.put("private", PrivateDestination.class);
RiftDestination.destinationRegistry.put("private_pocket_exit", PrivatePocketExitDestination.class);
RiftDestination.destinationRegistry.put("relative", RelativeDestination.class);
}
public void onInitialization(FMLInitializationEvent event) {
SchematicHandler.INSTANCE.loadSchematics();
LootTableList.register(new ResourceLocation(DimDoors.MODID, "dungeon_chest"));
LootTableList.register(new ResourceLocation(DimDoors.MODID, "dispenser_projectiles"));
LootTableList.register(new ResourceLocation(DimDoors.MODID, "dispenser_splash_potions"));
LootTableList.register(new ResourceLocation(DimDoors.MODID, "dispenser_potion_arrows"));
}
public void registerTileEntities() {
GameRegistry.registerTileEntity(TileEntityEntranceRift.class, "dimdoors:entrance_rift");
GameRegistry.registerTileEntity(TileEntityFloatingRift.class, "dimdoors:floating_rift");
}
public abstract boolean isClient();
public abstract EntityPlayer getLocalPlayer();
public abstract void setCloudRenderer(WorldProvider provider, IRenderHandler renderer);
public abstract void setSkyRenderer(WorldProvider provider, IRenderHandler renderer);
}

View file

@ -1,21 +1,17 @@
package org.dimdev.dimdoors.shared;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import org.dimdev.pocketlib.PocketRegistry;
import org.dimdev.dimdoors.shared.rifts.registry.RiftRegistry;
import org.dimdev.dimdoors.shared.world.ModDimensions;
public final class EventHandler {
@SubscribeEvent(priority = EventPriority.HIGHEST) // don't let other mods do something based on the event
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onLivingHurt(LivingHurtEvent event) {
Entity entity = event.getEntity();
if (entity.dimension == ModDimensions.LIMBO.getId() && event.getSource() == DamageSource.FALL) {
@ -23,26 +19,9 @@ public final class EventHandler {
}
}
@SubscribeEvent
public static void onEntityEnterChunk(EntityEvent.EnteringChunk event) {
// TODO: Pass to PocketLib
Entity entity = event.getEntity();
if (entity instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) entity;
World world = entity.world;
int dim = world.provider.getDimension();
if (!world.isRemote
&& !player.isDead
&& ModDimensions.isDimDoorsPocketDimension(world)
&& !PocketRegistry.instance(dim).isPlayerAllowedToBeAt(player, player.getPosition())) {
// TODO: make the world circular
}
}
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void onDimensionChange(PlayerEvent.PlayerChangedDimensionEvent event) { // TODO: what about non-players (EntityTravelToDimensionEvent)?
// TODO: PocketLib compatibility
public static void onDimensionChange(PlayerEvent.PlayerChangedDimensionEvent event) {
// TODO: Make this work with other mods (such as Dimensional Industry)
if (!ModDimensions.isDimDoorsPocketDimension(event.fromDim) && ModDimensions.isDimDoorsPocketDimension(event.toDim)) {
RiftRegistry.instance().setOverworldRift(event.player.getUniqueID(), null);
}

View file

@ -3,15 +3,12 @@ package org.dimdev.dimdoors.shared;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.dimdev.dimdoors.DimDoors;
import static net.minecraftforge.common.config.Config.*;
// TODO: fix missing/removed config options automatically on load
@Config(modid = DimDoors.MODID, name = DimDoors.MODID, category = "")
@Mod.EventBusSubscriber(modid = DimDoors.MODID)
public final class ModConfig {
public static General general = new General();

View file

@ -1,6 +1,5 @@
package org.dimdev.dimdoors.shared.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.EnumPushReaction;
import net.minecraft.block.material.Material;
@ -11,6 +10,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
@ -32,27 +32,32 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
// Run server-side only
if (world.isRemote) return;
IBlockState doorState = world.getBlockState(state.getValue(HALF) == EnumDoorHalf.UPPER ? pos.down() : pos); // .down() because only the bottom block has open=true
// Get the door's state (many door blockstates are available for the bottom door half only)
IBlockState doorState = world.getBlockState(state.getValue(HALF) == EnumDoorHalf.UPPER ? pos.down() : pos);
if (doorState.getBlock() != this) return; // The door is in a half-broken state
// Check that it's a door and that the entity portal timer is 0
if (doorState.getBlock().equals(this) && doorState.getValue(BlockDoor.OPEN) && entity.timeUntilPortal == 0) {
entity.timeUntilPortal = 50; // Disable another teleport for that entity for 2.5s
// Check that the door is open and the teleport timer is 0
if (doorState.getValue(BlockDoor.OPEN) && entity.timeUntilPortal == 0) {
entity.timeUntilPortal = 50; // Disable another teleport for 2.5s to avoid duplicate teleports
// Get the rift tile entity and teleport the entity
TileEntityEntranceRift rift = getRift(world, pos, state);
boolean successful = rift.teleport(entity);
if (successful) entity.timeUntilPortal = 0; // Allow the entity to teleport if successful
if (successful && entity instanceof EntityPlayer) {
if (ModConfig.general.closeDoorBehind && !state.getValue(POWERED)) toggleDoor(world, pos, false);
if (rift.isCloseAfterPassThrough()) world.destroyBlock(pos, false);
if (successful) entity.timeUntilPortal = 0; // Allow teleportation again
// Close the door when player passes through if enabled in config and door isn't powered
if (successful && entity instanceof EntityPlayer && ModConfig.general.closeDoorBehind && !doorState.getValue(POWERED)) {
toggleDoor(world, pos, false);
}
}
}
@Override
@Override // Open door even if material is iron
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!canOpen(world, pos, player)) return false;
BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
IBlockState iblockstate = pos.equals(blockpos) ? state : world.getBlockState(blockpos);
@ -75,17 +80,6 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro
return blockMaterial == Material.IRON ? 1005 : 1006;
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
if (canOpen(world, pos, null)) {
super.neighborChanged(state, world, pos, block, fromPos);
}
}
public boolean canOpen(World world, BlockPos pos, EntityPlayer player) {
return true; // TODO: locking system
}
@Override
public boolean hasTileEntity(IBlockState state) {
return state.getValue(BlockDoor.HALF) == EnumDoorHalf.LOWER;
@ -93,16 +87,23 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro
@Override
public boolean canPlaceBlockAt(World world, BlockPos pos) {
// Any door block can be placed on rifts now, items will enforce restrictions now.
// Check that door won't exceed world height.
if (pos.getY() >= world.getHeight() - 1) {
return false;
} else {
IBlockState state = world.getBlockState(pos.down());
return (state.isSideSolid(world, pos, EnumFacing.UP)
|| state.getBlockFaceShape(world, pos.down(), EnumFacing.UP) == BlockFaceShape.SOLID)
&& (world.getBlockState(pos).getBlock().isReplaceable(world, pos) || world.getBlockState(pos).getBlock().equals(ModBlocks.RIFT))
&& world.getBlockState(pos.up()).getBlock().isReplaceable(world, pos.up());
}
IBlockState stateUnder = world.getBlockState(pos.down());
// Check that the bottom block is solid
if (!stateUnder.isSideSolid(world, pos, EnumFacing.UP) || stateUnder.getBlockFaceShape(world, pos.down(), EnumFacing.UP) != BlockFaceShape.SOLID) {
return false;
}
// Check that the bottom block is replaceable or a rift, and that the top block is replaceable
IBlockState stateBottom = world.getBlockState(pos);
IBlockState stateTop = world.getBlockState(pos.up());
return (stateBottom.getBlock().isReplaceable(world, pos) || stateBottom.getBlock() == ModBlocks.RIFT) &&
stateTop.getBlock().isReplaceable(world, pos);
}
@Override
@ -131,10 +132,8 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro
TileEntityEntranceRift rift = getRift(world, pos, state);
super.breakBlock(world, pos, state);
if (world.isRemote) return;
if (rift == null) {
DimDoors.log.error("Rift tile entity was null when breaking block at " + new Location(world, pos) + ", please report this error.");
}
if (rift.isLeaveScarWhenClosed() || rift.isRegistered() && RiftRegistry.instance().getSources(new Location(rift.getWorld(), rift.getPos())).size() > 0 && !rift.isAlwaysDelete()) {
if (rift.isLeaveRiftOnBreak() || rift.isRegistered() && RiftRegistry.instance().getSources(new Location(rift.getWorld(), rift.getPos())).size() > 0 && !rift.isAlwaysDelete()) {
world.setBlockState(pos, ModBlocks.RIFT.getDefaultState());
// This isn't run when we change the block from within block break
TileEntityFloatingRift newRift = (TileEntityFloatingRift) world.getTileEntity(pos);
@ -155,10 +154,27 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro
@Override
public TileEntityEntranceRift getRift(World world, BlockPos pos, IBlockState state) {
// Rift can be in either top or bottom block
TileEntity bottomEntity;
TileEntity topEntity;
if (state.getValue(BlockDoor.HALF) == EnumDoorHalf.LOWER) {
return (TileEntityEntranceRift) world.getTileEntity(pos);
bottomEntity = world.getTileEntity(pos);
topEntity = world.getTileEntity(pos.up());
} else {
return (TileEntityEntranceRift) world.getTileEntity(pos.down());
bottomEntity = world.getTileEntity(pos.down());
topEntity = world.getTileEntity(pos);
}
// TODO: Also notify player in case of error, don't crash
if (bottomEntity instanceof TileEntityEntranceRift && topEntity instanceof TileEntityEntranceRift) {
DimDoors.log.error("Dimensional door at " + pos + " in world " + world + " contained two rifts, please report this. Defaulting to bottom.");
return (TileEntityEntranceRift) bottomEntity;
} else if (bottomEntity instanceof TileEntityEntranceRift) {
return (TileEntityEntranceRift) bottomEntity;
} else if (topEntity instanceof TileEntityEntranceRift) {
return (TileEntityEntranceRift) topEntity;
} else {
throw new RuntimeException("Dimensional door at " + pos + " in world " + world + " contained no rift.");
}
}

View file

@ -1,11 +1,11 @@
package org.dimdev.dimdoors.shared.blocks;
import net.minecraft.block.state.IBlockState;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModItems;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModItems;
import java.util.Random;

View file

@ -1,25 +1,25 @@
package org.dimdev.dimdoors.shared.blocks;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
public class BlockDimensionalPortal extends BlockDimensionalDoor { // TODO: convert to a more general entrances block (like nether portals)
public static final String ID = "dimensional_portal";
public BlockDimensionalPortal() {
super(Material.IRON);
super(Material.PORTAL); // This is the only way to make it collide with water but not other entities, but still have a collision box.
setHardness(1.0F);
setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
@ -44,16 +44,22 @@ public class BlockDimensionalPortal extends BlockDimensionalDoor { // TODO: conv
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
// Run server-side only
if (world.isRemote) return;
// Check that the entity portal timer is 0
// Check that the teleport timer is 0
if (entity.timeUntilPortal == 0) {
entity.timeUntilPortal = 50; // Disable another teleport for that entity for 2.5s
entity.timeUntilPortal = 50; // Disable another teleport for 2.5s to avoid duplicate teleports
// Get the rift tile entity and teleport the entity
TileEntityEntranceRift rift = getRift(world, pos, state);
boolean successful = rift.teleport(entity);
if (successful) entity.timeUntilPortal = 0; // Allow the entity to teleport if successful
if (successful) entity.timeUntilPortal = 0; // Allow teleportation again
// Break the entrance if necessary
if (successful && entity instanceof EntityPlayer && rift.isCloseAfterPassThrough()) {
world.destroyBlock(pos, false);
world.setBlockToAir(pos);
}
}
}

View file

@ -1,9 +1,10 @@
package org.dimdev.dimdoors.shared.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.BlockTrapDoor;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.EnumPushReaction;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
@ -12,7 +13,10 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
// TODO: Make this placeable on rifts
public abstract class BlockDimensionalTrapdoor extends BlockTrapDoor implements ITileEntityProvider, IRiftProvider<TileEntityEntranceRift> {
public BlockDimensionalTrapdoor(Material material) {
@ -30,33 +34,20 @@ public abstract class BlockDimensionalTrapdoor extends BlockTrapDoor implements
boolean successful = rift.teleport(entity);
if (successful) entity.timeUntilPortal = 0; // Allow the entity to teleport if successful
if (successful && entity instanceof EntityPlayer) {
if (world.getStrongPower(pos) == 0) world.setBlockState(pos, state.withProperty(OPEN, false), 2); // TODO: config option playerClosesDoorBehind
if (world.getStrongPower(pos) == 0) world.setBlockState(pos, state.withProperty(OPEN, false), 2);
if (rift.isCloseAfterPassThrough()) world.destroyBlock(pos, false);
}
}
}
@Override
@Override // Open trapdoor even if material is iron
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!canOpen(world, pos, player)) return false;
state = state.cycleProperty(OPEN);
world.setBlockState(pos, state, 2);
playSound(player, world, pos, state.getValue(OPEN));
return true;
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
if (canOpen(world, pos, null)) {
super.neighborChanged(state, world, pos, block, fromPos);
}
}
public boolean canOpen(World world, BlockPos pos, EntityPlayer player) {
return true; // TODO: locking system
}
@Override
public TileEntityEntranceRift createNewTileEntity(World world, int meta) {
TileEntityEntranceRift rift = new TileEntityEntranceRift();
@ -85,5 +76,5 @@ public abstract class BlockDimensionalTrapdoor extends BlockTrapDoor implements
return (TileEntityEntranceRift) world.getTileEntity(pos);
}
public abstract boolean canBePlacedOnRift(); // TODO
public abstract boolean canBePlacedOnRift();
}

View file

@ -1,12 +1,13 @@
package org.dimdev.dimdoors.shared.blocks;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import org.dimdev.dimdoors.DimDoors;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.util.ResourceLocation;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModCreativeTabs;
import java.util.Random;
@ -18,7 +19,7 @@ public class BlockDimensionalTrapdoorWood extends BlockDimensionalTrapdoor { //
super(Material.WOOD);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
setUnlocalizedName(ID);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setHardness(1.0F);
setSoundType(SoundType.WOOD);
}
@ -28,7 +29,8 @@ public class BlockDimensionalTrapdoorWood extends BlockDimensionalTrapdoor { //
return Blocks.TRAPDOOR.getItemDropped(state, rand, fortune);
}
@Override public boolean canBePlacedOnRift() {
@Override
public boolean canBePlacedOnRift() {
return true;
}
}

View file

@ -3,6 +3,7 @@ package org.dimdev.dimdoors.shared.blocks;
import java.util.Random;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModCreativeTabs;
import org.dimdev.dimdoors.shared.items.ModItems;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
@ -22,7 +23,7 @@ public class BlockDoorGold extends BlockDoor {
super(Material.IRON);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
setUnlocalizedName(ID);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setHardness(0.1F);
}

View file

@ -3,6 +3,7 @@ package org.dimdev.dimdoors.shared.blocks;
import java.util.Random;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModCreativeTabs;
import org.dimdev.dimdoors.shared.items.ModItems;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
@ -22,7 +23,7 @@ public class BlockDoorQuartz extends BlockDoor {
super(Material.ROCK);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
setUnlocalizedName(ID);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setHardness(0.1F);
}

View file

@ -17,6 +17,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModCreativeTabs;
import org.dimdev.dimdoors.shared.world.ModDimensions;
import java.util.Random;
@ -30,7 +31,7 @@ public class BlockFabric extends BlockColored {
super(FABRIC);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
setUnlocalizedName(ID);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setDefaultState(getDefaultState().withProperty(COLOR, EnumDyeColor.BLACK));
setHardness(0.1F);
setSoundType(SoundType.STONE);
@ -50,16 +51,19 @@ public class BlockFabric extends BlockColored {
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack heldItem = player.getHeldItem(hand);
Block block = Block.getBlockFromItem(heldItem.getItem());
if (!block.getDefaultState().isNormalCube() || block.hasTileEntity(block.getDefaultState())
|| block == this
|| player.isSneaking()
|| !ModDimensions.isDimDoorsPocketDimension(world)) {
return false;
// Replace fabric in pockets unless it's a special block or the player is sneaking
if (block.getDefaultState().isNormalCube()
&& !block.hasTileEntity(block.getDefaultState())
&& block != this && !player.isSneaking()
&& ModDimensions.isDimDoorsPocketDimension(world)) {
if (!player.isCreative()) heldItem.shrink(1);
world.setBlockState(pos, block.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, heldItem.getMetadata(), player, hand));
return true; // Cancel the block place, and return success (swings arm)
} else {
return false; // Handle the place normally
}
if (!player.isCreative()) heldItem.shrink(1);
world.setBlockState(pos, block.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, heldItem.getMetadata(), player, hand)); //choosing getStateForPlacement over getDefaultState, because it will cause directional blocks, like logs to rotate correctly
return true;
}
}

View file

@ -10,6 +10,7 @@ import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModCreativeTabs;
import java.util.Random;
@ -20,7 +21,7 @@ public class BlockFabricAncient extends BlockColored {
public BlockFabricAncient() {
super(Material.ROCK);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
setUnlocalizedName(ID);
setDefaultState(getDefaultState().withProperty(COLOR, EnumDyeColor.BLACK));

View file

@ -11,6 +11,7 @@ import net.minecraft.world.World;
import org.dimdev.ddutils.Location;
import org.dimdev.ddutils.RotatedLocation;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModCreativeTabs;
import org.dimdev.dimdoors.shared.rifts.destinations.EscapeDestination;
public class BlockFabricEternal extends BlockEmptyDrops { // TODO: make this a glowing red liquid
@ -23,7 +24,7 @@ public class BlockFabricEternal extends BlockEmptyDrops { // TODO: make this a g
super(ETERNAL_FABRIC);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
setUnlocalizedName(ID);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setHardness(-1);
setResistance(6000000.0F);
disableStats();

View file

@ -9,6 +9,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModCreativeTabs;
import org.dimdev.dimdoors.shared.world.limbo.LimboDecay;
import org.dimdev.dimdoors.shared.world.limbo.WorldProviderLimbo;
@ -23,7 +24,7 @@ public class BlockFabricUnravelled extends BlockEmptyDrops {
super(UNRAVELLED_FABRIC);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
setUnlocalizedName(ID);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setHardness(0.1F);
setSoundType(SoundType.STONE);

View file

@ -5,18 +5,14 @@ import java.util.*;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.client.ParticleRiftEffect;
import org.dimdev.dimdoors.client.RiftParticle;
import org.dimdev.dimdoors.shared.ModConfig;
import org.dimdev.dimdoors.shared.items.ModItems;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
import org.dimdev.ddutils.blocks.BlockSpecialAir;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
@ -24,6 +20,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.shared.world.ModDimensions;
public class BlockFloatingRift extends BlockSpecialAir implements ITileEntityProvider, IRiftProvider<TileEntityFloatingRift> {
@ -45,7 +42,7 @@ public class BlockFloatingRift extends BlockSpecialAir implements ITileEntityPro
@Override
@SuppressWarnings("deprecation")
public MapColor getMapColor(IBlockState state, IBlockAccess world, BlockPos pos) {
return MapColor.BLUE;
return MapColor.BLACK;
}
// Unregister the rift on break
@ -72,13 +69,6 @@ public class BlockFloatingRift extends BlockSpecialAir implements ITileEntityPro
return (TileEntityFloatingRift) world.getTileEntity(pos);
}
public void dropWorldThread(World world, BlockPos pos, Random random) {
if (!world.getBlockState(pos).equals(Blocks.AIR)) {
ItemStack thread = new ItemStack(ModItems.WORLD_THREAD, 1);
world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), thread));
}
}
// Render rift effects
@Override
@SideOnly(Side.CLIENT)
@ -88,21 +78,21 @@ public class BlockFloatingRift extends BlockSpecialAir implements ITileEntityPro
if (!(tileEntity instanceof TileEntityFloatingRift)) return;
TileEntityFloatingRift rift = (TileEntityFloatingRift) tileEntity;
// TODO: direction of particles should be rift orientation, speed should depend on size
double speed = 0.1d; // rift.size / 1400f;
boolean outsidePocket = !ModDimensions.isDimDoorsPocketDimension(world);
double speed = 0.1D;
if (rift.closing) { // Renders an opposite color effect if it is being closed by the rift remover
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect(
if (rift.closing) {
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new RiftParticle(
world,
pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5,
rand.nextGaussian() * speed, rand.nextGaussian() * speed, rand.nextGaussian() * speed,
0.8f, 0.4f, 0.55f, 2000, 2000));
outsidePocket ? 0.8f : 0.4f, 0.55f, 2000, 2000));
}
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect(
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new RiftParticle(
world,
pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5,
rand.nextGaussian() * speed, rand.nextGaussian() * speed, rand.nextGaussian() * speed,
0.0f, 0.7f, 0.55f, rift.stabilized ? 750 : 2000, rift.stabilized ? 750 : 2000));
outsidePocket ? 0.0f : 0.7f, 0.55f, rift.stabilized ? 750 : 2000, rift.stabilized ? 750 : 2000));
}
}

View file

@ -27,7 +27,8 @@ public final class ModBlocks {
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event) {
event.getRegistry().registerAll(GOLD_DOOR,
event.getRegistry().registerAll(
GOLD_DOOR,
QUARTZ_DOOR,
IRON_DIMENSIONAL_DOOR,
GOLD_DIMENSIONAL_DOOR,

View file

@ -35,12 +35,13 @@ public abstract class ItemDimensionalDoor extends ItemDoor {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
BlockPos originalPos = pos; // super.onItemUse needs the actual position
if (!world.getBlockState(pos).getBlock().isReplaceable(world, pos)) pos = pos.offset(facing);
boolean placedOnRift = world.getBlockState(pos).getBlock().equals(ModBlocks.RIFT);
boolean placedOnRift = world.getBlockState(pos).getBlock() == ModBlocks.RIFT;
if (!placedOnRift && !player.isSneaking() && isRiftNear(world, pos)) {
// Allowing on second right click would require cancelling client-side, which
// is impossible (see https://github.com/MinecraftForge/MinecraftForge/issues/3272)
// or sending fake packets.
// without sending custom packets.
if (world.isRemote) {
DimDoors.chat(player, "rifts.entrances.rift_too_close");
TileEntityFloatingRiftRenderer.showRiftCoreUntil = System.currentTimeMillis() + ModConfig.graphics.highlightRiftCoreFor;

View file

@ -16,7 +16,7 @@ public class ItemDimensionalDoorGold extends ItemDimensionalDoor {
public ItemDimensionalDoorGold() {
super(ModBlocks.GOLD_DIMENSIONAL_DOOR);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(BlockDimensionalDoorGold.ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, BlockDimensionalDoorGold.ID));
}

View file

@ -11,7 +11,7 @@ public class ItemDimensionalDoorIron extends ItemDimensionalDoor {
public ItemDimensionalDoorIron() {
super(ModBlocks.IRON_DIMENSIONAL_DOOR);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(BlockDimensionalDoorIron.ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, BlockDimensionalDoorIron.ID));
}

View file

@ -13,7 +13,7 @@ public class ItemDimensionalDoorQuartz extends ItemDimensionalDoor {
public ItemDimensionalDoorQuartz() {
super(ModBlocks.PERSONAL_DIMENSIONAL_DOOR);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(BlockDimensionalDoorQuartz.ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, BlockDimensionalDoorQuartz.ID));
}

View file

@ -10,7 +10,7 @@ public class ItemDimensionalDoorUnstable extends ItemDimensionalDoor {
public ItemDimensionalDoorUnstable() {
super(ModBlocks.IRON_DIMENSIONAL_DOOR);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName("unstable_dimensional_door");
setRegistryName(new ResourceLocation(DimDoors.MODID, "unstable_dimensional_door"));
}

View file

@ -13,7 +13,7 @@ public class ItemDimensionalDoorWood extends ItemDimensionalDoor {
public ItemDimensionalDoorWood() {
super(ModBlocks.WARP_DIMENSIONAL_DOOR);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(BlockDimensionalDoorWood.ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, BlockDimensionalDoorWood.ID));
}

View file

@ -19,7 +19,6 @@ import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import java.util.List;
// TODO: Iron dimensional trapdoor
public abstract class ItemDimensionalTrapdoor extends ItemBlock {
public <T extends Block & IRiftProvider<TileEntityEntranceRift>>ItemDimensionalTrapdoor(T block) {

View file

@ -11,7 +11,7 @@ public class ItemDimensionalTrapdoorWood extends ItemDimensionalTrapdoor {
public ItemDimensionalTrapdoorWood() {
super(ModBlocks.WOOD_DIMENSIONAL_TRAPDOOR);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(BlockDimensionalTrapdoorWood.ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, BlockDimensionalTrapdoorWood.ID));
}

View file

@ -11,7 +11,7 @@ public class ItemDoorGold extends ItemDoor {
public ItemDoorGold() {
super(ModBlocks.GOLD_DOOR);
setMaxStackSize(16);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(BlockDoorGold.ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, BlockDoorGold.ID));
}

View file

@ -10,7 +10,7 @@ public class ItemDoorQuartz extends ItemDoor {
public ItemDoorQuartz() {
super(ModBlocks.QUARTZ_DOOR);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(BlockDoorQuartz.ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, BlockDoorQuartz.ID));
}

View file

@ -7,7 +7,6 @@ import org.dimdev.dimdoors.client.TileEntityFloatingRiftRenderer;
import org.dimdev.dimdoors.shared.ModConfig;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
import org.dimdev.ddutils.Location;
import org.dimdev.dimdoors.shared.RayTraceHelper;
import org.dimdev.ddutils.TeleportUtils;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
@ -24,16 +23,13 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
/**
* Created by Jared Johnson on 1/20/2017.
*/
public class ItemRiftBlade extends ItemSword {
public static final String ID = "rift_blade";
public ItemRiftBlade() {
super(ToolMaterial.IRON);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
}
@ -79,7 +75,7 @@ public class ItemRiftBlade extends ItemSword {
BlockPos tpPos = new BlockPos(hitPos.getX() + xDiff, hitPos.getY(), hitPos.getZ() + zDiff);
while (world.getBlockState(tpPos).getMaterial().blocksMovement()) tpPos = tpPos.up(); // TODO: move to ddutils
TeleportUtils.teleport(player, new Location(world, tpPos), player.rotationYaw, player.rotationPitch);
stack.damageItem(1, player); // TODO: check if successful
stack.damageItem(1, player);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}

View file

@ -17,7 +17,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.client.TileEntityFloatingRiftRenderer;
import org.dimdev.dimdoors.shared.ModConfig;
import org.dimdev.dimdoors.shared.RayTraceHelper;
import java.util.List;
@ -28,7 +27,7 @@ public class ItemRiftConfigurationTool extends Item {
ItemRiftConfigurationTool() {
setMaxStackSize(1);
setMaxDamage(16);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
}

View file

@ -8,7 +8,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.client.TileEntityFloatingRiftRenderer;
import org.dimdev.dimdoors.shared.ModConfig;
import org.dimdev.dimdoors.shared.RayTraceHelper;
import org.dimdev.dimdoors.shared.sound.ModSounds;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
import net.minecraft.client.util.ITooltipFlag;
@ -24,7 +23,7 @@ public class ItemRiftRemover extends Item {
public static final String ID = "rift_remover";
public ItemRiftRemover() {
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
setMaxStackSize(1);
@ -40,7 +39,7 @@ public class ItemRiftRemover extends Item {
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { // TODO: permissions
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
RayTraceResult hit = rayTrace(world, player, true);

View file

@ -2,7 +2,6 @@ package org.dimdev.dimdoors.shared.items;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
@ -29,7 +28,7 @@ public class ItemRiftSignature extends Item {
public ItemRiftSignature() {
setMaxStackSize(1);
setMaxDamage(1);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
}
@ -45,7 +44,7 @@ public class ItemRiftSignature extends Item {
ItemStack stack = player.getHeldItem(hand);
pos = world.getBlockState(pos).getBlock().isReplaceable(world, pos) ? pos : pos.offset(side);
// Fail if the player can't place a block there TODO: spawn protection, other plugin support
// Fail if the player can't place a block there
if (!player.canPlayerEdit(pos, side.getOpposite(), stack)) {
return EnumActionResult.FAIL;
}
@ -62,8 +61,8 @@ public class ItemRiftSignature extends Item {
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".stored"), true);
world.playSound(null, player.getPosition(), ModSounds.RIFT_START, SoundCategory.BLOCKS, 0.6f, 1);
} else {
// Place a rift at the saved point TODO: check that the player still has permission
if (!target.getLocation().getBlockState().getBlock().equals(ModBlocks.RIFT)) {
// Place a rift at the saved point
if (target.getLocation().getBlockState().getBlock() != ModBlocks.RIFT) {
if (!target.getLocation().getBlockState().getBlock().isReplaceable(world, target.getLocation().getPos())) {
DimDoors.sendTranslatedMessage(player, "tools.target_became_block");
clearSource(stack); // TODO: But is this fair? It's a rather hidden way of unbinding your signature!

View file

@ -14,7 +14,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.client.TileEntityFloatingRiftRenderer;
import org.dimdev.dimdoors.shared.ModConfig;
import org.dimdev.dimdoors.shared.RayTraceHelper;
import org.dimdev.dimdoors.shared.sound.ModSounds;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
@ -26,13 +25,13 @@ public class ItemRiftStabilizer extends Item {
public ItemRiftStabilizer() {
setMaxStackSize(1);
setMaxDamage(6); // TODO: Add more uses and make it reduce rift growth speed instead?
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { // TODO: permissions
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
RayTraceResult hit = rayTrace(world, player, true);

View file

@ -3,7 +3,6 @@ package org.dimdev.dimdoors.shared.items;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -29,7 +28,7 @@ public class ItemStabilizedRiftSignature extends Item { // TODO: common supercla
public ItemStabilizedRiftSignature() {
setMaxStackSize(1);
setMaxDamage(20);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
}
@ -44,7 +43,7 @@ public class ItemStabilizedRiftSignature extends Item { // TODO: common supercla
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
pos = world.getBlockState(pos).getBlock().isReplaceable(world, pos) ? pos : pos.offset(side);
// Fail if the player can't place a block there TODO: spawn protection, other plugin support
// Fail if the player can't place a block there
if (!player.canPlayerEdit(pos, side.getOpposite(), stack)) {
return EnumActionResult.FAIL;
}
@ -62,7 +61,7 @@ public class ItemStabilizedRiftSignature extends Item { // TODO: common supercla
world.playSound(null, player.getPosition(), ModSounds.RIFT_START, SoundCategory.BLOCKS, 0.6f, 1);
} else {
// Place a rift at the target point
if (!target.getLocation().getBlockState().getBlock().equals(ModBlocks.RIFT)) {
if (target.getLocation().getBlockState().getBlock() != ModBlocks.RIFT) {
if (!target.getLocation().getBlockState().getBlock().isReplaceable(world, target.getLocation().getPos())) {
DimDoors.sendTranslatedMessage(player, "tools.target_became_block");
// Don't clear source, stabilized signatures always stay bound

View file

@ -22,6 +22,6 @@ public class ItemWovenWorldThreadArmor extends ItemArmor {
super(WOVEN_WORLD_THREAD, renderIndex, equipmentSlot);
setUnlocalizedName(name);
setRegistryName(DimDoors.MODID, name);
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);
}
}

View file

@ -0,0 +1,16 @@
package org.dimdev.dimdoors.shared.items;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public final class ModCreativeTabs {
public static final CreativeTabs DIMENSIONAL_DOORS_CREATIVE_TAB = new CreativeTabs("dimensional_doors_creative_tab") {
@Override
@SideOnly(Side.CLIENT)
public ItemStack getTabIconItem() {
return new ItemStack(ModItems.IRON_DIMENSIONAL_DOOR);
}
};
}

View file

@ -26,8 +26,8 @@ public final class ModItems {
// Crafting ingredients
private static final String WORLD_THREAD_ID = "world_thread";
private static final String STABLE_FABRIC_ID = "stable_fabric";
public static final Item WORLD_THREAD = new Item().setUnlocalizedName(WORLD_THREAD_ID).setFull3D().setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB).setRegistryName(new ResourceLocation(DimDoors.MODID, WORLD_THREAD_ID));
public static final Item STABLE_FABRIC = new Item().setUnlocalizedName(STABLE_FABRIC_ID).setFull3D().setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB).setRegistryName(new ResourceLocation(DimDoors.MODID, STABLE_FABRIC_ID));
public static final Item WORLD_THREAD = new Item().setUnlocalizedName(WORLD_THREAD_ID).setFull3D().setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB).setRegistryName(new ResourceLocation(DimDoors.MODID, WORLD_THREAD_ID));
public static final Item STABLE_FABRIC = new Item().setUnlocalizedName(STABLE_FABRIC_ID).setFull3D().setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB).setRegistryName(new ResourceLocation(DimDoors.MODID, STABLE_FABRIC_ID));
// Tools
public static final ItemRiftConfigurationTool RIFT_CONFIGURATION_TOOL = new ItemRiftConfigurationTool();
@ -52,7 +52,8 @@ public final class ModItems {
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
event.getRegistry().registerAll(QUARTZ_DOOR,
event.getRegistry().registerAll(
QUARTZ_DOOR,
QUARTZ_DIMENSIONAL_DOOR,
GOLD_DOOR,
GOLD_DIMENSIONAL_DOOR,
@ -76,7 +77,5 @@ public final class ModItems {
UNRAVELLED_FABRIC,
ETERNAL_FABRIC,
WOOD_DIMENSIONAL_TRAPDOOR);
DimDoors.proxy.afterItemsRegistered();
}
}

View file

@ -1,16 +1,16 @@
package org.dimdev.dimdoors.shared;
package org.dimdev.dimdoors.shared.items;
import org.dimdev.dimdoors.shared.tileentities.TileEntityRift;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
import org.dimdev.dimdoors.shared.tileentities.TileEntityRift;
public final class RayTraceHelper {
public static boolean isFloatingRift(RayTraceResult hit, World world) {
return hit != null && hit.typeOfHit == RayTraceResult.Type.BLOCK && world.getTileEntity(hit.getBlockPos()) instanceof TileEntityFloatingRift;
}
public static boolean isRift(RayTraceResult hit, World world) {
return hit != null && hit.typeOfHit == RayTraceResult.Type.BLOCK && world.getTileEntity(hit.getBlockPos()) instanceof TileEntityRift;
}

View file

@ -1,7 +1,7 @@
package org.dimdev.dimdoors.shared.pockets;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.*;
import org.dimdev.dimdoors.shared.ModConfig;
import org.dimdev.dimdoors.shared.rifts.RiftDestination;
import org.dimdev.dimdoors.shared.rifts.registry.LinkProperties;
import org.dimdev.dimdoors.shared.world.ModDimensions;

View file

@ -241,7 +241,7 @@ public class PocketTemplate {
if (linkProperties != null) rift.setProperties(linkProperties);
rift.setDestination(rift.getProperties() == null || !rift.getProperties().oneWay ? linkTo : null);
if (rift instanceof TileEntityEntranceRift && !rift.isAlwaysDelete()) {
((TileEntityEntranceRift) rift).setLeaveScarWhenClosed(true); // We modified the door's state
((TileEntityEntranceRift) rift).setLeaveRiftOnBreak(true); // We modified the door's state
}
}
}

View file

@ -1,20 +1,18 @@
package org.dimdev.dimdoors.shared.pockets;
import org.dimdev.ddutils.math.MathUtils;
import org.dimdev.ddutils.schem.Schematic;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import org.apache.commons.io.IOUtils;
import org.dimdev.ddutils.math.MathUtils;
import org.dimdev.ddutils.schem.Schematic;
import org.dimdev.dimdoors.DimDoors;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.dimdev.dimdoors.shared.ModConfig;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
@ -22,11 +20,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.dimdev.dimdoors.shared.ModConfig;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompressedStreamTools;
import org.apache.commons.io.IOUtils;
/**
* @author Robijnvogel
*/
@ -82,7 +75,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
try {
Schematic schematic = Schematic.loadFromNBT(CompressedStreamTools.readCompressed(new FileInputStream(file)));
PocketTemplate template = new PocketTemplate(SAVED_POCKETS_GROUP_NAME, file.getName(), null, null, null, schematic, -1, 0);
template.replacePlaceholders(schematic);
PocketTemplate.replacePlaceholders(schematic);
templates.add(template);
} catch (IOException e) {
DimDoors.log.error("Error reading schematic " + file.getName() + ": " + e);
@ -151,12 +144,12 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
}
if (schematic != null
&& (schematic.width > (template.getSize() + 1) * 16 || schematic.length > (template.getSize() + 1) * 16)) {
&& (schematic.width > (template.getSize() + 1) * 16 || schematic.length > (template.getSize() + 1) * 16)) {
schematic = null;
DimDoors.log.warn("Schematic " + template.getId() + " was bigger than specified in its json file and therefore wasn't loaded");
}
template.setSchematic(schematic);
template.replacePlaceholders(schematic);
PocketTemplate.replacePlaceholders(schematic);
}
return validTemplates;
}
@ -224,7 +217,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
* Gets a loaded PocketTemplate by its group and name.
*
* @param group Template group
* @param name Template name
* @param name Template name
* @return The dungeon template with that group and name, or null if it wasn't found
*/
public PocketTemplate getTemplate(String group, String name) {
@ -242,10 +235,10 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
/**
* Gets a random template matching certain criteria.
*
* @param group The template group to choose from.
* @param maxSize Maximum size the template can be.
* @param getLargest Setting this to true will always get the largest template size in that group,
* but still randomly out of the templates with that size (ex. for private and public pockets)
* @param group The template group to choose from.
* @param maxSize Maximum size the template can be.
* @param getLargest Setting this to true will always get the largest template size in that group,
* but still randomly out of the templates with that size (ex. for private and public pockets)
* @return A random template matching those criteria, or null if none were found
*/
public PocketTemplate getRandomTemplate(String group, int depth, int maxSize, boolean getLargest) { // TODO: multiple groups

View file

@ -23,7 +23,7 @@ import net.minecraft.util.EnumFacing;
import java.util.Random;
@NBTSerializable public class TileEntityEntranceRift extends TileEntityRift {
@Saved @Getter protected boolean leaveScarWhenClosed = false;
@Saved @Getter protected boolean leaveRiftOnBreak = false;
@Saved @Getter protected boolean closeAfterPassThrough = false; // TODO: doesn't make sense lore-wise for doors, split into separate tile entity
// Set by the block on tile entity creation, can't get from the block, it's not necessarily a door
@ -52,13 +52,13 @@ import java.util.Random;
TileEntityEntranceRift oldEntranceRift = (TileEntityEntranceRift) oldRift;
closeAfterPassThrough = oldEntranceRift.closeAfterPassThrough;
}
leaveScarWhenClosed = true;
leaveRiftOnBreak = true;
}
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTUtils.readFromNBT(this, nbt); }
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt = super.writeToNBT(nbt); return NBTUtils.writeToNBT(this, nbt); }
public void setLeaveScarWhenClosed(boolean leaveScarWhenClosed) { this.leaveScarWhenClosed = leaveScarWhenClosed; markDirty(); }
public void setLeaveRiftOnBreak(boolean leaveRiftOnBreak) { this.leaveRiftOnBreak = leaveRiftOnBreak; markDirty(); }
public void setLockStatus(byte lockStatus) { this.lockStatus = lockStatus; markDirty(); }
public void setCloseAfterPassThrough(boolean closeAfterPassThrough) { this.closeAfterPassThrough = closeAfterPassThrough; markDirty(); }
@ -66,7 +66,7 @@ import java.util.Random;
public boolean teleport(Entity entity) {
boolean status = super.teleport(entity);
if (riftStateChanged && !alwaysDelete) {
leaveScarWhenClosed = true;
leaveRiftOnBreak = true;
markDirty();
}
return status;
@ -99,7 +99,18 @@ import java.util.Random;
return oldState.getBlock() != newSate.getBlock();
}
public RGBA getEntranceRenderColor(Random rand) {
@SideOnly(Side.CLIENT)
public RGBA[] getColors(int count) { // TODO: cache this
Random rand = new Random(31100L);
RGBA[] colors = new RGBA[count];
for (int i = 0; i < count; i++) {
colors[i] = getEntranceRenderColor(rand);
}
return colors;
}
@SideOnly(Side.CLIENT)
protected RGBA getEntranceRenderColor(Random rand) {
float red, green, blue;
switch(world.provider.getDimension()) {
case -1: // Nether

View file

@ -222,11 +222,6 @@ import javax.annotation.Nonnull;
}
}
@Override
public void markDirty() {
super.markDirty();
}
// Info
protected abstract boolean isFloating();

View file

@ -7,23 +7,29 @@ import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.registries.GameData;
import net.minecraftforge.registries.RegistryManager;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.server.ServerProxy;
import org.dimdev.dimdoors.proxy.ServerProxy;
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
public final class Initializer {
public static void initialize() {
Bootstrap.register();
ModMetadata md = new ModMetadata();
md.modId = DimDoors.MODID;
ModContainer mc = new DummyModContainer(md);
Loader.instance().setupTestHarness(mc);
Loader.instance().setActiveModContainer(mc);
DimDoors.instance = new DimDoors();
DimDoors.proxy = new ServerProxy();
DimDoors.instance.onPreInitialization(new FMLPreInitializationEvent());
ModBlocks.registerBlocks(new RegistryEvent.Register<Block>(GameData.BLOCKS, RegistryManager.ACTIVE.getRegistry(GameData.BLOCKS)));
new ServerProxy().registerTileEntities();
new ServerProxy().registerRiftDestinations();
Loader.instance().setActiveModContainer(null);
}
}

View file

@ -156,7 +156,7 @@ public final class SchematicGenerator {
.build());
rift.setProperties(link);
rift.setLeaveScarWhenClosed(true);
rift.setLeaveRiftOnBreak(true);
NBTTagCompound tileNBT = rift.serializeNBT();
tileNBT.setInteger("x", (size - 1) / 2);
tileNBT.setInteger("y", 5);

View file

@ -45,12 +45,6 @@ public class BiomeLimbo extends Biome {
@Override public void genTerrainBlocks(World world, Random rand, ChunkPrimer chunkPrimer, int x, int z, double noiseVal) {}
@Override
@SideOnly(Side.CLIENT)
public int getSkyColorByTemp(float currentTemperature) { // TODO: what does this do?
return super.getSkyColorByTemp(currentTemperature);
}
// TODO: check that black/white grass and foliage in getModdedBiomeGrassColor is compatible with other mods such as Quark's greener grass option
@Override
@SideOnly(Side.CLIENT)

View file

@ -73,7 +73,7 @@ public class WorldProviderLimbo extends WorldProvider {
@Override
public boolean canCoordinateBeSpawn(int x, int z) {
BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z));
return world.getBlockState(pos).equals(ModBlocks.UNRAVELLED_FABRIC.getDefaultState());
return world.getBlockState(pos) == ModBlocks.UNRAVELLED_FABRIC.getDefaultState();
}
@Override

View file

@ -45,6 +45,4 @@ import org.dimdev.ddutils.nbt.NBTUtils;
int gridSize = PocketRegistry.instance(dim).getGridSize();
return new BlockPos(x * gridSize * 16, 0, z * gridSize * 16);
}
// TODO: more pockets methods
}

View file

@ -11,7 +11,6 @@ import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.storage.MapStorage;
@ -146,7 +145,7 @@ import org.dimdev.dimdoors.shared.ModConfig;
return getPocket(posToID(pos));
}
public boolean isPlayerAllowedToBeAt(EntityPlayerMP player, BlockPos pos) {
public boolean isWithinPocketBounds(BlockPos pos) {
Pocket pocket = getPocketAt(pos);
return pocket != null && pocket.isInBounds(pos);
}

View file

@ -47,7 +47,7 @@ import org.dimdev.dimdoors.shared.world.limbo.WorldProviderLimbo;
if (!limboConsideredWorld && world.provider instanceof WorldProviderLimbo) {
world = WorldUtils.getWorld(0);
}
float spread = ModConfig.general.depthSpreadFactor * depth; // TODO: gaussian spread
float spread = ModConfig.general.depthSpreadFactor * depth; // TODO: gaussian spread, handle air-filled/pocket world
int newX = (int) (x + spread * 2 * (Math.random() - 0.5));
int newZ = (int) (z + spread * 2 * (Math.random() - 0.5));
BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(newX, 0, newZ));

View file

@ -116,7 +116,7 @@ commands.saveschem.success=Pocket %s has been successfully saved
commands.generic.dimdoors.not_in_pocket_dim=You must be in a pocket dimension to use this command.
commands.generic.dimdoors.not_in_pocket=You must be in a pocket to use this command.
rifts.unlinked=This rift has no destinations
rifts.unlinked=This rift leads nowhere
rifts.destinations.escape.cannot_escape_limbo=Nice try, but you'll need to either die or find some eternal fabric to get out of Limbo.
rifts.destinations.escape.not_in_pocket_dim=You can only use this to escape from a pocket dimension!
rifts.destinations.escape.did_not_use_rift=You didn't use a rift to enter the pocket dimension, so you ended up in Limbo!

View file

@ -97,7 +97,7 @@ commands.saveschem.success=La modèle de dimension de poche %s a été sauvegard
commands.generic.dimdoors.not_in_pocket_dim=Vous devez être dans une dimension contenant des dimension de poche pour utiliser cette commande.
commands.generic.dimdoors.not_in_pocket=Vous devez être dans une dimension de poche pour utiliser cette commande.
rifts.unlinked=Cette fissure n'a pas de destination
rifts.unlinked=Cette fissure ne mene nulle part
rifts.destinations.escape.cannot_escape_limbo=Bien éssayé, mais il faut soit mourrir ou trouver de l'étoffe eternelle pour s'échapper des Limbes.
rifts.destinations.escape.not_in_pocket_dim=Vous ne pouvez utiliser cela que pour vous échapper d'une dimension de poche!
rifts.destinations.escape.did_not_use_rift=Vouz n'avez pas utilisé une fissure pour entrer dans la dimension de poche donc vous tombez dans les Limbes!