Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
planetguy32 committed Oct 4, 2015
2 parents f372746 + b392e39 commit 7a433b8
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 77 deletions.
8 changes: 0 additions & 8 deletions src/main/java/me/planetguy/remaininmotion/core/ModRiM.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import me.planetguy.remaininmotion.network.PacketManager;
import me.planetguy.remaininmotion.network.PacketSpecterVelocity;
import net.minecraft.block.Block;
import me.planetguy.lib.PLHelper;
import me.planetguy.lib.prefab.GuiHandlerPrefab;
Expand Down Expand Up @@ -185,13 +184,6 @@ private void handleBlacklistIMC(String message, Blacklist targetList, String sen
}
}

@SubscribeEvent
public void onJoin(PlayerEvent.PlayerLoggedInEvent event){
if(!(event.player instanceof EntityPlayerMP)) return;
if(((EntityPlayerMP) event.player).isClientWorld())
PacketSpecterVelocity.send((EntityPlayerMP) event.player);
}

/*@SubscribeEvent
public void onFinishTeleporting(EntityJoinWorldEvent event){
if(!(event.entity instanceof EntityPlayerMP)) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ public void Process() {
CarriageMotion.MotionDuration = BoundedInteger("MotionDurationInTicks", "Duration of motion in ticks", 1,
CarriageMotion.MotionDuration, Integer.MAX_VALUE);

TileEntityMotiveSpectre.velocity = 1 / ((double) CarriageMotion.MotionDuration);

CarriageMotion.TeleportationDuration = BoundedInteger("TeleportDurationInTicks",
"Duration of translocation in ticks", 1, CarriageMotion.TeleportationDuration, Integer.MAX_VALUE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
import me.planetguy.remaininmotion.motion.CarriageObstructionException;
import me.planetguy.remaininmotion.motion.CarriagePackage;
import me.planetguy.remaininmotion.api.Moveable;
import me.planetguy.remaininmotion.api.RiMRegistry;
import me.planetguy.remaininmotion.api.event.BlockPreMoveEvent;
import me.planetguy.remaininmotion.api.event.IBlockPos;
import me.planetguy.remaininmotion.base.BlockCamouflageable;
import me.planetguy.remaininmotion.base.BlockRiM;
import me.planetguy.remaininmotion.base.TileEntityCamouflageable;
import me.planetguy.remaininmotion.core.ModRiM;
Expand All @@ -28,22 +24,19 @@
import me.planetguy.remaininmotion.spectre.TileEntityMotiveSpectre;
import me.planetguy.remaininmotion.spectre.TileEntitySupportiveSpectre;
import me.planetguy.remaininmotion.util.WorldUtil;
import me.planetguy.remaininmotion.util.position.AABBUtil;
import me.planetguy.remaininmotion.util.position.BlockPosition;
import me.planetguy.remaininmotion.util.position.BlockRecord;
import me.planetguy.remaininmotion.util.position.BlockRecordSet;
import me.planetguy.remaininmotion.util.transformations.ArrayRotator;
import me.planetguy.remaininmotion.util.transformations.Directions;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRailBase;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
Expand All @@ -52,7 +45,6 @@
import cofh.api.energy.IEnergyHandler;

import java.util.Set;
import java.util.UUID;

@Optional.Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHCore")
public abstract class TileEntityCarriageDrive extends TileEntityCamouflageable implements IEnergyHandler {
Expand Down Expand Up @@ -82,6 +74,10 @@ public abstract class TileEntityCarriageDrive extends TileEntityCamouflageable i

public boolean requiresScrewdriverToOpen=false;

// Elevator mode
public int personalDurationInTicks = CarriageMotion.MotionDuration;
public boolean zeroContinuousCooldown = false;

@Override
public void WriteCommonRecord(NBTTagCompound tag) {
tag.setBoolean("Continuous", Continuous);
Expand All @@ -98,6 +94,13 @@ public void WriteCommonRecord(NBTTagCompound tag) {
tag.setBoolean("screwdriver", requiresScrewdriverToOpen);

tag.setBoolean("anchored", this.isAnchored);

// Elevator Mode
// in common to ensure rendering is synced
// should also fix #118
tag.setInteger("PersonalDuration", personalDurationInTicks);

tag.setBoolean("ForceZeroCooldown", zeroContinuousCooldown);
}

@Override
Expand Down Expand Up @@ -128,6 +131,13 @@ public void ReadCommonRecord(NBTTagCompound tag) {
requiresScrewdriverToOpen=tag.getBoolean("screwdriver");

isAnchored=tag.getBoolean("anchored");

// Elevator Mode
// in common to ensure rendering is synced
// should also fix #118
personalDurationInTicks = tag.getInteger("PersonalDuration");

zeroContinuousCooldown = tag.getBoolean("ForceZeroCooldown");
}

@Override
Expand Down Expand Up @@ -167,7 +177,7 @@ public boolean HandleToolUsage(int Side, boolean Sneaking, EntityPlayer player)
}

public void ToggleActivity() {
if (Active && Continuous) {
if (Active && Continuous && !zeroContinuousCooldown) {
CooldownRemaining = RiMConfiguration.CarriageDrive.ContinuousCooldown;
}else if(Active){
Signalled=true;
Expand Down Expand Up @@ -250,15 +260,15 @@ public void updateEntity() {

if(Active) {
if (ticksExisted > 0
&& ticksExisted < CarriageMotion.MotionDuration
&& ticksExisted < personalDurationInTicks
&& ticksExisted % 20 == 0) {
if (Anchored()) {
ModRiM.plHelper.playSound(worldObj, xCoord, yCoord, zCoord,
CarriageMotion.SoundFile, CarriageMotion.volume, 1f);
}
}
ticksExisted++;
if (ticksExisted >= CarriageMotion.MotionDuration) ticksExisted = 0;
if (ticksExisted >= personalDurationInTicks) ticksExisted = 0;
} else {
if(ticksExisted != 0) ticksExisted = 0;
}
Expand Down Expand Up @@ -588,7 +598,12 @@ public void EstablishSpectre(CarriagePackage Package) {
//The above setBlock already creates the TE
//worldObj.setTileEntity(CarriageX, CarriageY, CarriageZ, new TileEntityMotiveSpectre());

((TileEntityMotiveSpectre) worldObj.getTileEntity(CarriageX, CarriageY, CarriageZ)).Absorb(Package);
TileEntityMotiveSpectre specter = ((TileEntityMotiveSpectre) worldObj.getTileEntity(CarriageX, CarriageY, CarriageZ));
specter.Absorb(Package);

// Elevator Mode
specter.personalDurationInTicks = this.personalDurationInTicks;
specter.personalVelocity = 1 / ((double) specter.personalDurationInTicks);
}

public abstract CarriagePackage GeneratePackage(TileEntity carriage, Directions CarriageDirection,
Expand Down Expand Up @@ -684,6 +699,7 @@ public void setConfiguration(long flags, EntityPlayerMP changer){
SideClosed[5]=(flags & 1<<Buttons.EAST.ordinal()) != 0;
requiresScrewdriverToOpen=(flags & 1<<Buttons.SCREWDRIVER_MODE.ordinal()) != 0;
Continuous=(flags & 1<<Buttons.CONTINUOUS_MODE.ordinal()) != 0;
zeroContinuousCooldown =(flags & 1<<Buttons.ZERO_COOLDOWN.ordinal()) != 0;

//flush changes to clients and persistence
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public enum Buttons {
EAST,
SCREWDRIVER_MODE,
CONTINUOUS_MODE,
MOVE_WITH_CARRIAGE
MOVE_WITH_CARRIAGE,
ZERO_COOLDOWN

;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiLabel;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import me.planetguy.lib.prefab.ContainerPrefab;
import me.planetguy.lib.prefab.GuiPrefab;
import me.planetguy.lib.util.Debug;
import me.planetguy.remaininmotion.core.ModRiM;
import me.planetguy.remaininmotion.drive.TileEntityCarriageDrive;
import me.planetguy.remaininmotion.network.PacketCarriageUpdate;
Expand All @@ -32,6 +26,8 @@ public class GuiDriveCommon extends GuiPrefab implements ITooltipDrawer {
protected long state=0;

private List<String> deferredTooltipLines;

// TODO make a fucking gui for elevator mode

public GuiDriveCommon(InventoryPlayer playerInv, TileEntity te) {
super(new ContainerDrive(playerInv, te), rl);
Expand All @@ -46,6 +42,8 @@ public void stateFromTE(TileEntityCarriageDrive te){
}
if(te.Continuous)
state=state|(1<<(3+Buttons.CONTINUOUS_MODE.ordinal()));
if(te.zeroContinuousCooldown)
state=state|(1<<(3+Buttons.ZERO_COOLDOWN.ordinal()));
if(te.requiresScrewdriverToOpen)
state=state|(1<<(3+Buttons.SCREWDRIVER_MODE.ordinal()));
if(!te.isAnchored)
Expand Down Expand Up @@ -78,7 +76,8 @@ public void initGui(){

createButton(-81, -60, Buttons.SCREWDRIVER_MODE);
createButton(-59, -60, Buttons.CONTINUOUS_MODE);
createContinuousButton();
createButton(-14, -60, Buttons.ZERO_COOLDOWN);
createAnchorButton();


createButton(-59, -31, Buttons.NORTH);
Expand All @@ -90,7 +89,7 @@ public void initGui(){
stateToButtons();
}

protected void createContinuousButton(){
protected void createAnchorButton(){
createButton(-37, -60, Buttons.MOVE_WITH_CARRIAGE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public String getLabel() {
}

// Do nothing - translocators
protected void createContinuousButton(){
protected void createAnchorButton(){

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public IMessage onMessage(NBTPacketDown message, MessageContext ctx) {
PacketRenderData.receive(message.body, Minecraft.getMinecraft().thePlayer.worldObj);
} else if (message.type==TypesDown.MULTIPART_PROPAGATION.ordinal()) {
PacketMultipartSynchronization.receive(message.body, Minecraft.getMinecraft().thePlayer.worldObj);
} else if (message.type==TypesDown.SPECTRE_VELOCITY.ordinal()) {
PacketSpecterVelocity.receive(message.body, Minecraft.getMinecraft().thePlayer.worldObj);
}
}
return null;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

public enum TypesDown {
RENDER,
MULTIPART_PROPAGATION,
SPECTRE_VELOCITY;
MULTIPART_PROPAGATION;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public void Render(TileEntity TileEntity, float PartialTick) {
double Offset;

if (RiMConfiguration.CarriageMotion.RenderInFinalPositionDuringLag
&& (Spectre.ticksExisted >= RiMConfiguration.CarriageMotion.MotionDuration)) {
&& (Spectre.ticksExisted >= Spectre.personalDurationInTicks)) {
Offset = 1;
} else {
Offset = Math.min(TileEntityMotiveSpectre.velocity * (Spectre.ticksExisted + PartialTick), 1.0D);
Offset = Math.min(Spectre.personalVelocity * (Spectre.ticksExisted + PartialTick), 1.0D);
}

Render.Translate(Offset * Spectre.motionDirection.deltaX - Spectre.xCoord, Offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public void renderTileEntityAt(TileEntity TileEntity, double X, double Y, double
double Offset;

if (RiMConfiguration.CarriageMotion.RenderInFinalPositionDuringLag
&& (Spectre.ticksExisted >= RiMConfiguration.CarriageMotion.MotionDuration)) {
&& (Spectre.ticksExisted >= Spectre.personalDurationInTicks)) {
Offset = 1;
} else {
Offset = Math.min(TileEntityMotiveSpectre.velocity * (Spectre.ticksExisted + PartialTick), 1.0D);
Offset = Math.min(Spectre.personalVelocity * (Spectre.ticksExisted + PartialTick), 1.0D);
}
if (Spectre.renderCacheKey != null) {

Expand Down
Loading

0 comments on commit 7a433b8

Please sign in to comment.