下面列出了net.minecraft.util.Mirror#NONE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void rotateEntity(Entity entity, double x, double y, double z, Rotation rotationCombined, Mirror mirrorMain, Mirror mirrorSub)
{
float rotationYaw = entity.rotationYaw;
if (mirrorMain != Mirror.NONE) { rotationYaw = entity.getMirroredYaw(mirrorMain); }
if (mirrorSub != Mirror.NONE) { rotationYaw = entity.getMirroredYaw(mirrorSub); }
if (rotationCombined != Rotation.NONE) { rotationYaw += entity.rotationYaw - entity.getRotatedYaw(rotationCombined); }
entity.setLocationAndAngles(x, y, z, rotationYaw, entity.rotationPitch);
entity.prevRotationYaw = rotationYaw;
entity.prevRotationPitch = entity.rotationPitch;
if (entity instanceof EntityLivingBase)
{
EntityLivingBase livingBase = (EntityLivingBase) entity;
livingBase.rotationYawHead = rotationYaw;
livingBase.prevRotationYawHead = rotationYaw;
livingBase.renderYawOffset = rotationYaw;
livingBase.prevRenderYawOffset = rotationYaw;
}
}
void resetToOriginalValues()
{
this.pos = this.defaultPos;
this.rotation = Rotation.NONE;
this.mirror = Mirror.NONE;
this.enabled = true;
this.ignoreEntities = false;
}
public boolean isRegionPlacementModified(BlockPos originalPosition)
{
return this.isEnabled() == false ||
this.ignoreEntities() ||
this.getMirror() != Mirror.NONE ||
this.getRotation() != Rotation.NONE ||
this.getPos().equals(originalPosition) == false;
}
public static IBlockState getUntransformedBlockState(IBlockState state, SchematicPlacement schematicPlacement, String subRegionName)
{
SubRegionPlacement placement = schematicPlacement.getRelativeSubRegionPlacement(subRegionName);
if (placement != null)
{
final Rotation rotationCombined = PositionUtils.getReverseRotation(schematicPlacement.getRotation().add(placement.getRotation()));
final Mirror mirrorMain = schematicPlacement.getMirror();
Mirror mirrorSub = placement.getMirror();
if (mirrorSub != Mirror.NONE &&
(schematicPlacement.getRotation() == Rotation.CLOCKWISE_90 ||
schematicPlacement.getRotation() == Rotation.COUNTERCLOCKWISE_90))
{
mirrorSub = mirrorSub == Mirror.FRONT_BACK ? Mirror.LEFT_RIGHT : Mirror.FRONT_BACK;
}
if (rotationCombined != Rotation.NONE)
{
state = state.withRotation(rotationCombined);
}
if (mirrorSub != Mirror.NONE)
{
state = state.withMirror(mirrorSub);
}
if (mirrorMain != Mirror.NONE)
{
state = state.withMirror(mirrorMain);
}
}
return state;
}
private void toggleMirror(ItemStack stack, Mode mode, EntityPlayer player)
{
Mirror mirror = player.getHorizontalFacing().getAxis() == EnumFacing.Axis.Z ? Mirror.LEFT_RIGHT : Mirror.FRONT_BACK;
// Same mirror setting as the one stored, toggle mirror off
if (mirror == this.getMirror(stack) && this.isMirrored(stack))
{
mirror = Mirror.NONE;
}
this.setMirror(stack, mode, mirror);
}
public Mirror getMirror(ItemStack stack, Mode mode)
{
int sel = this.getSelectionIndex(stack);
NBTTagCompound tag = this.getModeTag(stack, mode);
if (tag.getBoolean("IsMirrored_" + sel) && tag.hasKey("Mirror_" + sel, Constants.NBT.TAG_BYTE))
{
return Mirror.values()[tag.getByte("Mirror_" + sel) % Mirror.values().length];
}
return Mirror.NONE;
}
public TofuCastleTemplate(TemplateManager manager, BlockPos pos, Rotation rotation, String templateName) {
this(manager, pos, rotation, Mirror.NONE, templateName);
}
/**
* Writes the most important/basic settings to JSON.
* If <b>minimal</b> is true, then only non-default rotation, mirror etc. values are included,
* and the name is not included. This is meant for sharing the settings string with other people.
* @param minimal
* @return
*/
public JsonObject baseSettingsToJson(boolean minimal)
{
JsonObject obj = new JsonObject();
boolean all = minimal == false;
obj.add("origin", JsonUtils.blockPosToJson(this.origin));
if (all)
{
obj.add("name", new JsonPrimitive(this.name));
}
if (this.rotation != Rotation.NONE)
{
obj.add("rotation", new JsonPrimitive(this.rotation.name()));
}
if (this.mirror != Mirror.NONE)
{
obj.add("mirror", new JsonPrimitive(this.mirror.name()));
}
if (this.ignoreEntities())
{
obj.add("ignore_entities", new JsonPrimitive(this.ignoreEntities()));
}
if (this.gridSettings.isInitialized() && this.gridSettings.isAtDefaultValues() == false)
{
obj.add("grid", this.gridSettings.toJson());
}
if ((all || this.isRegionPlacementModified()) && this.relativeSubRegionPlacements.isEmpty() == false)
{
JsonArray arr = new JsonArray();
for (Map.Entry<String, SubRegionPlacement> entry : this.relativeSubRegionPlacements.entrySet())
{
JsonObject placementObj = new JsonObject();
placementObj.add("name", new JsonPrimitive(entry.getKey()));
placementObj.add("placement", entry.getValue().toJson());
arr.add(placementObj);
}
obj.add("placements", arr);
}
return obj;
}