This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
forked from Bukkit/Bukkit
-
Notifications
You must be signed in to change notification settings - Fork 11
Additions for improved BlockType-system (adds hay, ender-portal-frame, improved lever-facing) #60
Open
Tonodus
wants to merge
6
commits into
GlowstoneMC:master
Choose a base branch
from
Tonodus:BBT
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4b48dc1
added hay-MaterialData
Tonodus 71120e2
changed lever: setFacingDirection takes notice of BluckFace.UP/DOWN now
Tonodus d064bfb
added EnderPortalFrame-MaterialData
Tonodus f2d28b8
added deprecated javadocs, added toString() and clone()
Tonodus 58c2bb9
formatting
Tonodus 889b3ae
fixed missing javadocs
Tonodus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
src/main/java/org/bukkit/material/EnderPortalFrame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package org.bukkit.material; | ||
|
||
import org.bukkit.block.BlockFace; | ||
import org.bukkit.Material; | ||
|
||
/** | ||
* Represents an EnderPortalFrame | ||
*/ | ||
public class EnderPortalFrame extends MaterialData implements Directional { | ||
public EnderPortalFrame() { | ||
super(Material.ENDER_PORTAL_FRAME); | ||
} | ||
|
||
/** | ||
* @deprecated magic value | ||
*/ | ||
public EnderPortalFrame(int type) { | ||
super(type); | ||
} | ||
|
||
public EnderPortalFrame(Material type) { | ||
super(type); | ||
} | ||
|
||
/** | ||
* @deprecated magic value | ||
*/ | ||
public EnderPortalFrame(int type, byte data) { | ||
super(type, data); | ||
} | ||
|
||
/** | ||
* @deprecated magic value | ||
*/ | ||
public EnderPortalFrame(Material type, byte data) { | ||
super(type, data); | ||
} | ||
|
||
/** | ||
* Gets whether an EYE_OF_ENDER was placed in this block | ||
* @return true if an EYE_OF_ENDER was placed in this block, false otherwise | ||
*/ | ||
public boolean hasEye() { | ||
return getData() > 3; | ||
} | ||
|
||
/** | ||
* Sets whether an EYE_OF_ENDER was placed in this block | ||
* @param hasEye whether an EYE_OF_ENDER was placed in this block | ||
*/ | ||
public void setEye(boolean hasEye) { | ||
byte data = getData(); | ||
if (hasEye) | ||
data |= 0x4; | ||
else | ||
data &= 0x3; | ||
setData(data); | ||
} | ||
|
||
@Override | ||
public void setFacingDirection(BlockFace face) { | ||
byte data = (byte) (getData() & 0x4); | ||
|
||
switch (face) { | ||
case SOUTH: | ||
data |= 0x0; | ||
break; | ||
case WEST: | ||
data |= 0x1; | ||
break; | ||
case NORTH: | ||
data |= 0x2; | ||
break; | ||
case EAST: | ||
default: | ||
data |= 0x3; | ||
break; | ||
} | ||
|
||
setData(data); | ||
} | ||
|
||
@Override | ||
public BlockFace getFacing() { | ||
switch (getData() & 0x3) { | ||
case 0: | ||
return BlockFace.SOUTH; | ||
case 1: | ||
return BlockFace.WEST; | ||
case 2: | ||
return BlockFace.NORTH; | ||
case 3: | ||
return BlockFace.EAST; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public EnderPortalFrame clone() { | ||
return (EnderPortalFrame) super.clone(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return super.toString() + " with" + (hasEye() ? "" : "out") + " eye of ender facing " + getFacing(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.bukkit.material; | ||
|
||
import org.bukkit.block.BlockFace; | ||
import org.bukkit.Material; | ||
|
||
/** | ||
* Represents a hay block | ||
*/ | ||
public class Hay extends MaterialData implements Directional { | ||
/** | ||
* @deprecated magic value | ||
*/ | ||
public Hay(int type) { | ||
super(type); | ||
} | ||
|
||
public Hay(Material type) { | ||
super(type); | ||
} | ||
|
||
/** | ||
* @deprecated magic value | ||
*/ | ||
public Hay(int type, byte data) { | ||
super(type, data); | ||
} | ||
|
||
/** | ||
* @deprecated magic value | ||
*/ | ||
public Hay(Material type, byte data) { | ||
super(type, data); | ||
} | ||
|
||
@Override | ||
public void setFacingDirection(BlockFace face) { | ||
switch (face) { | ||
case NORTH: | ||
case SOUTH: | ||
setData((byte) 8); | ||
break; | ||
case WEST: | ||
case EAST: | ||
setData((byte) 4); | ||
break; | ||
case UP: | ||
case DOWN: | ||
setData((byte) 0); | ||
break; | ||
} | ||
} | ||
|
||
@Override | ||
public BlockFace getFacing() { | ||
switch (getData()) { | ||
case 8: | ||
return BlockFace.NORTH; | ||
case 4: | ||
return BlockFace.EAST; | ||
case 0: | ||
default: | ||
return BlockFace.UP; | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return super.toString() + " facing " + getFacing(); | ||
} | ||
|
||
@Override | ||
public Hay clone() { | ||
return (Hay) super.clone(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,41 @@ public void setFacingDirection(BlockFace face) { | |
byte data = (byte) (getData() & 0x8); | ||
BlockFace attach = getAttachedFace(); | ||
|
||
if (face == BlockFace.UP) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is going on here? There appears to be several changes that do not need to be made |
||
switch (attach) { | ||
case NORTH: | ||
case SOUTH: | ||
data |= 0x5; | ||
break; | ||
|
||
case EAST: | ||
case WEST: | ||
default: | ||
data |= 0x6; | ||
break; | ||
|
||
} | ||
|
||
setData(data); | ||
return; | ||
} else if (face == BlockFace.DOWN) { | ||
switch (attach) { | ||
case EAST: | ||
case WEST: | ||
data |= 0x0; | ||
break; | ||
|
||
case NORTH: | ||
case SOUTH: | ||
default: | ||
data |= 0x7; | ||
break; | ||
} | ||
|
||
setData(data); | ||
return; | ||
} | ||
|
||
if (attach == BlockFace.DOWN) { | ||
switch (face) { | ||
case SOUTH: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing javadocs